From 506c2ba6c7064692a11bf18b0a9ed935a6055ffc Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 4 Oct 2023 12:10:26 +1100 Subject: [PATCH] ST7789v - Allow predefined backlight pin to be disabled. (#5476) * Allow predefined backlight pin to be disabled. * Add test * Update esphome/components/st7789v/display.py --- esphome/components/st7789v/display.py | 7 +++++-- tests/test1.yaml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/esphome/components/st7789v/display.py b/esphome/components/st7789v/display.py index ad152bf356..a4c08974c6 100644 --- a/esphome/components/st7789v/display.py +++ b/esphome/components/st7789v/display.py @@ -138,7 +138,10 @@ CONFIG_SCHEMA = cv.All( cv.Required(CONF_MODEL): cv.one_of(*MODELS.keys(), upper=True, space="_"), cv.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema, cv.Optional(CONF_DC_PIN): pins.gpio_output_pin_schema, - cv.Optional(CONF_BACKLIGHT_PIN): pins.gpio_output_pin_schema, + cv.Optional(CONF_BACKLIGHT_PIN): cv.Any( + cv.boolean, + pins.gpio_output_pin_schema, + ), cv.Optional(CONF_POWER_SUPPLY): cv.use_id(power_supply.PowerSupply), cv.Optional(CONF_EIGHTBITCOLOR, default=False): cv.boolean, cv.Optional(CONF_HEIGHT): cv.int_, @@ -174,7 +177,7 @@ async def to_code(config): reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN]) cg.add(var.set_reset_pin(reset)) - if CONF_BACKLIGHT_PIN in config: + if CONF_BACKLIGHT_PIN in config and config[CONF_BACKLIGHT_PIN]: bl = await cg.gpio_pin_expression(config[CONF_BACKLIGHT_PIN]) cg.add(var.set_backlight_pin(bl)) diff --git a/tests/test1.yaml b/tests/test1.yaml index 11ce86c5f3..ea69343dbf 100644 --- a/tests/test1.yaml +++ b/tests/test1.yaml @@ -2948,7 +2948,7 @@ display: cs_pin: GPIO5 dc_pin: GPIO16 reset_pin: GPIO23 - backlight_pin: GPIO4 + backlight_pin: no lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); - platform: st7920