Add support for Waveshare 2.13" V2 display (#6337)

* Add support for Waveshare 2.13" V2 display

* Fix clang-tidy error, add comment about BUSY in deep sleep

* Add test

* Add nullptr check and move tests to separate file

* Fix GPIO pins in test
This commit is contained in:
Manuel Kasper 2024-03-11 19:38:59 +01:00 committed by GitHub
parent 32be12423a
commit a96762220a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 228 additions and 137 deletions

View File

@ -85,6 +85,9 @@ WaveshareEPaper7P5InHDB = waveshare_epaper_ns.class_(
WaveshareEPaper2P13InDKE = waveshare_epaper_ns.class_(
"WaveshareEPaper2P13InDKE", WaveshareEPaper
)
WaveshareEPaper2P13InV2 = waveshare_epaper_ns.class_(
"WaveshareEPaper2P13InV2", WaveshareEPaper
)
WaveshareEPaper2P13InV3 = waveshare_epaper_ns.class_(
"WaveshareEPaper2P13InV3", WaveshareEPaper
)
@ -97,6 +100,7 @@ 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.13inv2": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_13_IN_V2),
"2.13in-ttgo": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN),
"2.13in-ttgo-b1": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN_B1),
"2.13in-ttgo-b73": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN_B73),

View File

