From 7fa5cab8e368bdfacb07b40bb826bf19c8f8cf46 Mon Sep 17 00:00:00 2001 From: sredfern Date: Sat, 2 May 2020 10:30:52 +1000 Subject: [PATCH] Extending Support to 5.83in Waveshare eink B/W displays (#1009) * Extending Support to 5.83in Waveshare eink B/W displays * Fixed lint issues --- .../components/waveshare_epaper/display.py | 2 + .../waveshare_epaper/waveshare_epaper.cpp | 95 +++++++++++++++++++ .../waveshare_epaper/waveshare_epaper.h | 23 +++++ 3 files changed, 120 insertions(+) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index bbbd8c0d3ae9..a654e559815b 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -14,6 +14,7 @@ WaveshareEPaper2P7In = waveshare_epaper_ns.class_('WaveshareEPaper2P7In', WaveshareEPaper) WaveshareEPaper2P9InB = waveshare_epaper_ns.class_('WaveshareEPaper2P9InB', WaveshareEPaper) WaveshareEPaper4P2In = waveshare_epaper_ns.class_('WaveshareEPaper4P2In', WaveshareEPaper) +WaveshareEPaper5P8In = waveshare_epaper_ns.class_('WaveshareEPaper5P8In', WaveshareEPaper) WaveshareEPaper7P5In = waveshare_epaper_ns.class_('WaveshareEPaper7P5In', WaveshareEPaper) WaveshareEPaperTypeAModel = waveshare_epaper_ns.enum('WaveshareEPaperTypeAModel') @@ -28,6 +29,7 @@ '2.70in': ('b', WaveshareEPaper2P7In), '2.90in-b': ('b', WaveshareEPaper2P9InB), '4.20in': ('b', WaveshareEPaper4P2In), + '5.83in': ('b', WaveshareEPaper5P8In), '7.50in': ('b', WaveshareEPaper7P5In), } diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index 695ba9c45551..c145fb361c00 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -657,6 +657,101 @@ void WaveshareEPaper4P2In::dump_config() { LOG_UPDATE_INTERVAL(this); } +void WaveshareEPaper5P8In::initialize() { + // COMMAND POWER SETTING + this->command(0x01); + this->data(0x37); + this->data(0x00); + + // COMMAND PANEL SETTING + this->command(0x00); + this->data(0xCF); + this->data(0x0B); + + // COMMAND BOOSTER SOFT START + this->command(0x06); + this->data(0xC7); + this->data(0xCC); + this->data(0x28); + + // COMMAND POWER ON + this->command(0x04); + this->wait_until_idle_(); + delay(10); + + // COMMAND PLL CONTROL + this->command(0x30); + this->data(0x3C); + + // COMMAND TEMPERATURE SENSOR CALIBRATION + this->command(0x41); + this->data(0x00); + + // COMMAND VCOM AND DATA INTERVAL SETTING + this->command(0x50); + this->data(0x77); + + // COMMAND TCON SETTING + this->command(0x60); + this->data(0x22); + + // COMMAND RESOLUTION SETTING + this->command(0x61); + this->data(0x02); + this->data(0x58); + this->data(0x01); + this->data(0xC0); + + // COMMAND VCM DC SETTING REGISTER + this->command(0x82); + this->data(0x1E); + + this->command(0xE5); + this->data(0x03); +} +void HOT WaveshareEPaper5P8In::display() { + // COMMAND DATA START TRANSMISSION 1 + this->command(0x10); + + this->start_data_(); + for (size_t i = 0; i < this->get_buffer_length_(); i++) { + uint8_t temp1 = this->buffer_[i]; + for (uint8_t j = 0; j < 8; j++) { + uint8_t temp2; + if (temp1 & 0x80) + temp2 = 0x03; + else + temp2 = 0x00; + + temp2 <<= 4; + temp1 <<= 1; + j++; + if (temp1 & 0x80) + temp2 |= 0x03; + else + temp2 |= 0x00; + temp1 <<= 1; + this->write_byte(temp2); + } + + App.feed_wdt(); + } + this->end_data_(); + + // COMMAND DISPLAY REFRESH + this->command(0x12); +} +int WaveshareEPaper5P8In::get_width_internal() { return 600; } +int WaveshareEPaper5P8In::get_height_internal() { return 448; } +void WaveshareEPaper5P8In::dump_config() { + LOG_DISPLAY("", "Waveshare E-Paper", this); + ESP_LOGCONFIG(TAG, " Model: 5.83in"); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} + void WaveshareEPaper7P5In::initialize() { // COMMAND POWER SETTING this->command(0x01); diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index c21cabcaf40f..1ed74753508b 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -190,6 +190,29 @@ class WaveshareEPaper4P2In : public WaveshareEPaper { int get_height_internal() override; }; +class WaveshareEPaper5P8In : public WaveshareEPaper { + public: + void initialize() override; + + void display() override; + + void dump_config() override; + + void deep_sleep() override { + // COMMAND POWER OFF + this->command(0x02); + this->wait_until_idle_(); + // COMMAND DEEP SLEEP + this->command(0x07); + this->data(0xA5); // check byte + } + + protected: + int get_width_internal() override; + + int get_height_internal() override; +}; + class WaveshareEPaper7P5In : public WaveshareEPaper { public: void initialize() override;