ST7789v - Allow predefined backlight pin to be disabled. (#5476)

* Allow predefined backlight pin to be disabled.

* Add test

* Update esphome/components/st7789v/display.py
This commit is contained in:
Clyde Stubbs 2023-10-04 12:10:26 +11:00 committed by GitHub
parent 050fa0d4c1
commit 506c2ba6c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -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))

View file

@ -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