9static const char *
const TAG =
"epaper_spi";
11static constexpr const char *
const EPAPER_STATE_STRINGS[] = {
12 "IDLE",
"UPDATE",
"RESET",
"RESET_END",
14 "SHOULD_WAIT",
"INITIALISE",
"TRANSFER_DATA",
"POWER_ON",
"REFRESH_SCREEN",
"POWER_OFF",
"DEEP_SLEEP",
18 if (
auto idx =
static_cast<unsigned>(this->
state_); idx < std::size(EPAPER_STATE_STRINGS))
19 return EPAPER_STATE_STRINGS[idx];
72 ESP_LOGVV(TAG,
"Command: 0x%02X, Length: %d, Data: %s",
command,
length,
113#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
136 this->delay_until_ = 0;
143#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
252 const uint8_t cmd = sequence[index++];
253 if (
const uint8_t
x = sequence[index++];
x == DELAY_FLAG) {
254 ESP_LOGV(TAG,
"Delay %dms", cmd);
257 const uint8_t num_args =
x & 0x7F;
258 if (
length - index < num_args) {
259 ESP_LOGE(TAG,
"Malformed init sequence, cmd = %X, num_args = %u", cmd, num_args);
263 ESP_LOGV(TAG,
"Command %02X, length %d", cmd, num_args);
264 this->
cmd_data(cmd, sequence + index, num_args);
271 LOG_DISPLAY(
"",
"E-Paper SPI",
this);
272 ESP_LOGCONFIG(TAG,
" Model: %s", this->
name_);
274 LOG_PIN(
" DC Pin: ", this->
dc_pin_);
276 LOG_UPDATE_INTERVAL(
this);
virtual void mark_failed()
Mark this component as failed.
void enable_loop()
Enable this component's loop.
void disable_loop()
Disable this component's loop.
virtual void digital_write(bool value)=0
virtual bool digital_read()=0
virtual void clear()
Clear the entire screen by filling it with OFF pixels.
virtual void power_off()=0
Power the display off.
void command(uint8_t value)
const uint8_t * init_sequence_
void process_state_()
Process the state machine.
virtual void deep_sleep()=0
Place the display into deep sleep.
void on_safe_shutdown() override
uint32_t waiting_for_idle_start_
void loop() override
Called during the loop task.
void dump_config() override
virtual bool transfer_data()=0
Methods that must be implemented by concrete classes to control the display.
split_buffer::SplitBuffer buffer_
void cmd_data(uint8_t command, const uint8_t *ptr, size_t length)
void set_state_(EPaperState state, uint16_t delay=0)
const char * epaper_state_to_string_()
virtual void power_on()=0
Power the display on.
void wait_for_idle_(bool should_wait)
uint32_t waiting_for_idle_last_print_
size_t init_sequence_length_
float get_setup_priority() const override
bool init_buffer_(size_t buffer_length)
virtual void refresh_screen()=0
Refresh the screen after data transfer.
void spi_setup() override
void write_byte(uint8_t data)
void write_array(const uint8_t *data, size_t length)
bool init(size_t total_length)
const float PROCESSOR
For components that use data from sensors like displays.
std::string format_hex_pretty(const uint8_t *data, size_t length, char separator, bool show_length)
Format a byte array in pretty-printed, human-readable hex format.
void IRAM_ATTR HOT delay(uint32_t ms)
uint32_t IRAM_ATTR HOT millis()