From 8b737aabd9ad7fd675e00aa53003ae67983e6efb Mon Sep 17 00:00:00 2001 From: Geoff Davis Date: Wed, 9 Jun 2021 19:05:27 -0700 Subject: [PATCH] Add support for waveshare_epaper 1.54v2 (#1843) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/components/waveshare_epaper/display.py | 3 ++- esphome/components/waveshare_epaper/waveshare_epaper.cpp | 9 ++++++++- esphome/components/waveshare_epaper/waveshare_epaper.h | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 42509f39f1..3e1132bb1d 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -46,6 +46,7 @@ WaveshareEPaperTypeBModel = waveshare_epaper_ns.enum("WaveshareEPaperTypeBModel" MODELS = { "1.54in": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_1_54_IN), + "1.54inv2": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_1_54_IN_V2), "2.13in": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_13_IN), "2.13in-ttgo": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN), "2.13in-ttgo-b1": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN_B1), @@ -67,7 +68,7 @@ def validate_full_update_every_only_type_a(value): if MODELS[value[CONF_MODEL]][0] != "a": raise cv.Invalid( "The 'full_update_every' option is only available for models " - "'1.54in', '2.13in', '2.90in', and '2.90inV2'." + "'1.54in', '1.54inV2', '2.13in', '2.90in', and '2.90inV2'." ) return value diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index 0fb783107d..daaa77b7fa 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -210,6 +210,9 @@ void WaveshareEPaperTypeA::dump_config() { case WAVESHARE_EPAPER_1_54_IN: ESP_LOGCONFIG(TAG, " Model: 1.54in"); break; + case WAVESHARE_EPAPER_1_54_IN_V2: + ESP_LOGCONFIG(TAG, " Model: 1.54inV2"); + break; case WAVESHARE_EPAPER_2_13_IN: ESP_LOGCONFIG(TAG, " Model: 2.13in"); break; @@ -334,7 +337,7 @@ void HOT WaveshareEPaperTypeA::display() { // COMMAND DISPLAY UPDATE CONTROL 2 this->command(0x22); - if (this->model_ == WAVESHARE_EPAPER_2_9_IN_V2) { + if (this->model_ == WAVESHARE_EPAPER_2_9_IN_V2 || this->model_ == WAVESHARE_EPAPER_1_54_IN_V2) { this->data(full_update ? 0xF7 : 0xFF); } else if (this->model_ == TTGO_EPAPER_2_13_IN_B73) { this->data(0xC7); @@ -353,6 +356,8 @@ int WaveshareEPaperTypeA::get_width_internal() { switch (this->model_) { case WAVESHARE_EPAPER_1_54_IN: return 200; + case WAVESHARE_EPAPER_1_54_IN_V2: + return 200; case WAVESHARE_EPAPER_2_13_IN: return 128; case TTGO_EPAPER_2_13_IN: @@ -372,6 +377,8 @@ int WaveshareEPaperTypeA::get_height_internal() { switch (this->model_) { case WAVESHARE_EPAPER_1_54_IN: return 200; + case WAVESHARE_EPAPER_1_54_IN_V2: + return 200; case WAVESHARE_EPAPER_2_13_IN: return 250; case TTGO_EPAPER_2_13_IN: diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 0b8958e7f0..8ab77d653b 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -66,6 +66,7 @@ class WaveshareEPaper : public PollingComponent, enum WaveshareEPaperTypeAModel { WAVESHARE_EPAPER_1_54_IN = 0, + WAVESHARE_EPAPER_1_54_IN_V2, WAVESHARE_EPAPER_2_13_IN, WAVESHARE_EPAPER_2_9_IN, WAVESHARE_EPAPER_2_9_IN_V2, @@ -85,7 +86,7 @@ class WaveshareEPaperTypeA : public WaveshareEPaper { void display() override; void deep_sleep() override { - if (this->model_ == WAVESHARE_EPAPER_2_9_IN_V2) { + if (this->model_ == WAVESHARE_EPAPER_2_9_IN_V2 || this->model_ == WAVESHARE_EPAPER_1_54_IN_V2) { // COMMAND DEEP SLEEP MODE this->command(0x10); this->data(0x01);