1
0
mirror of https://github.com/esphome/esphome.git synced 2025-02-14 17:08:22 +00:00

Added Waveshare e-paper display model "7.50inv2p" to the waveshare_epaper component. (#7751)

Co-authored-by: Tim Pehla <tim.pehla@uni-bielefeld.de>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com>
This commit is contained in:
tmpeh 2025-02-11 21:41:52 +01:00 committed by GitHub
parent 6b3f3e1da6
commit 14d7931bd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 264 additions and 0 deletions

View File

@ -91,6 +91,9 @@ WaveshareEPaper7P5InV2 = waveshare_epaper_ns.class_(
WaveshareEPaper7P5InV2alt = waveshare_epaper_ns.class_(
"WaveshareEPaper7P5InV2alt", WaveshareEPaper
)
WaveshareEPaper7P5InV2P = waveshare_epaper_ns.class_(
"WaveshareEPaper7P5InV2P", WaveshareEPaper
)
WaveshareEPaper7P5InHDB = waveshare_epaper_ns.class_(
"WaveshareEPaper7P5InHDB", WaveshareEPaper
)
@ -144,6 +147,7 @@ MODELS = {
"7.50in-bc": ("b", WaveshareEPaper7P5InBC),
"7.50inv2": ("b", WaveshareEPaper7P5InV2),
"7.50inv2alt": ("b", WaveshareEPaper7P5InV2alt),
"7.50inv2p": ("c", WaveshareEPaper7P5InV2P),
"7.50in-hd-b": ("b", WaveshareEPaper7P5InHDB),
"2.13in-ttgo-dke": ("c", WaveshareEPaper2P13InDKE),
"2.13inv3": ("c", WaveshareEPaper2P13InV3),

View File

@ -3100,6 +3100,209 @@ void WaveshareEPaper7P5InV2alt::dump_config() {
LOG_UPDATE_INTERVAL(this);
}
/* 7.50inV2 with partial and fast refresh */
bool WaveshareEPaper7P5InV2P::wait_until_idle_() {
if (this->busy_pin_ == nullptr) {
return true;
}
const uint32_t start = millis();
while (this->busy_pin_->digital_read()) {
this->command(0x71);
if (millis() - start > this->idle_timeout_()) {
ESP_LOGE(TAG, "Timeout while displaying image!");
return false;
}
App.feed_wdt();
delay(10);
}
return true;
}
void WaveshareEPaper7P5InV2P::reset_() {
if (this->reset_pin_ != nullptr) {
this->reset_pin_->digital_write(true);
delay(20);
this->reset_pin_->digital_write(false);
delay(2);
this->reset_pin_->digital_write(true);
delay(20);
}
}
void WaveshareEPaper7P5InV2P::turn_on_display_() {
this->command(0x12);
delay(100); // NOLINT
this->wait_until_idle_();
}
void WaveshareEPaper7P5InV2P::initialize() {
this->reset_();
// COMMAND POWER SETTING
this->command(0x01);
this->data(0x07);
this->data(0x07);
this->data(0x3f);
this->data(0x3f);
// COMMAND BOOSTER SOFT START
this->command(0x06);
this->data(0x17);
this->data(0x17);
this->data(0x28);
this->data(0x17);
// COMMAND POWER DRIVER HAT UP
this->command(0x04);
delay(100); // NOLINT
this->wait_until_idle_();
// COMMAND PANEL SETTING
this->command(0x00);
this->data(0x1F);
// COMMAND RESOLUTION SETTING
this->command(0x61);
this->data(0x03);
this->data(0x20);
this->data(0x01);
this->data(0xE0);
// COMMAND DUAL SPI MM_EN, DUSPI_EN
this->command(0x15);
this->data(0x00);
// COMMAND VCOM AND DATA INTERVAL SETTING
this->command(0x50);
this->data(0x10);
this->data(0x07);
// COMMAND TCON SETTING
this->command(0x60);
this->data(0x22);
// COMMAND ENABLE FAST UPDATE
this->command(0xE0);
this->data(0x02);
this->command(0xE5);
this->data(0x5A);
// COMMAND POWER DRIVER HAT DOWN
this->command(0x02);
}
void HOT WaveshareEPaper7P5InV2P::display() {
uint32_t buf_len = this->get_buffer_length_();
// COMMAND POWER ON
ESP_LOGI(TAG, "Power on the display and hat");
this->command(0x04);
delay(200); // NOLINT
this->wait_until_idle_();
if (this->full_update_every_ == 1) {
this->command(0x13);
for (uint32_t i = 0; i < buf_len; i++) {
this->data(~(this->buffer_[i]));
}
this->turn_on_display_();
this->command(0x02);
this->wait_until_idle_();
return;
}
this->command(0x50);
this->data(0xA9);
this->data(0x07);
if (this->at_update_ == 0) {
// Enable fast refresh
this->command(0xE5);
this->data(0x5A);
this->command(0x92);
this->command(0x10);
delay(2);
for (uint32_t i = 0; i < buf_len; i++) {
this->data(~(this->buffer_[i]));
}
delay(100); // NOLINT
this->wait_until_idle_();
this->command(0x13);
delay(2);
for (uint32_t i = 0; i < buf_len; i++) {
this->data(this->buffer_[i]);
}
delay(100); // NOLINT
this->wait_until_idle_();
this->turn_on_display_();
} else {
// Enable partial refresh
this->command(0xE5);
this->data(0x6E);
// Activate partial refresh and set window bounds
this->command(0x91);
this->command(0x90);
this->data(0x00);
this->data(0x00);
this->data((get_width_internal() - 1) >> 8 & 0xFF);
this->data((get_width_internal() - 1) & 0xFF);
this->data(0x00);
this->data(0x00);
this->data((get_height_internal() - 1) >> 8 & 0xFF);
this->data((get_height_internal() - 1) & 0xFF);
this->data(0x01);
this->command(0x13);
delay(2);
for (uint32_t i = 0; i < buf_len; i++) {
this->data(this->buffer_[i]);
}
delay(100); // NOLINT
this->wait_until_idle_();
this->turn_on_display_();
}
ESP_LOGV(TAG, "Before command(0x02) (>> power off)");
this->command(0x02);
this->wait_until_idle_();
ESP_LOGV(TAG, "After command(0x02) (>> power off)");
this->at_update_ = (this->at_update_ + 1) % this->full_update_every_;
}
int WaveshareEPaper7P5InV2P::get_width_internal() { return 800; }
int WaveshareEPaper7P5InV2P::get_height_internal() { return 480; }
uint32_t WaveshareEPaper7P5InV2P::idle_timeout_() { return 10000; }
void WaveshareEPaper7P5InV2P::dump_config() {
LOG_DISPLAY("", "Waveshare E-Paper", this);
ESP_LOGCONFIG(TAG, " Model: 7.50inv2p");
ESP_LOGCONFIG(TAG, " Full Update Every: %" PRIu32, this->full_update_every_);
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 WaveshareEPaper7P5InV2P::set_full_update_every(uint32_t full_update_every) {
this->full_update_every_ = full_update_every;
}
/* 7.50in-bc */
void WaveshareEPaper7P5InBC::initialize() {
/* The command sequence is similar to the 7P5In display but differs in subtle ways

View File

@ -775,6 +775,43 @@ class WaveshareEPaper7P5InV2alt : public WaveshareEPaper7P5InV2 {
};
};
class WaveshareEPaper7P5InV2P : public WaveshareEPaper {
public:
bool wait_until_idle_();
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
}
void set_full_update_every(uint32_t full_update_every);
protected:
int get_width_internal() override;
int get_height_internal() override;
uint32_t idle_timeout_() override;
uint32_t full_update_every_{30};
uint32_t at_update_{0};
private:
void reset_();
void turn_on_display_();
};
class WaveshareEPaper7P5InHDB : public WaveshareEPaper {
public:
void initialize() override;

View File

@ -675,6 +675,26 @@ display:
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
id: epd_7_50inv2p
model: 7.50inv2p
spi_id: spi_waveshare_epaper
cs_pin:
allow_other_uses: true
number: ${cs_pin}
dc_pin:
allow_other_uses: true
number: ${dc_pin}
busy_pin:
allow_other_uses: true
number: ${busy_pin}
reset_pin:
allow_other_uses: true
number: ${reset_pin}
full_update_every: 30
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
id: epd_7_50hdb
model: 7.50in-hd-b