mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 11:44:13 +01:00
9816e677a6
* setup ili9341 framework used epaper-waveshare as start * first version working * added models for now only M5Stack * get_buffer_length is huge * fill, low/high watermark, buffer tests failed. RAM is to small for ili9341 16 bit color mode * removed high/low watermark debug log * added standard 2.4" TFT model * code cleanup * make ledpin optional busy pin is not needed * make bufer 1 byte to avoid the buffer allocation error * gitignore * added backlight pin to dump_config * huge speed increase 8bit color framebuffer (256 colors) lo and high watermark for drawing to screen * fix for images * higher spi data rates * Set spi data rate to 40Mhz Experimental * fixed: formatting fixed: the last row and column being trimmed fixed: namings * Update the code to use Color class * fixed minor color things * fixed linting * #patch minor fixes * fix gitignore too * Update esphome/components/ili9341/ili9341_display.cpp Co-authored-by: Oleg <epushiron+github@gmail.com> * reverting the changes as it's being fixed in PR-1241 Co-authored-by: Michiel van Turnhout <qris.online@gmail.com> Co-authored-by: Michiel van Turnhout <m.vanturnhout@exxellence.nl> Co-authored-by: Oleg <epushiron+github@gmail.com>
61 lines
2.2 KiB
Python
61 lines
2.2 KiB
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome import pins
|
|
from esphome.components import display, spi
|
|
from esphome.const import CONF_DC_PIN, \
|
|
CONF_ID, CONF_LAMBDA, CONF_MODEL, CONF_PAGES, CONF_RESET_PIN
|
|
|
|
DEPENDENCIES = ['spi']
|
|
|
|
CONF_LED_PIN = 'led_pin'
|
|
|
|
ili9341_ns = cg.esphome_ns.namespace('ili9341')
|
|
ili9341 = ili9341_ns.class_('ILI9341Display', cg.PollingComponent, spi.SPIDevice,
|
|
display.DisplayBuffer)
|
|
ILI9341M5Stack = ili9341_ns.class_('ILI9341M5Stack', ili9341)
|
|
ILI9341TFT24 = ili9341_ns.class_('ILI9341TFT24', ili9341)
|
|
|
|
ILI9341Model = ili9341_ns.enum('ILI9341Model')
|
|
|
|
MODELS = {
|
|
'M5STACK': ILI9341Model.M5STACK,
|
|
'TFT_2.4': ILI9341Model.TFT_24,
|
|
}
|
|
|
|
ILI9341_MODEL = cv.enum(MODELS, upper=True, space="_")
|
|
|
|
CONFIG_SCHEMA = cv.All(display.FULL_DISPLAY_SCHEMA.extend({
|
|
cv.GenerateID(): cv.declare_id(ili9341),
|
|
cv.Required(CONF_MODEL): ILI9341_MODEL,
|
|
cv.Required(CONF_DC_PIN): pins.gpio_output_pin_schema,
|
|
cv.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema,
|
|
cv.Optional(CONF_LED_PIN): pins.gpio_output_pin_schema,
|
|
}).extend(cv.polling_component_schema('1s')).extend(spi.spi_device_schema()),
|
|
cv.has_at_most_one_key(CONF_PAGES, CONF_LAMBDA))
|
|
|
|
|
|
def to_code(config):
|
|
if config[CONF_MODEL] == 'M5STACK':
|
|
lcd_type = ILI9341M5Stack
|
|
if config[CONF_MODEL] == 'TFT_2.4':
|
|
lcd_type = ILI9341TFT24
|
|
rhs = lcd_type.new()
|
|
var = cg.Pvariable(config[CONF_ID], rhs)
|
|
|
|
yield cg.register_component(var, config)
|
|
yield display.register_display(var, config)
|
|
yield spi.register_spi_device(var, config)
|
|
cg.add(var.set_model(config[CONF_MODEL]))
|
|
dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN])
|
|
cg.add(var.set_dc_pin(dc))
|
|
|
|
if CONF_LAMBDA in config:
|
|
lambda_ = yield cg.process_lambda(config[CONF_LAMBDA], [(display.DisplayBufferRef, 'it')],
|
|
return_type=cg.void)
|
|
cg.add(var.set_writer(lambda_))
|
|
if CONF_RESET_PIN in config:
|
|
reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN])
|
|
cg.add(var.set_reset_pin(reset))
|
|
if CONF_LED_PIN in config:
|
|
led_pin = yield cg.gpio_pin_expression(config[CONF_LED_PIN])
|
|
cg.add(var.set_led_pin(led_pin))
|