mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 23:18:10 +01:00
Waveshare e-ink 2IN9_V2 - fix full and partial update based on vendor SDK and examples (#5481)
Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com>
This commit is contained in:
parent
f73518dbeb
commit
37138d4f28
3 changed files with 247 additions and 0 deletions
|
@ -45,6 +45,9 @@ WaveshareEPaper2P9InB = waveshare_epaper_ns.class_(
|
||||||
WaveshareEPaper2P9InBV3 = waveshare_epaper_ns.class_(
|
WaveshareEPaper2P9InBV3 = waveshare_epaper_ns.class_(
|
||||||
"WaveshareEPaper2P9InBV3", WaveshareEPaper
|
"WaveshareEPaper2P9InBV3", WaveshareEPaper
|
||||||
)
|
)
|
||||||
|
WaveshareEPaper2P9InV2R2 = waveshare_epaper_ns.class_(
|
||||||
|
"WaveshareEPaper2P9InV2R2", WaveshareEPaper
|
||||||
|
)
|
||||||
GDEY029T94 = waveshare_epaper_ns.class_("GDEY029T94", WaveshareEPaper)
|
GDEY029T94 = waveshare_epaper_ns.class_("GDEY029T94", WaveshareEPaper)
|
||||||
WaveshareEPaper4P2In = waveshare_epaper_ns.class_(
|
WaveshareEPaper4P2In = waveshare_epaper_ns.class_(
|
||||||
"WaveshareEPaper4P2In", WaveshareEPaper
|
"WaveshareEPaper4P2In", WaveshareEPaper
|
||||||
|
@ -107,6 +110,7 @@ MODELS = {
|
||||||
"2.70inv2": ("b", WaveshareEPaper2P7InV2),
|
"2.70inv2": ("b", WaveshareEPaper2P7InV2),
|
||||||
"2.90in-b": ("b", WaveshareEPaper2P9InB),
|
"2.90in-b": ("b", WaveshareEPaper2P9InB),
|
||||||
"2.90in-bv3": ("b", WaveshareEPaper2P9InBV3),
|
"2.90in-bv3": ("b", WaveshareEPaper2P9InBV3),
|
||||||
|
"2.90inv2-r2": ("c", WaveshareEPaper2P9InV2R2),
|
||||||
"4.20in": ("b", WaveshareEPaper4P2In),
|
"4.20in": ("b", WaveshareEPaper4P2In),
|
||||||
"4.20in-bv2": ("b", WaveshareEPaper4P2InBV2),
|
"4.20in-bv2": ("b", WaveshareEPaper4P2InBV2),
|
||||||
"5.83in": ("b", WaveshareEPaper5P8In),
|
"5.83in": ("b", WaveshareEPaper5P8In),
|
||||||
|
|
|
@ -83,6 +83,33 @@ static const uint8_t PARTIAL_UPDATE_LUT_TTGO_B1[LUT_SIZE_TTGO_B1] = {
|
||||||
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
// Disable formatting to preserve the same look as in Waveshare examples
|
||||||
|
static const uint8_t PARTIAL_UPD_2IN9_LUT_SIZE = 159;
|
||||||
|
static const uint8_t PARTIAL_UPD_2IN9_LUT[PARTIAL_UPD_2IN9_LUT_SIZE] =
|
||||||
|
{
|
||||||
|
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00,
|
||||||
|
0x22, 0x17, 0x41, 0xB0, 0x32, 0x36,
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
void WaveshareEPaperBase::setup_pins_() {
|
void WaveshareEPaperBase::setup_pins_() {
|
||||||
this->init_internal_(this->get_buffer_length_());
|
this->init_internal_(this->get_buffer_length_());
|
||||||
this->dc_pin_->setup(); // OUTPUT
|
this->dc_pin_->setup(); // OUTPUT
|
||||||
|
@ -1118,6 +1145,192 @@ void WaveshareEPaper2P9InBV3::dump_config() {
|
||||||
LOG_UPDATE_INTERVAL(this);
|
LOG_UPDATE_INTERVAL(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ========================================================
|
||||||
|
// 2.90in v2 rev2
|
||||||
|
// based on SDK and examples in ZIP file from:
|
||||||
|
// https://www.waveshare.com/pico-epaper-2.9.htm
|
||||||
|
// ========================================================
|
||||||
|
|
||||||
|
void WaveshareEPaper2P9InV2R2::initialize() {
|
||||||
|
this->reset_();
|
||||||
|
this->wait_until_idle_();
|
||||||
|
|
||||||
|
this->command(0x12); // SWRESET
|
||||||
|
this->wait_until_idle_();
|
||||||
|
|
||||||
|
this->command(0x01);
|
||||||
|
this->data(0x27);
|
||||||
|
this->data(0x01);
|
||||||
|
this->data(0x00);
|
||||||
|
|
||||||
|
this->command(0x11);
|
||||||
|
this->data(0x03);
|
||||||
|
|
||||||
|
// SetWindows(0, 0, w, h)
|
||||||
|
this->command(0x44);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(((this->get_width_controller() - 1) >> 3) & 0xFF);
|
||||||
|
|
||||||
|
this->command(0x45);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data((this->get_height_internal() - 1) & 0xFF);
|
||||||
|
this->data(((this->get_height_internal() - 1) >> 8) & 0xFF);
|
||||||
|
|
||||||
|
this->command(0x21);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x80);
|
||||||
|
|
||||||
|
// SetCursor(0, 0)
|
||||||
|
this->command(0x4E);
|
||||||
|
this->data(0x00);
|
||||||
|
this->command(0x4f);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x00);
|
||||||
|
|
||||||
|
this->wait_until_idle_();
|
||||||
|
}
|
||||||
|
|
||||||
|
WaveshareEPaper2P9InV2R2::WaveshareEPaper2P9InV2R2() { this->reset_duration_ = 10; }
|
||||||
|
|
||||||
|
void WaveshareEPaper2P9InV2R2::reset_() {
|
||||||
|
if (this->reset_pin_ != nullptr) {
|
||||||
|
this->reset_pin_->digital_write(false);
|
||||||
|
delay(reset_duration_); // NOLINT
|
||||||
|
this->reset_pin_->digital_write(true);
|
||||||
|
delay(reset_duration_); // NOLINT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaveshareEPaper2P9InV2R2::display() {
|
||||||
|
if (!this->wait_until_idle_()) {
|
||||||
|
this->status_set_warning();
|
||||||
|
ESP_LOGE(TAG, "fail idle 1");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->full_update_every_ == 1) {
|
||||||
|
// do single full update
|
||||||
|
this->command(0x24);
|
||||||
|
this->start_data_();
|
||||||
|
this->write_array(this->buffer_, this->get_buffer_length_());
|
||||||
|
this->end_data_();
|
||||||
|
|
||||||
|
// TurnOnDisplay
|
||||||
|
this->command(0x22);
|
||||||
|
this->data(0xF7);
|
||||||
|
this->command(0x20);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (this->full_update_every_ == 1 ||
|
||||||
|
if (this->at_update_ == 0) {
|
||||||
|
// do base update
|
||||||
|
this->command(0x24);
|
||||||
|
this->start_data_();
|
||||||
|
this->write_array(this->buffer_, this->get_buffer_length_());
|
||||||
|
this->end_data_();
|
||||||
|
|
||||||
|
this->command(0x26);
|
||||||
|
this->start_data_();
|
||||||
|
this->write_array(this->buffer_, this->get_buffer_length_());
|
||||||
|
this->end_data_();
|
||||||
|
|
||||||
|
// TurnOnDisplay
|
||||||
|
this->command(0x22);
|
||||||
|
this->data(0xF7);
|
||||||
|
this->command(0x20);
|
||||||
|
} else {
|
||||||
|
// do partial update
|
||||||
|
this->reset_();
|
||||||
|
|
||||||
|
this->write_lut_(PARTIAL_UPD_2IN9_LUT, PARTIAL_UPD_2IN9_LUT_SIZE);
|
||||||
|
|
||||||
|
this->command(0x37);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x40);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x00);
|
||||||
|
|
||||||
|
this->command(0x3C);
|
||||||
|
this->data(0x80);
|
||||||
|
|
||||||
|
this->command(0x22);
|
||||||
|
this->data(0xC0);
|
||||||
|
this->command(0x20);
|
||||||
|
|
||||||
|
if (!this->wait_until_idle_()) {
|
||||||
|
ESP_LOGE(TAG, "fail idle 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetWindows(0, 0, w, h)
|
||||||
|
this->command(0x44);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(((this->get_width_controller() - 1) >> 3) & 0xFF);
|
||||||
|
|
||||||
|
this->command(0x45);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data((this->get_height_internal() - 1) & 0xFF);
|
||||||
|
this->data(((this->get_height_internal() - 1) >> 8) & 0xFF);
|
||||||
|
|
||||||
|
// SetCursor(0, 0)
|
||||||
|
this->command(0x4E);
|
||||||
|
this->data(0x00);
|
||||||
|
this->command(0x4f);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x00);
|
||||||
|
|
||||||
|
// write b/w
|
||||||
|
this->command(0x24);
|
||||||
|
this->start_data_();
|
||||||
|
this->write_array(this->buffer_, this->get_buffer_length_());
|
||||||
|
this->end_data_();
|
||||||
|
|
||||||
|
// TurnOnDisplayPartial
|
||||||
|
this->command(0x22);
|
||||||
|
this->data(0x0F);
|
||||||
|
this->command(0x20);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->at_update_ = (this->at_update_ + 1) % this->full_update_every_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaveshareEPaper2P9InV2R2::write_lut_(const uint8_t *lut, const uint8_t size) {
|
||||||
|
// COMMAND WRITE LUT REGISTER
|
||||||
|
this->command(0x32);
|
||||||
|
for (uint8_t i = 0; i < size; i++)
|
||||||
|
this->data(lut[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaveshareEPaper2P9InV2R2::dump_config() {
|
||||||
|
LOG_DISPLAY("", "Waveshare E-Paper", this);
|
||||||
|
ESP_LOGCONFIG(TAG, " Model: 2.9inV2R2");
|
||||||
|
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 WaveshareEPaper2P9InV2R2::deep_sleep() {
|
||||||
|
this->command(0x10);
|
||||||
|
this->data(0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
int WaveshareEPaper2P9InV2R2::get_width_internal() { return 128; }
|
||||||
|
int WaveshareEPaper2P9InV2R2::get_height_internal() { return 296; }
|
||||||
|
int WaveshareEPaper2P9InV2R2::get_width_controller() { return this->get_width_internal(); }
|
||||||
|
void WaveshareEPaper2P9InV2R2::set_full_update_every(uint32_t full_update_every) {
|
||||||
|
this->full_update_every_ = full_update_every;
|
||||||
|
}
|
||||||
|
|
||||||
// ========================================================
|
// ========================================================
|
||||||
// Good Display 2.9in black/white/grey
|
// Good Display 2.9in black/white/grey
|
||||||
// Datasheet:
|
// Datasheet:
|
||||||
|
|
|
@ -337,6 +337,36 @@ class WaveshareEPaper2P9InBV3 : public WaveshareEPaper {
|
||||||
int get_height_internal() override;
|
int get_height_internal() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class WaveshareEPaper2P9InV2R2 : public WaveshareEPaper {
|
||||||
|
public:
|
||||||
|
WaveshareEPaper2P9InV2R2();
|
||||||
|
|
||||||
|
void initialize() override;
|
||||||
|
|
||||||
|
void display() override;
|
||||||
|
|
||||||
|
void dump_config() override;
|
||||||
|
|
||||||
|
void deep_sleep() override;
|
||||||
|
|
||||||
|
void set_full_update_every(uint32_t full_update_every);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void write_lut_(const uint8_t *lut, uint8_t size);
|
||||||
|
|
||||||
|
int get_width_internal() override;
|
||||||
|
|
||||||
|
int get_height_internal() override;
|
||||||
|
|
||||||
|
int get_width_controller() override;
|
||||||
|
|
||||||
|
uint32_t full_update_every_{30};
|
||||||
|
uint32_t at_update_{0};
|
||||||
|
|
||||||
|
private:
|
||||||
|
void reset_();
|
||||||
|
};
|
||||||
|
|
||||||
class WaveshareEPaper4P2In : public WaveshareEPaper {
|
class WaveshareEPaper4P2In : public WaveshareEPaper {
|
||||||
public:
|
public:
|
||||||
void initialize() override;
|
void initialize() override;
|
||||||
|
|
Loading…
Reference in a new issue