@ -256,12 +256,14 @@ void WaveshareEPaperTypeA::initialize() {
}
}
void WaveshareEPaperTypeA::init_display_() {
if (this->model_ == TTGO_EPAPER_2_13_IN_B74) {
if (this->model_ == TTGO_EPAPER_2_13_IN_B74 || this->model_ == WAVESHARE_EPAPER_2_13_IN_V2) {
if (this->reset_pin_ != nullptr) {
this->reset_pin_->digital_write(false);
delay(10);
this->reset_pin_->digital_write(true);
delay(10);
this->wait_until_idle_();
}
this->command(0x12); // SWRESET
this->wait_until_idle_();
@ -321,6 +323,9 @@ void WaveshareEPaperTypeA::dump_config() {
case WAVESHARE_EPAPER_2_13_IN:
ESP_LOGCONFIG(TAG, " Model: 2.13in");
break;
case WAVESHARE_EPAPER_2_13_IN_V2:
ESP_LOGCONFIG(TAG, " Model: 2.13inV2");
break;
case TTGO_EPAPER_2_13_IN:
ESP_LOGCONFIG(TAG, " Model: 2.13in (TTGO)");
break;
@ -366,6 +371,8 @@ void HOT WaveshareEPaperTypeA::display() {
if (full_update != prev_full_update) {
switch (this->model_) {
case TTGO_EPAPER_2_13_IN:
case WAVESHARE_EPAPER_2_13_IN_V2:
// Waveshare 2.13" V2 uses the same LUTs as TTGO
this->write_lut_(full_update ? FULL_UPDATE_LUT_TTGO : PARTIAL_UPDATE_LUT_TTGO, LUT_SIZE_TTGO);
break;
case TTGO_EPAPER_2_13_IN_B73:
@ -384,6 +391,41 @@ void HOT WaveshareEPaperTypeA::display() {
this->at_update_ = (this->at_update_ + 1) % this->full_update_every_;
}
if (this->model_ == WAVESHARE_EPAPER_2_13_IN_V2) {
// Set VCOM for full or partial update
this->command(0x2C);
this->data(full_update ? 0x55 : 0x26);
if (!full_update) {
// Enable "ping-pong"
this->command(0x37);
this->data(0x00);
this->data(0x00);
this->data(0x00);
this->data(0x00);
this->data(0x40);
this->data(0x00);
this->data(0x00);
this->command(0x22);
this->data(0xc0);
this->command(0x20);
}
}
// Border waveform
switch (this->model_) {
case TTGO_EPAPER_2_13_IN_B74:
this->command(0x3C);
this->data(full_update ? 0x05 : 0x80);
break;
case WAVESHARE_EPAPER_2_13_IN_V2:
this->command(0x3C);
this->data(full_update ? 0x03 : 0x01);
break;
default:
break;
}
// Set x & y regions we want to write to (full)
switch (this->model_) {
case TTGO_EPAPER_2_13_IN_B1:
@ -407,12 +449,6 @@ void HOT WaveshareEPaperTypeA::display() {
this->data((this->get_height_internal() - 1) >> 8);
break;
case TTGO_EPAPER_2_13_IN_B74:
// BorderWaveform
this->command(0x3C);
this->data(full_update ? 0x05 : 0x80);
// fall through
default:
// COMMAND SET RAM X ADDRESS START END POSITION
this->command(0x44);
@ -458,6 +494,14 @@ void HOT WaveshareEPaperTypeA::display() {
}
this->end_data_();
if (this->model_ == WAVESHARE_EPAPER_2_13_IN_V2 && full_update) {
// Write base image again on full refresh
this->command(0x26);
this->start_data_();
this->write_array(this->buffer_, this->get_buffer_length_());
this->end_data_();
}
// COMMAND DISPLAY UPDATE CONTROL 2
this->command(0x22);
switch (this->model_) {
@ -469,6 +513,9 @@ void HOT WaveshareEPaperTypeA::display() {
case TTGO_EPAPER_2_13_IN_B73:
this->data(0xC7);
break;
case WAVESHARE_EPAPER_2_13_IN_V2:
this->data(full_update ? 0xC7 : 0x0C);
break;
default:
this->data(0xC4);
break;
@ -492,6 +539,7 @@ int WaveshareEPaperTypeA::get_width_internal() {
case WAVESHARE_EPAPER_1_54_IN_V2:
return 200;
case WAVESHARE_EPAPER_2_13_IN:
case WAVESHARE_EPAPER_2_13_IN_V2:
case TTGO_EPAPER_2_13_IN:
case TTGO_EPAPER_2_13_IN_B73:
case TTGO_EPAPER_2_13_IN_B74:
@ -507,6 +555,7 @@ int WaveshareEPaperTypeA::get_width_internal() {
int WaveshareEPaperTypeA::get_width_controller() {
switch (this->model_) {
case WAVESHARE_EPAPER_2_13_IN:
case WAVESHARE_EPAPER_2_13_IN_V2:
case TTGO_EPAPER_2_13_IN:
case TTGO_EPAPER_2_13_IN_B73:
case TTGO_EPAPER_2_13_IN_B74:
@ -522,6 +571,7 @@ int WaveshareEPaperTypeA::get_height_internal() {
case WAVESHARE_EPAPER_1_54_IN_V2:
return 200;
case WAVESHARE_EPAPER_2_13_IN:
case WAVESHARE_EPAPER_2_13_IN_V2:
case TTGO_EPAPER_2_13_IN:
case TTGO_EPAPER_2_13_IN_B73:
case TTGO_EPAPER_2_13_IN_B74:
@ -548,6 +598,7 @@ uint32_t WaveshareEPaperTypeA::idle_timeout_() {
switch (this->model_) {
case WAVESHARE_EPAPER_1_54_IN:
case WAVESHARE_EPAPER_1_54_IN_V2:
case WAVESHARE_EPAPER_2_13_IN_V2:
case TTGO_EPAPER_2_13_IN_B1:
return 2500;
default:

View File

@ -90,6 +90,7 @@ enum WaveshareEPaperTypeAModel {
WAVESHARE_EPAPER_1_54_IN = 0,
WAVESHARE_EPAPER_1_54_IN_V2,
WAVESHARE_EPAPER_2_13_IN,
WAVESHARE_EPAPER_2_13_IN_V2,
WAVESHARE_EPAPER_2_9_IN,
WAVESHARE_EPAPER_2_9_IN_V2,
TTGO_EPAPER_2_13_IN,
@ -114,6 +115,7 @@ class WaveshareEPaperTypeA : public WaveshareEPaper {
case WAVESHARE_EPAPER_1_54_IN:
case WAVESHARE_EPAPER_1_54_IN_V2:
case WAVESHARE_EPAPER_2_9_IN_V2:
case WAVESHARE_EPAPER_2_13_IN_V2:
// COMMAND DEEP SLEEP MODE
this->command(0x10);
this->data(0x01);
@ -124,8 +126,12 @@ class WaveshareEPaperTypeA : public WaveshareEPaper {
this->command(0x10);
break;
}
if (this->model_ != WAVESHARE_EPAPER_2_13_IN_V2) {
// From panel specification:
// "After this command initiated, the chip will enter Deep Sleep Mode, BUSY pad will keep output high."
this->wait_until_idle_();
}
}
void set_full_update_every(uint32_t full_update_every);

View File

@ -0,0 +1,154 @@
---
spi:
- id: spi_id_1
clk_pin:
number: GPIO18
mosi_pin:
number: GPIO23
miso_pin:
number: GPIO19
interface: hardware
display:
- platform: waveshare_epaper
model: 2.13in-ttgo-b1
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO25
dc_pin:
allow_other_uses: true
number: GPIO26
busy_pin:
allow_other_uses: true
number: GPIO27
reset_pin:
allow_other_uses: true
number: GPIO32
full_update_every: 30
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
model: 2.90in
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO25
dc_pin:
allow_other_uses: true
number: GPIO26
busy_pin:
allow_other_uses: true
number: GPIO27
reset_pin:
allow_other_uses: true
number: GPIO32
full_update_every: 30
reset_duration: 200ms
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
model: 2.90inv2
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO25
dc_pin:
allow_other_uses: true
number: GPIO26
busy_pin:
allow_other_uses: true
number: GPIO27
reset_pin:
allow_other_uses: true
number: GPIO32
full_update_every: 30
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
model: 2.70in-b
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO25
dc_pin:
allow_other_uses: true
number: GPIO26
busy_pin:
allow_other_uses: true
number: GPIO27
reset_pin:
allow_other_uses: true
number: GPIO32
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
model: 2.70in-bv2
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO25
dc_pin:
allow_other_uses: true
number: GPIO26
busy_pin:
allow_other_uses: true
number: GPIO27
reset_pin:
allow_other_uses: true
number: GPIO32
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
model: 1.54in-m5coreink-m09
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO25
dc_pin:
allow_other_uses: true
number: GPIO26
busy_pin:
allow_other_uses: true
number: GPIO27
reset_pin:
allow_other_uses: true
number: GPIO32
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
model: 2.13inv3
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO25
dc_pin:
allow_other_uses: true
number: GPIO26
busy_pin:
allow_other_uses: true
number: GPIO27
reset_pin:
allow_other_uses: true
number: GPIO32
full_update_every: 30
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
model: 2.13inv2
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO25
dc_pin:
allow_other_uses: true
number: GPIO26
busy_pin:
allow_other_uses: true
number: GPIO27
reset_pin:
allow_other_uses: true
number: GPIO32
full_update_every: 30
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());

View File

@ -612,112 +612,6 @@ display:
rotation: 0°
update_interval: 16ms
- platform: waveshare_epaper
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO23
dc_pin:
allow_other_uses: true
number: GPIO23
busy_pin:
allow_other_uses: true
number: GPIO23
reset_pin:
allow_other_uses: true
number: GPIO23
model: 2.13in-ttgo-b1
full_update_every: 30
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO23
dc_pin:
allow_other_uses: true
number: GPIO23
busy_pin:
allow_other_uses: true
number: GPIO23
reset_pin:
allow_other_uses: true
number: GPIO23
model: 2.90in
full_update_every: 30
reset_duration: 200ms
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO23
dc_pin:
allow_other_uses: true
number: GPIO23
busy_pin:
allow_other_uses: true
number: GPIO23
reset_pin:
allow_other_uses: true
number: GPIO23
model: 2.90inv2
full_update_every: 30
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO23
dc_pin:
allow_other_uses: true
number: GPIO23
busy_pin:
allow_other_uses: true
number: GPIO23
reset_pin:
allow_other_uses: true
number: GPIO23
model: 2.70in-b
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO23
dc_pin:
allow_other_uses: true
number: GPIO23
busy_pin:
allow_other_uses: true
number: GPIO23
reset_pin:
allow_other_uses: true
number: GPIO23
model: 2.70in-bv2
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO23
dc_pin:
allow_other_uses: true
number: GPIO23
busy_pin:
allow_other_uses: true
number: GPIO23
reset_pin:
allow_other_uses: true
number: GPIO23
model: 1.54in-m5coreink-m09
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: inkplate6
id: inkplate_display
greyscale: false
@ -771,24 +665,6 @@ display:
vcom_pin:
number: GPIO1
allow_other_uses: true
- platform: waveshare_epaper
spi_id: spi_id_1
cs_pin:
number: GPIO23
allow_other_uses: true
dc_pin:
number: GPIO23
allow_other_uses: true
busy_pin:
number: GPIO23
allow_other_uses: true
reset_pin:
number: GPIO23
allow_other_uses: true
model: 2.13inv3
full_update_every: 30
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
number:
- platform: tuya