[waveshare_epaper] Add support for 2.66in-b

This commit is contained in:
Friso Brugmans 2024-11-13 22:10:50 +01:00
parent c7c8711c9c
commit 2359376f76
3 changed files with 109 additions and 1 deletions

View file

@ -27,6 +27,9 @@ WaveshareEPaperBWR = waveshare_epaper_ns.class_(
WaveshareEPaperTypeA = waveshare_epaper_ns.class_(
"WaveshareEPaperTypeA", WaveshareEPaper
)
WaveshareEPaper2P66InB = waveshare_epaper_ns.class_(
"WaveshareEPaper2P66InB", WaveshareEPaper
)
WaveshareEPaper2P7In = waveshare_epaper_ns.class_(
"WaveshareEPaper2P7In", WaveshareEPaper
)
@ -114,6 +117,7 @@ MODELS = {
"2.90in": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN),
"2.90inv2": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN_V2),
"gdew029t5": ("c", GDEW029T5),
"2.66in-b": ("b", WaveshareEPaper2P66InB),
"2.70in": ("b", WaveshareEPaper2P7In),
"2.70in-b": ("b", WaveshareEPaper2P7InB),
"2.70in-bv2": ("b", WaveshareEPaper2P7InBV2),

View file

@ -808,6 +808,90 @@ void WaveshareEPaper2P7InV2::dump_config() {
LOG_UPDATE_INTERVAL(this);
}
// ========================================================
// 2.66inch_e-paper_b
// ========================================================
// Datasheet:
// - https://files.waveshare.com/upload/e/ec/2.66inch-e-paper-b-specification.pdf
// - https://github.com/waveshareteam/e-Paper/blob/master/RaspberryPi_JetsonNano/c/lib/e-Paper/EPD_2in66b.c
void WaveshareEPaper2P66InB::initialize() {
this->reset_();
this->wait_until_idle_();
// Command soft reset
this->command(0x12);
this->wait_until_idle_();
// Command data entry mode
this->command(0x11);
this->data(0x03);
// Set windows
uint32_t xend = this->get_width_controller() - 1;
uint32_t yend = this->get_height_internal() - 1;
// SET_RAM_X_ADDRESS_START_END_POSITION
this->command(0x44);
this->data(0x00);
this->data((xend >> 3) & 0x1F);
// SET_RAM_Y_ADDRESS_START_END_POSITION
this->command(0x45);
this->data(0x00);
this->data(0x00);
this->data(yend & 0xFF);
this->data((yend >> 8) & 0x01);
// Command display update control
this->command(0x21);
this->data(0x00);
this->data(0x80);
// Set cursor
// SET_RAM_X_ADDRESS_COUNTER
this->command(0x4E);
this->data(0x00);
// SET_RAM_Y_ADDRESS_COUNTER
this->command(0x4F);
this->data(0x00);
this->data(0x00);
this->wait_until_idle_();
}
void HOT WaveshareEPaper2P66InB::display() {
uint32_t buf_len_half = this->get_buffer_length_() >> 1;
// COMMAND DATA START TRANSMISSION 1 (BLACK)
this->command(0x24);
delay(2);
for (uint32_t i = 0; i < buf_len_half; i++) {
this->data(this->buffer_[i]);
}
delay(2);
// COMMAND DATA START TRANSMISSION 2 (RED)
this->command(0x26);
delay(2);
for (uint32_t i = buf_len_half; i < buf_len_half * 2u; i++) {
this->data(this->buffer_[i]);
}
delay(2);
this->command(0x20);
this->wait_until_idle_();
}
int WaveshareEPaper2P66InB::get_width_internal() { return 152; }
int WaveshareEPaper2P66InB::get_height_internal() { return 296; }
void WaveshareEPaper2P66InB::dump_config() {
LOG_DISPLAY("", "Waveshare E-Paper", this);
ESP_LOGCONFIG(TAG, " Model: 2.66in B");
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);
}
// ========================================================
// 2.7inch_e-paper_b
// ========================================================

View file

@ -155,7 +155,8 @@ class WaveshareEPaperTypeA : public WaveshareEPaper {
};
enum WaveshareEPaperTypeBModel {
WAVESHARE_EPAPER_2_7_IN = 0,
WAVESHARE_EPAPER_2_66_IN_B = 0,
WAVESHARE_EPAPER_2_7_IN,
WAVESHARE_EPAPER_2_7_IN_B,
WAVESHARE_EPAPER_2_7_IN_B_V2,
WAVESHARE_EPAPER_4_2_IN,
@ -166,6 +167,25 @@ enum WaveshareEPaperTypeBModel {
WAVESHARE_EPAPER_13_3_IN_K,
};
class WaveshareEPaper2P66InB : public WaveshareEPaperBWR {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND DEEP SLEEP
this->command(0x10);
this->data(0x01);
}
protected:
int get_width_internal() override;
int get_height_internal() override;
};
class WaveshareEPaper2P7In : public WaveshareEPaper {
public:
void initialize() override;