Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for V2 of the waveshare 5.83in e-paper display. #3660

Merged
merged 6 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions esphome/components/waveshare_epaper/display.py
Expand Up @@ -38,6 +38,9 @@
WaveshareEPaper5P8In = waveshare_epaper_ns.class_(
"WaveshareEPaper5P8In", WaveshareEPaper
)
WaveshareEPaper5P8InV2 = waveshare_epaper_ns.class_(
"WaveshareEPaper5P8InV2", WaveshareEPaper
)
WaveshareEPaper7P5In = waveshare_epaper_ns.class_(
"WaveshareEPaper7P5In", WaveshareEPaper
)
Expand Down Expand Up @@ -78,6 +81,7 @@
"4.20in": ("b", WaveshareEPaper4P2In),
"4.20in-bv2": ("b", WaveshareEPaper4P2InBV2),
"5.83in": ("b", WaveshareEPaper5P8In),
"5.83inv2": ("b", WaveshareEPaper5P8InV2),
"7.50in": ("b", WaveshareEPaper7P5In),
"7.50in-bv2": ("b", WaveshareEPaper7P5InBV2),
"7.50in-bc": ("b", WaveshareEPaper7P5InBC),
Expand Down
92 changes: 92 additions & 0 deletions esphome/components/waveshare_epaper/waveshare_epaper.cpp
Expand Up @@ -937,6 +937,98 @@ void WaveshareEPaper5P8In::dump_config() {
LOG_PIN(" Busy Pin: ", this->busy_pin_);
LOG_UPDATE_INTERVAL(this);
}

// ========================================================
// 5.83in V2
// Datasheet/Specification/Reference:
// - https://www.waveshare.com/w/upload/3/37/5.83inch_e-Paper_V2_Specification.pdf
// - https://github.com/waveshare/e-Paper/blob/master/Arduino/epd5in83_V2/epd5in83_V2.cpp
// ========================================================
void WaveshareEPaper5P8InV2::initialize() {
/*
// Reset
this->reset_pin_->digital_write(false);
delay(20);
this->reset_pin_->digital_write(true);
delay(5);
this->reset_pin_->digital_write(false);
delay(20);
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out? If it's not needed, then just remove it.


// COMMAND POWER SETTING
this->command(0x01);
this->data(0x07);
this->data(0x07);
this->data(0x3f);
this->data(0x3f);

// COMMAND POWER ON
this->command(0x04);
delay(10);
this->wait_until_idle_();

// PANNEL SETTING
this->command(0x00);
this->data(0x1F);

// COMMAND RESOLUTION SETTING
this->command(0x61);
this->data(0x02);
this->data(0x88);
this->data(0x01);
this->data(0xE0);

this->command(0x15);
this->data(0x00);

// COMMAND TCON SETTING
this->command(0x60);
this->data(0x22);

// Do we need this?
// COMMAND PLL CONTROL
this->command(0x30);
this->data(0x3C); // 3A 100HZ 29 150Hz 39 200HZ 31 171HZ
}
void HOT WaveshareEPaper5P8InV2::display() {
// Reuse the code from WaveshareEPaper4P2In::display()
// COMMAND VCM DC SETTING REGISTER
this->command(0x82);
this->data(0x12);

// COMMAND VCOM AND DATA INTERVAL SETTING
this->command(0x50);
this->data(0x97);

// COMMAND DATA START TRANSMISSION 1
this->command(0x10);
delay(2);
this->start_data_();
this->write_array(this->buffer_, this->get_buffer_length_());
this->end_data_();
delay(2);

// COMMAND DATA START TRANSMISSION 2
this->command(0x13);
delay(2);
this->start_data_();
this->write_array(this->buffer_, this->get_buffer_length_());
this->end_data_();

// COMMAND DISPLAY REFRESH
this->command(0x12);
}
int WaveshareEPaper5P8InV2::get_width_internal() { return 648; }
int WaveshareEPaper5P8InV2::get_height_internal() { return 480; }
void WaveshareEPaper5P8InV2::dump_config() {
LOG_DISPLAY("", "Waveshare E-Paper", this);
ESP_LOGCONFIG(TAG, " Model: 5.83inv2");
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 WaveshareEPaper7P5InBV2::initialize() {
// COMMAND POWER SETTING
this->command(0x01);
Expand Down
43 changes: 43 additions & 0 deletions esphome/components/waveshare_epaper/waveshare_epaper.h
Expand Up @@ -260,6 +260,49 @@ class WaveshareEPaper5P8In : public WaveshareEPaper {
int get_height_internal() override;
};

class WaveshareEPaper5P8InV2 : public WaveshareEPaper {
public:
void initialize() override;

void display() override;

void dump_config() override;

void deep_sleep() override {
// COMMAND VCOM AND DATA INTERVAL SETTING
this->command(0x50);
this->data(0x17); // border floating

// COMMAND VCM DC SETTING
this->command(0x82);
// COMMAND PANEL SETTING
this->command(0x00);

delay(100); // NOLINT

// COMMAND POWER SETTING
this->command(0x01);
this->data(0x00);
this->data(0x00);
this->data(0x00);
this->data(0x00);
this->data(0x00);
delay(100); // NOLINT

// 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;
Expand Down