diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index db138c6ff5..bbcbfc1fc6 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -9,14 +9,14 @@ from esphome.const import ( CONF_ID, CONF_LAMBDA, CONF_MODEL, + CONF_NUM_SEGMENTS_X, + CONF_NUM_SEGMENTS_Y, CONF_PAGES, CONF_RESET_DURATION, CONF_RESET_PIN, ) DEPENDENCIES = ["spi"] -CONF_NUM_SEGMENTS_X = "num_segments_x" -CONF_NUM_SEGMENTS_Y = "num_segments_y" waveshare_epaper_ns = cg.esphome_ns.namespace("waveshare_epaper") WaveshareEPaperBase = waveshare_epaper_ns.class_( "WaveshareEPaperBase", cg.PollingComponent, spi.SPIDevice, display.DisplayBuffer diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index 03013955a8..11d70d6f8e 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -1584,13 +1584,34 @@ void GDEY075Z08::calculate_CRCs_(bool fullSync) { } void GDEY075Z08::set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; } +void GDEY075Z08::set_num_segments_x(uint8_t value) { + if (this->get_width_internal() % (value * 8) != 0) { + ESP_LOGD(TAG, + "Invalid number of X Segments (%d) The display width divided by number of segments must be divisible by " + "8 for " + "proper byte boundaries. Setting num_segments_x to 20.", + value); // We actually don't have to do anything, 10 is the default value :o) + } else { + this->seg_x_ = value; + } +} +void GDEY075Z08::set_num_segments_y(uint8_t value) { + if (this->get_height_internal() % value != 0) { + ESP_LOGD(TAG, + "Invalid number of Y Segments (%d). The display height (480px) must be divisible by the number of y " + "segments for equal segment height. Setting num_segments_y to 10.", + value); // We actually don't have to do anything, 10 is the default value :o) + } else { + this->seg_y_ = value; + } +} void GDEY075Z08::init_fast() { this->reset_(); // Module reset this->command(0x00); // PANNEL SETTING - this->data(0x0F); // KW-3f KWR-2F BWROTP 0f BWOTP 1f + this->data(0x0F); // KW-3f KWR-2F BWROTP 0f BWOTP 1f this->command(0x04); - delay(100); + delay(100); // NOLINT this->wait_until_idle_(); // waiting for the electronic paper IC to release the idle signal // Enhanced display drive(Add 0x06 command) @@ -1772,7 +1793,7 @@ void GDEY075Z08::deep_sleep() { this->command(0x50); this->data(0xF7); // check byte this->command(0x02); - delay(100); + delay(100); // NOLINT this->command(0x07); this->data(0xA5); ESP_LOGI(TAG, "Display now in deep sleep."); diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 90d29846da..88b36242d7 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -237,28 +237,8 @@ class GDEY075Z08 : public WaveshareEPaperBWR { void dump_config() override; void deep_sleep() override; void set_full_update_every(uint32_t full_update_every); - void set_num_segments_x(uint8_t value) { - if (this->get_width_internal() % (value * 8) != 0) { - ESP_LOGD(TAG, - "Invalid number of X Segments (%d) The display width divided by number of segments must be divisible by " - "8 for " - "proper byte boundaries. Setting num_segments_x to 20.", - value); - } else { - this->seg_x_ = value; - } - } - void set_num_segments_y(uint8_t value) { - if (this->get_height_internal() % value != 0) { - ESP_LOGD(TAG, - "Invalid number of Y Segments (%d). The display height (480px) must be divisible by the number of y " - "segments for equal segment height. Setting num_segments_y to 10.", - value); - uint8_t replacementvalue = this->get_height_internal() / - } else { - this->seg_y_ = value; - } - } + void set_num_segments_x(uint8_t value); + void set_num_segments_y(uint8_t value); protected: bool wait_until_idle_();