mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-19 12:43:28 +02:00
30a542e763
* Add backlight handling for lcd_pcf8574 Switch the backlight on or off by calling id(mydisplay).backlight() or id(mydisplay).no_backlight() in lamda functions (assuming mydisplay is the custom id for the LCD). * Use abstract method Co-authored-by: Attila Darazs <attila@darazs.com> Co-authored-by: Otto Winter <otto@otto-winter.com>
30 lines
963 B
Python
30 lines
963 B
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import display
|
|
from esphome.const import CONF_DIMENSIONS
|
|
from esphome.core import coroutine
|
|
|
|
lcd_base_ns = cg.esphome_ns.namespace('lcd_base')
|
|
LCDDisplay = lcd_base_ns.class_('LCDDisplay', cg.PollingComponent)
|
|
|
|
|
|
def validate_lcd_dimensions(value):
|
|
value = cv.dimensions(value)
|
|
if value[0] > 0x40:
|
|
raise cv.Invalid("LCD displays can't have more than 64 columns")
|
|
if value[1] > 4:
|
|
raise cv.Invalid("LCD displays can't have more than 4 rows")
|
|
return value
|
|
|
|
|
|
LCD_SCHEMA = display.BASIC_DISPLAY_SCHEMA.extend({
|
|
cv.Required(CONF_DIMENSIONS): validate_lcd_dimensions,
|
|
}).extend(cv.polling_component_schema('1s'))
|
|
|
|
|
|
@coroutine
|
|
def setup_lcd_display(var, config):
|
|
yield cg.register_component(var, config)
|
|
yield display.register_display(var, config)
|
|
cg.add(var.set_dimensions(config[CONF_DIMENSIONS][0], config[CONF_DIMENSIONS][1]))
|