[epaper_spi] Metadata, bug fixes, new model (#16950)

This commit is contained in:
Clyde Stubbs
2026-06-15 12:10:58 +10:00
committed by GitHub
parent 8d2c2e6adc
commit f1fd5f2f49
9 changed files with 412 additions and 80 deletions
+21 -1
View File
@@ -13,6 +13,7 @@ from esphome.components.mipi import (
import esphome.config_validation as cv
from esphome.config_validation import update_interval
from esphome.const import (
CONF_AUTO_CLEAR_ENABLED,
CONF_BUSY_PIN,
CONF_CS_PIN,
CONF_DATA_RATE,
@@ -129,7 +130,23 @@ def customise_schema(config):
},
extra=cv.ALLOW_EXTRA,
)(config)
return model_schema(config)(config)
model = MODELS[config[CONF_MODEL]]
config = model_schema(config)(config)
width, height = model.get_dimensions(config)
display.add_metadata(
config[CONF_ID],
width,
height,
has_hardware_rotation=True,
byte_order=cv.UNDEFINED,
has_writer=config.get(CONF_AUTO_CLEAR_ENABLED) is True
or config.get(CONF_PAGES) is not None
or config.get(CONF_LAMBDA) is not None
or config.get(CONF_SHOW_TEST_CARD) is True,
rotation=config.get(CONF_ROTATION, 0),
draw_rounding=0,
)
return config
CONFIG_SCHEMA = customise_schema
@@ -197,6 +214,9 @@ async def to_code(config):
if busy_pin := config.get(CONF_BUSY_PIN):
busy = await cg.gpio_pin_expression(busy_pin)
cg.add(var.set_busy_pin(busy))
if enable_pin := config.get(CONF_ENABLE_PIN):
enable = [await cg.gpio_pin_expression(pin) for pin in enable_pin]
cg.add(var.set_enable_pins(enable))
cg.add(var.set_full_update_every(config[CONF_FULL_UPDATE_EVERY]))
if CONF_RESET_DURATION in config:
cg.add(var.set_reset_duration(config[CONF_RESET_DURATION]))
@@ -38,6 +38,10 @@ bool EPaperBase::init_buffer_(size_t buffer_length) {
}
void EPaperBase::setup_pins_() const {
for (auto *pin : this->enable_pins_) {
pin->setup();
pin->digital_write(true);
}
this->dc_pin_->setup(); // OUTPUT
this->dc_pin_->digital_write(false);
@@ -50,6 +50,7 @@ class EPaperBase : public Display,
float get_setup_priority() const override;
void set_reset_pin(GPIOPin *reset) { this->reset_pin_ = reset; }
void set_busy_pin(GPIOPin *busy) { this->busy_pin_ = busy; }
void set_enable_pins(std::vector<GPIOPin *> enable_pins) { this->enable_pins_ = std::move(enable_pins); }
void set_reset_duration(uint32_t reset_duration) { this->reset_duration_ = reset_duration; }
void set_transform(uint8_t transform) {
this->transform_ = transform;
@@ -177,6 +178,7 @@ class EPaperBase : public Display,
GPIOPin *dc_pin_{};
GPIOPin *busy_pin_{};
GPIOPin *reset_pin_{};
std::vector<GPIOPin *> enable_pins_{};
bool waiting_for_idle_{};
uint32_t delay_until_{}; // timestamp until which to delay processing
uint16_t next_delay_{}; // milliseconds to delay before next state
@@ -10,11 +10,11 @@ class SSD1677(EpaperModel):
# fmt: off
def get_init_sequence(self, config: dict):
width, _height = self.get_dimensions(config)
_width, height = self.get_dimensions(config)
return (
(0x18, 0x80), # Select internal Temp sensor
(0x0C, 0xAE, 0xC7, 0xC3, 0xC0, 0x80), # inrush current level 2
(0x01, (width - 1) % 256, (width - 1) // 256, 0x02), # Set column gate limit
(0x01, (height - 1) % 256, (height - 1) // 256, 0x02), # Set gate limit (number of rows-1)
(0x3C, 0x01), # Set border waveform
(0x11, 3), # Set transform
)
@@ -51,3 +51,16 @@ ssd1677.extend(
height=480,
mirror_x=True,
)
ssd1677.extend(
"seeed-reterminal-sticky",
width=800,
height=480,
mirror_x=True,
enable_pin=47,
cs_pin=15,
dc_pin=16,
reset_pin=17,
busy_pin=18,
data_rate="10MHz",
)