| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- """ESPHome display platform driving GxEPD2_213_Z98c via a native chunked
- refresh engine (see cycle_engine.h) instead of GxEPD2's own C++ classes.
- Only this one panel is wired up so far - this is the first slice of
- replacing the old GxEPD2-template/FreeRTOS-task component; see the plan
- this was implemented from. catalog.json/vendor/arduino_compat stay in the
- tree as reference material for later panels but aren't used by this file.
- """
- 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_BUSY_PIN, CONF_CS_PIN, CONF_DC_PIN, CONF_ID, CONF_RESET_PIN, CONF_SPI_ID, Framework
- from esphome.types import ConfigType
- CODEOWNERS = ["@zib"]
- DEPENDENCIES = ["spi"]
- gxepd2_ns = cg.esphome_ns.namespace("gxepd2")
- GxEPD2Display = gxepd2_ns.class_("GxEPD2Display", display.DisplayBuffer)
- CONFIG_SCHEMA = cv.All(
- display.FULL_DISPLAY_SCHEMA.extend(
- {
- cv.GenerateID(): cv.declare_id(GxEPD2Display),
- cv.GenerateID(CONF_SPI_ID): cv.use_id(spi.SPIComponent),
- cv.Required(CONF_CS_PIN): pins.gpio_output_pin_schema,
- cv.Required(CONF_DC_PIN): pins.gpio_output_pin_schema,
- cv.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema,
- cv.Optional(CONF_BUSY_PIN): pins.gpio_input_pin_schema,
- }
- ),
- cv.only_with_framework(Framework.ESP_IDF),
- )
- async def to_code(config: ConfigType) -> None:
- var = cg.new_Pvariable(config[CONF_ID])
- cg.add(var.set_cs_pin(await cg.gpio_pin_expression(config[CONF_CS_PIN])))
- cg.add(var.set_dc_pin(await cg.gpio_pin_expression(config[CONF_DC_PIN])))
- if reset_pin := config.get(CONF_RESET_PIN):
- cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin)))
- if busy_pin := config.get(CONF_BUSY_PIN):
- cg.add(var.set_busy_pin(await cg.gpio_pin_expression(busy_pin)))
- spi_parent = await cg.get_variable(config[CONF_SPI_ID])
- cg.add(var.set_spi_parent(spi_parent))
- await display.register_display(var, config)
|