ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
epaper_waveshare.cpp
Go to the documentation of this file.
1#include "epaper_waveshare.h"
2
3namespace esphome::epaper_spi {
4
5ESPHOME_LOG_TAG(TAG, "epaper_spi.waveshare");
6
7bool EpaperWaveshare::initialise(bool partial) {
9 if (partial) {
10 this->cmd_data(0x32, this->partial_lut_, this->partial_lut_length_);
12 this->cmd_data(0x3C, {0x80});
13 this->cmd_data(0x22, {0xC0});
14 this->command(0x20);
15 this->next_delay_ = 100;
16 } else {
17 this->cmd_data(0x32, this->lut_, this->lut_length_);
19 this->cmd_data(0x3C, {0x05});
20 }
21 // The previous image must stay in the base RAM for partial updates to compare against,
22 // so models needing it write the base RAM on full updates only.
23 this->send_red_ = !(this->base_image_required_ && partial);
24 return true;
25}
26
28 this->x_low_ &= ~7;
29 this->x_high_ += 7;
30 this->x_high_ &= ~7;
31 uint16_t x_start = this->x_low_ / 8;
32 uint16_t x_end = (this->x_high_ - 1) / 8;
33 this->cmd_data(0x44, {(uint8_t) x_start, (uint8_t) (x_end)});
34 this->cmd_data(0x4E, {(uint8_t) x_start});
35 this->cmd_data(0x45, {(uint8_t) this->y_low_, (uint8_t) (this->y_low_ / 256), (uint8_t) (this->y_high_ - 1),
36 (uint8_t) ((this->y_high_ - 1) / 256)});
37 this->cmd_data(0x4F, {(uint8_t) this->y_low_, (uint8_t) (this->y_low_ / 256)});
38 ESP_LOGV(TAG, "Set window X: %u-%u, Y: %u-%u", this->x_low_, this->x_high_, this->y_low_, this->y_high_);
39}
40
42 if (partial) {
43 this->cmd_data(0x22, {0x0F});
44 } else {
45 this->cmd_data(0x22, {0xC7});
46 }
47 this->command(0x20);
48 this->next_delay_ = partial ? 100 : 3000;
49}
50
51void EpaperWaveshare::deep_sleep() { this->cmd_data(0x10, {0x01}); }
52
54 // Skip the software reset (0x12) EPaperMono adds: it restarts the alternation between the two RAM
55 // banks, so a partial update would compare against the wrong bank. The RST pulse only wakes the
56 // controller from sleep.
57 if (this->must_keep_base_image_())
58 return this->hardware_reset_();
59 return EPaperMono::reset();
60}
61} // namespace esphome::epaper_spi
void command(uint8_t value)
virtual bool initialise(bool partial)
void send_init_sequence_(const uint8_t *sequence, size_t length)
void cmd_data(uint8_t command, const uint8_t *ptr, size_t length)
bool hardware_reset_()
The reset pin part of reset(), for a driver that must skip what its parent adds to it.
bool initialise(bool partial) override
void refresh_screen(bool partial) override
static void int x_start
Definition display.cpp:62
ESPHOME_LOG_TAG(TAG, "display")