ESPHome 2026.3.0-dev
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
5static const char *const 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_);
11 this->cmd_data(0x3C, {0x80});
12 this->cmd_data(0x22, {0xC0});
13 this->command(0x20);
14 this->next_delay_ = 100;
15 } else {
16 this->cmd_data(0x32, this->lut_, this->lut_length_);
17 this->cmd_data(0x3C, {0x05});
18 }
19 this->send_red_ = true;
20 return true;
21}
22
24 this->x_low_ &= ~7;
25 this->x_high_ += 7;
26 this->x_high_ &= ~7;
27 uint16_t x_start = this->x_low_ / 8;
28 uint16_t x_end = (this->x_high_ - 1) / 8;
29 this->cmd_data(0x44, {(uint8_t) x_start, (uint8_t) (x_end)});
30 this->cmd_data(0x4E, {(uint8_t) x_start});
31 this->cmd_data(0x45, {(uint8_t) this->y_low_, (uint8_t) (this->y_low_ / 256), (uint8_t) (this->y_high_ - 1),
32 (uint8_t) ((this->y_high_ - 1) / 256)});
33 this->cmd_data(0x4F, {(uint8_t) this->y_low_, (uint8_t) (this->y_low_ / 256)});
34 ESP_LOGV(TAG, "Set window X: %u-%u, Y: %u-%u", this->x_low_, this->x_high_, this->y_low_, this->y_high_);
35}
36
38 if (partial) {
39 this->cmd_data(0x22, {0x0F});
40 } else {
41 this->cmd_data(0x22, {0xC7});
42 }
43 this->command(0x20);
44 this->next_delay_ = partial ? 100 : 3000;
45}
46
47void EpaperWaveshare::deep_sleep() { this->cmd_data(0x10, {0x01}); }
48} // namespace esphome::epaper_spi
void command(uint8_t value)
virtual bool initialise(bool partial)
void cmd_data(uint8_t command, const uint8_t *ptr, size_t length)
bool initialise(bool partial) override
void refresh_screen(bool partial) override