1
0
mirror of https://github.com/esphome/esphome.git synced 2025-01-22 22:04:06 +00:00
Otto Winter 8e75980ebd
Cleanup dashboard JS (#491)
* Cleanup dashboard JS

* Add vscode

* Save start_mark/end_mark

* Updates

* Updates

* Remove need for cv.nameable

It's a bit hacky but removes so much bloat from integrations

* Add enum helper

* Document APIs, and Improvements

* Fixes

* Fixes

* Update PULL_REQUEST_TEMPLATE.md

* Updates

* Updates

* Updates
2019-04-22 21:56:30 +02:00

36 lines
1.2 KiB
Python

import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import display
from esphome.const import CONF_DIMENSIONS, CONF_LAMBDA
from esphome.core import coroutine
lcd_base_ns = cg.esphome_ns.namespace('lcd_base')
LCDDisplay = lcd_base_ns.class_('LCDDisplay', cg.PollingComponent)
LCDDisplayRef = LCDDisplay.operator('ref')
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]))
if CONF_LAMBDA in config:
lambda_ = yield cg.process_lambda(config[CONF_LAMBDA], [(LCDDisplayRef, 'it')],
return_type=cg.void)
cg.add(var.set_writer(lambda_))