mirror of
https://github.com/esphome/esphome.git
synced 2024-12-23 05:54:56 +01:00
Waveshare enter deep sleep mode on shutdown (#561)
Fixes https://github.com/esphome/issues/issues/307 Only enters deep sleep mode when node turns off - not between updates because entering+exiting deep sleep takes some time (could be added later)
This commit is contained in:
parent
61ba2e0f35
commit
df0d33c3cd
2 changed files with 205 additions and 151 deletions
|
@ -8,29 +8,6 @@ namespace waveshare_epaper {
|
|||
|
||||
static const char *TAG = "waveshare_epaper";
|
||||
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_DRIVER_OUTPUT_CONTROL = 0x01;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_BOOSTER_SOFT_START_CONTROL = 0x0C;
|
||||
// static const uint8_t WAVESHARE_EPAPER_COMMAND_GATE_SCAN_START_POSITION = 0x0F;
|
||||
// static const uint8_t WAVESHARE_EPAPER_COMMAND_DEEP_SLEEP_MODE = 0x10;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_DATA_ENTRY_MODE_SETTING = 0x11;
|
||||
// static const uint8_t WAVESHARE_EPAPER_COMMAND_SW_RESET = 0x12;
|
||||
// static const uint8_t WAVESHARE_EPAPER_COMMAND_TEMPERATURE_SENSOR_CONTROL = 0x1A;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_MASTER_ACTIVATION = 0x20;
|
||||
// static const uint8_t WAVESHARE_EPAPER_COMMAND_DISPLAY_UPDATE_CONTROL_1 = 0x21;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_DISPLAY_UPDATE_CONTROL_2 = 0x22;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_WRITE_RAM = 0x24;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_WRITE_VCOM_REGISTER = 0x2C;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_WRITE_LUT_REGISTER = 0x32;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_DUMMY_LINE_PERIOD = 0x3A;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_GATE_TIME = 0x3B;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_BORDER_WAVEFORM_CONTROL = 0x3C;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_RAM_X_ADDRESS_START_END_POSITION = 0x44;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_RAM_Y_ADDRESS_START_END_POSITION = 0x45;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_RAM_X_ADDRESS_COUNTER = 0x4E;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_SET_RAM_Y_ADDRESS_COUNTER = 0x4F;
|
||||
static const uint8_t WAVESHARE_EPAPER_COMMAND_TERMINATE_FRAME_READ_WRITE = 0xFF;
|
||||
|
||||
// not in .text section since only 30 bytes
|
||||
static const uint8_t FULL_UPDATE_LUT[30] = {0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, 0x66, 0x69,
|
||||
0x69, 0x59, 0x58, 0x99, 0x99, 0x88, 0x00, 0x00, 0x00, 0x00,
|
||||
0xF8, 0xB4, 0x13, 0x51, 0x35, 0x51, 0x51, 0x19, 0x01, 0x00};
|
||||
|
@ -52,13 +29,7 @@ void WaveshareEPaper::setup_pins_() {
|
|||
}
|
||||
this->spi_setup();
|
||||
|
||||
// Reset
|
||||
if (this->reset_pin_ != nullptr) {
|
||||
this->reset_pin_->digital_write(false);
|
||||
delay(200);
|
||||
this->reset_pin_->digital_write(true);
|
||||
delay(200);
|
||||
}
|
||||
this->reset_();
|
||||
}
|
||||
float WaveshareEPaper::get_setup_priority() const { return setup_priority::PROCESSOR; }
|
||||
void WaveshareEPaper::command(uint8_t value) {
|
||||
|
@ -121,34 +92,39 @@ void WaveshareEPaper::start_data_() {
|
|||
this->enable();
|
||||
}
|
||||
void WaveshareEPaper::end_data_() { this->disable(); }
|
||||
void WaveshareEPaper::on_safe_shutdown() { this->deep_sleep(); }
|
||||
|
||||
// ========================================================
|
||||
// Type A
|
||||
// ========================================================
|
||||
|
||||
void WaveshareEPaperTypeA::setup() {
|
||||
this->setup_pins_();
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_DRIVER_OUTPUT_CONTROL);
|
||||
void WaveshareEPaperTypeA::initialize() {
|
||||
// COMMAND DRIVER OUTPUT CONTROL
|
||||
this->command(0x01);
|
||||
this->data(this->get_height_internal() - 1);
|
||||
this->data((this->get_height_internal() - 1) >> 8);
|
||||
this->data(0x00); // ? GD = 0, SM = 0, TB = 0
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_BOOSTER_SOFT_START_CONTROL); // ?
|
||||
// COMMAND BOOSTER SOFT START CONTROL
|
||||
this->command(0x0C);
|
||||
this->data(0xD7);
|
||||
this->data(0xD6);
|
||||
this->data(0x9D);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_WRITE_VCOM_REGISTER); // ?
|
||||
// COMMAND WRITE VCOM REGISTER
|
||||
this->command(0x2C);
|
||||
this->data(0xA8);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_DUMMY_LINE_PERIOD); // ?
|
||||
// COMMAND SET DUMMY LINE PERIOD
|
||||
this->command(0x3A);
|
||||
this->data(0x1A);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_GATE_TIME); // 2µs per row
|
||||
this->data(0x08);
|
||||
// COMMAND SET GATE TIME
|
||||
this->command(0x3B);
|
||||
this->data(0x08); // 2µs per row
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_DATA_ENTRY_MODE_SETTING);
|
||||
// COMMAND DATA ENTRY MODE SETTING
|
||||
this->command(0x11);
|
||||
this->data(0x03); // from top left to bottom right
|
||||
}
|
||||
void WaveshareEPaperTypeA::dump_config() {
|
||||
|
@ -186,18 +162,22 @@ void HOT WaveshareEPaperTypeA::display() {
|
|||
}
|
||||
|
||||
// Set x & y regions we want to write to (full)
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_RAM_X_ADDRESS_START_END_POSITION);
|
||||
// COMMAND SET RAM X ADDRESS START END POSITION
|
||||
this->command(0x44);
|
||||
this->data(0x00);
|
||||
this->data((this->get_width_internal() - 1) >> 3);
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_RAM_Y_ADDRESS_START_END_POSITION);
|
||||
// COMMAND SET RAM Y ADDRESS START END POSITION
|
||||
this->command(0x45);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
this->data(this->get_height_internal() - 1);
|
||||
this->data((this->get_height_internal() - 1) >> 8);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_RAM_X_ADDRESS_COUNTER);
|
||||
// COMMAND SET RAM X ADDRESS COUNTER
|
||||
this->command(0x4E);
|
||||
this->data(0x00);
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_SET_RAM_Y_ADDRESS_COUNTER);
|
||||
// COMMAND SET RAM Y ADDRESS COUNTER
|
||||
this->command(0x4F);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
|
||||
|
@ -206,15 +186,19 @@ void HOT WaveshareEPaperTypeA::display() {
|
|||
return;
|
||||
}
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_WRITE_RAM);
|
||||
// COMMAND WRITE RAM
|
||||
this->command(0x24);
|
||||
this->start_data_();
|
||||
this->write_array(this->buffer_, this->get_buffer_length_());
|
||||
this->end_data_();
|
||||
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_DISPLAY_UPDATE_CONTROL_2);
|
||||
// COMMAND DISPLAY UPDATE CONTROL 2
|
||||
this->command(0x22);
|
||||
this->data(0xC4);
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_MASTER_ACTIVATION);
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_TERMINATE_FRAME_READ_WRITE);
|
||||
// COMMAND MASTER ACTIVATION
|
||||
this->command(0x20);
|
||||
// COMMAND TERMINATE FRAME READ WRITE
|
||||
this->command(0xFF);
|
||||
|
||||
this->status_clear_warning();
|
||||
}
|
||||
|
@ -241,7 +225,8 @@ int WaveshareEPaperTypeA::get_height_internal() {
|
|||
return 0;
|
||||
}
|
||||
void WaveshareEPaperTypeA::write_lut_(const uint8_t *lut) {
|
||||
this->command(WAVESHARE_EPAPER_COMMAND_WRITE_LUT_REGISTER);
|
||||
// COMMAND WRITE LUT REGISTER
|
||||
this->command(0x32);
|
||||
for (uint8_t i = 0; i < 30; i++)
|
||||
this->data(lut[i]);
|
||||
}
|
||||
|
@ -253,47 +238,9 @@ void WaveshareEPaperTypeA::set_full_update_every(uint32_t full_update_every) {
|
|||
// ========================================================
|
||||
// Type B
|
||||
// ========================================================
|
||||
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PANEL_SETTING = 0x00;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_SETTING = 0x01;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_OFF = 0x02;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_OFF_SEQUENCE_SETTING = 0x03;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_ON = 0x04;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_MEASURE = 0x05;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_BOOSTER_SOFT_START = 0x06;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_DEEP_SLEEP = 0x07;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_1 = 0x10;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_DATA_STOP = 0x11;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_DISPLAY_REFRESH = 0x12;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_2 = 0x13;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_DATA_START_TRANSMISSION_1 = 0x14;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_DATA_START_TRANSMISSION_2 = 0x15;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_DISPLAY_REFRESH = 0x16;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LUT_FOR_VCOM = 0x20;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_WHITE = 0x21;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_WHITE = 0x22;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_BLACK = 0x23;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_BLACK = 0x24;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PLL_CONTROL = 0x30;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_TEMPERATURE_SENSOR_COMMAND = 0x40;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_TEMPERATURE_SENSOR_CALIBRATION = 0x41;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_TEMPERATURE_SENSOR_WRITE = 0x42;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_TEMPERATURE_SENSOR_READ = 0x43;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_VCOM_AND_DATA_INTERVAL_SETTING = 0x50;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_LOW_POWER_DETECTION = 0x51;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_TCON_SETTING = 0x60;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_RESOLUTION_SETTING = 0x61;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_GET_STATUS = 0x71;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_AUTO_MEASURE_VCOM = 0x80;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_VCOM_VALUE = 0x81;
|
||||
static const uint8_t WAVESHARE_EPAPER_B_COMMAND_VCM_DC_SETTING_REGISTER = 0x82;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_WINDOW = 0x90;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_IN = 0x91;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PARTIAL_OUT = 0x92;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_PROGRAM_MODE = 0xA0;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_ACTIVE_PROGRAM = 0xA1;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_READ_OTP_DATA = 0xA2;
|
||||
// static const uint8_t WAVESHARE_EPAPER_B_COMMAND_POWER_SAVING = 0xE3;
|
||||
// Datasheet:
|
||||
// - https://www.waveshare.com/w/upload/7/7f/4.2inch-e-paper-b-specification.pdf
|
||||
// - https://github.com/soonuse/epd-library-arduino/blob/master/4.2inch_e-paper/epd4in2/
|
||||
|
||||
static const uint8_t LUT_VCOM_DC_2_7[44] = {
|
||||
0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x00, 0x32, 0x32, 0x00, 0x00, 0x02, 0x00,
|
||||
|
@ -325,18 +272,17 @@ static const uint8_t LUT_BLACK_TO_BLACK_2_7[42] = {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
void WaveshareEPaper2P7In::setup() {
|
||||
this->setup_pins_();
|
||||
// this->buffer_.init(this->get_width_(), this->get_height_());
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_SETTING);
|
||||
void WaveshareEPaper2P7In::initialize() {
|
||||
// command power setting
|
||||
this->command(0x01);
|
||||
this->data(0x03); // VDS_EN, VDG_EN
|
||||
this->data(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
|
||||
this->data(0x2B); // VDH
|
||||
this->data(0x2B); // VDL
|
||||
this->data(0x09); // VDHR
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_BOOSTER_SOFT_START);
|
||||
// command booster soft start
|
||||
this->command(0x06);
|
||||
this->data(0x07);
|
||||
this->data(0x07);
|
||||
this->data(0x17);
|
||||
|
@ -364,51 +310,66 @@ void WaveshareEPaper2P7In::setup() {
|
|||
this->data(0x73);
|
||||
this->data(0x41);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PARTIAL_DISPLAY_REFRESH);
|
||||
// command partial display refresh
|
||||
this->command(0x16);
|
||||
this->data(0x00);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_ON);
|
||||
// command power on
|
||||
this->command(0x04);
|
||||
this->wait_until_idle_();
|
||||
delay(10);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PANEL_SETTING);
|
||||
// Command panel setting
|
||||
this->command(0x00);
|
||||
this->data(0xAF); // KW-BF KWR-AF BWROTP 0f
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PLL_CONTROL);
|
||||
// command pll control
|
||||
this->command(0x30);
|
||||
this->data(0x3A); // 3A 100HZ 29 150Hz 39 200HZ 31 171HZ
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_VCM_DC_SETTING_REGISTER);
|
||||
// COMMAND VCM DC SETTING
|
||||
this->command(0x82);
|
||||
this->data(0x12);
|
||||
|
||||
delay(2);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_FOR_VCOM);
|
||||
// COMMAND LUT FOR VCOM
|
||||
this->command(0x20);
|
||||
for (uint8_t i : LUT_VCOM_DC_2_7)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_WHITE);
|
||||
|
||||
// COMMAND LUT WHITE TO WHITE
|
||||
this->command(0x21);
|
||||
for (uint8_t i : LUT_WHITE_TO_WHITE_2_7)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_WHITE);
|
||||
// COMMAND LUT BLACK TO WHITE
|
||||
this->command(0x22);
|
||||
for (uint8_t i : LUT_BLACK_TO_WHITE_2_7)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_BLACK);
|
||||
// COMMAND LUT WHITE TO BLACK
|
||||
this->command(0x23);
|
||||
for (uint8_t i : LUT_WHITE_TO_BLACK_2_7)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_BLACK);
|
||||
// COMMAND LUT BLACK TO BLACK
|
||||
this->command(0x24);
|
||||
for (uint8_t i : LUT_BLACK_TO_BLACK_2_7)
|
||||
this->data(i);
|
||||
}
|
||||
void HOT WaveshareEPaper2P7In::display() {
|
||||
// TODO check active frame buffer to only transmit once / use partial transmits
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_1);
|
||||
// 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);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_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_();
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DISPLAY_REFRESH);
|
||||
|
||||
// COMMAND DISPLAY REFRESH
|
||||
this->command(0x12);
|
||||
}
|
||||
int WaveshareEPaper2P7In::get_width_internal() { return 176; }
|
||||
int WaveshareEPaper2P7In::get_height_internal() { return 264; }
|
||||
|
@ -449,73 +410,88 @@ static const uint8_t LUT_WHITE_TO_BLACK_4_2[] = {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
void WaveshareEPaper4P2In::setup() {
|
||||
this->setup_pins_();
|
||||
void WaveshareEPaper4P2In::initialize() {
|
||||
// https://www.waveshare.com/w/upload/7/7f/4.2inch-e-paper-b-specification.pdf - page 8
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_SETTING);
|
||||
// COMMAND POWER SETTING
|
||||
this->command(0x01);
|
||||
this->data(0x03); // VDS_EN, VDG_EN
|
||||
this->data(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
|
||||
this->data(0x2B); // VDH
|
||||
this->data(0x2B); // VDL
|
||||
this->data(0xFF); // VDHR
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_BOOSTER_SOFT_START);
|
||||
this->data(0x17);
|
||||
this->data(0x17);
|
||||
this->data(0x17);
|
||||
// COMMAND BOOSTER SOFT START
|
||||
this->command(0x06);
|
||||
this->data(0x17); // PHA
|
||||
this->data(0x17); // PHB
|
||||
this->data(0x17); // PHC
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_ON);
|
||||
// COMMAND POWER ON
|
||||
this->command(0x04);
|
||||
this->wait_until_idle_();
|
||||
delay(10);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PANEL_SETTING);
|
||||
// COMMAND PANEL SETTING
|
||||
this->command(0x00);
|
||||
this->data(0xBF); // KW-BF KWR-AF BWROTP 0f
|
||||
this->data(0x0B);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PLL_CONTROL);
|
||||
// COMMAND PLL CONTROL
|
||||
this->command(0x30);
|
||||
this->data(0x3C); // 3A 100HZ 29 150Hz 39 200HZ 31 171HZ
|
||||
|
||||
delay(2);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_FOR_VCOM);
|
||||
// COMMAND LUT FOR VCOM
|
||||
this->command(0x20);
|
||||
for (uint8_t i : LUT_VCOM_DC_4_2)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_WHITE);
|
||||
// COMMAND LUT WHITE TO WHITE
|
||||
this->command(0x21);
|
||||
for (uint8_t i : LUT_WHITE_TO_WHITE_4_2)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_WHITE);
|
||||
// COMMAND LUT BLACK TO WHITE
|
||||
this->command(0x22);
|
||||
for (uint8_t i : LUT_BLACK_TO_WHITE_4_2)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_WHITE_TO_BLACK);
|
||||
// COMMAND LUT WHITE TO BLACK
|
||||
this->command(0x23);
|
||||
for (uint8_t i : LUT_WHITE_TO_BLACK_4_2)
|
||||
this->data(i);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_LUT_BLACK_TO_BLACK);
|
||||
// COMMAND LUT BLACK TO BLACK
|
||||
this->command(0x24);
|
||||
for (uint8_t i : LUT_BLACK_TO_BLACK_4_2)
|
||||
this->data(i);
|
||||
}
|
||||
void HOT WaveshareEPaper4P2In::display() {
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_RESOLUTION_SETTING);
|
||||
// COMMAND RESOLUTION SETTING
|
||||
this->command(0x61);
|
||||
this->data(0x01);
|
||||
this->data(0x90);
|
||||
this->data(0x01);
|
||||
this->data(0x2C);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_VCM_DC_SETTING_REGISTER);
|
||||
// COMMAND VCM DC SETTING REGISTER
|
||||
this->command(0x82);
|
||||
this->data(0x12);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_VCOM_AND_DATA_INTERVAL_SETTING);
|
||||
// COMMAND VCOM AND DATA INTERVAL SETTING
|
||||
this->command(0x50);
|
||||
this->data(0x97);
|
||||
|
||||
// TODO check active frame buffer to only transmit once / use partial transmits
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_1);
|
||||
// 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);
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_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_();
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DISPLAY_REFRESH);
|
||||
// COMMAND DISPLAY REFRESH
|
||||
this->command(0x12);
|
||||
}
|
||||
int WaveshareEPaper4P2In::get_width_internal() { return 400; }
|
||||
int WaveshareEPaper4P2In::get_height_internal() { return 300; }
|
||||
|
@ -529,52 +505,61 @@ void WaveshareEPaper4P2In::dump_config() {
|
|||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
|
||||
void WaveshareEPaper7P5In::setup() {
|
||||
this->setup_pins_();
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_SETTING);
|
||||
void WaveshareEPaper7P5In::initialize() {
|
||||
// COMMAND POWER SETTING
|
||||
this->command(0x01);
|
||||
this->data(0x37);
|
||||
this->data(0x00);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PANEL_SETTING);
|
||||
// COMMAND PANEL SETTING
|
||||
this->command(0x00);
|
||||
this->data(0xCF);
|
||||
this->data(0x0B);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_BOOSTER_SOFT_START);
|
||||
// COMMAND BOOSTER SOFT START
|
||||
this->command(0x06);
|
||||
this->data(0xC7);
|
||||
this->data(0xCC);
|
||||
this->data(0x28);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_POWER_ON);
|
||||
// COMMAND POWER ON
|
||||
this->command(0x04);
|
||||
this->wait_until_idle_();
|
||||
delay(10);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_PLL_CONTROL);
|
||||
// COMMAND PLL CONTROL
|
||||
this->command(0x30);
|
||||
this->data(0x3C);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_TEMPERATURE_SENSOR_CALIBRATION);
|
||||
// COMMAND TEMPERATURE SENSOR CALIBRATION
|
||||
this->command(0x41);
|
||||
this->data(0x00);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_VCOM_AND_DATA_INTERVAL_SETTING);
|
||||
// COMMAND VCOM AND DATA INTERVAL SETTING
|
||||
this->command(0x50);
|
||||
this->data(0x77);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_TCON_SETTING);
|
||||
// COMMAND TCON SETTING
|
||||
this->command(0x60);
|
||||
this->data(0x22);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_RESOLUTION_SETTING);
|
||||
// COMMAND RESOLUTION SETTING
|
||||
this->command(0x61);
|
||||
this->data(0x02);
|
||||
this->data(0x80);
|
||||
this->data(0x01);
|
||||
this->data(0x80);
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_VCM_DC_SETTING_REGISTER);
|
||||
// COMMAND VCM DC SETTING REGISTER
|
||||
this->command(0x82);
|
||||
this->data(0x1E);
|
||||
|
||||
this->command(0xE5);
|
||||
this->data(0x03);
|
||||
}
|
||||
void HOT WaveshareEPaper7P5In::display() {
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DATA_START_TRANSMISSION_1);
|
||||
// COMMAND DATA START TRANSMISSION 1
|
||||
this->command(0x10);
|
||||
|
||||
this->start_data_();
|
||||
for (size_t i = 0; i < this->get_buffer_length_(); i++) {
|
||||
|
@ -601,7 +586,8 @@ void HOT WaveshareEPaper7P5In::display() {
|
|||
}
|
||||
this->end_data_();
|
||||
|
||||
this->command(WAVESHARE_EPAPER_B_COMMAND_DISPLAY_REFRESH);
|
||||
// COMMAND DISPLAY REFRESH
|
||||
this->command(0x12);
|
||||
}
|
||||
int WaveshareEPaper7P5In::get_width_internal() { return 640; }
|
||||
int WaveshareEPaper7P5In::get_height_internal() { return 384; }
|
||||
|
|
|
@ -19,11 +19,20 @@ class WaveshareEPaper : public PollingComponent, public spi::SPIDevice, public d
|
|||
void data(uint8_t value);
|
||||
|
||||
virtual void display() = 0;
|
||||
virtual void initialize() = 0;
|
||||
virtual void deep_sleep() = 0;
|
||||
|
||||
void update() override;
|
||||
|
||||
void fill(int color) override;
|
||||
|
||||
void setup() override {
|
||||
this->setup_pins_();
|
||||
this->initialize();
|
||||
}
|
||||
|
||||
void on_safe_shutdown() override;
|
||||
|
||||
protected:
|
||||
void draw_absolute_pixel_internal(int x, int y, int color) override;
|
||||
|
||||
|
@ -31,6 +40,15 @@ class WaveshareEPaper : public PollingComponent, public spi::SPIDevice, public d
|
|||
|
||||
void setup_pins_();
|
||||
|
||||
void reset_() {
|
||||
if (this->reset_pin_ != nullptr) {
|
||||
this->reset_pin_->digital_write(false);
|
||||
delay(200);
|
||||
this->reset_pin_->digital_write(true);
|
||||
delay(200);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t get_buffer_length_();
|
||||
|
||||
bool is_device_high_speed() override;
|
||||
|
@ -55,12 +73,18 @@ class WaveshareEPaperTypeA : public WaveshareEPaper {
|
|||
public:
|
||||
WaveshareEPaperTypeA(WaveshareEPaperTypeAModel model);
|
||||
|
||||
void setup() override;
|
||||
void initialize() override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
void display() override;
|
||||
|
||||
void deep_sleep() override {
|
||||
// COMMAND DEEP SLEEP MODE
|
||||
this->command(0x10);
|
||||
this->wait_until_idle_();
|
||||
}
|
||||
|
||||
void set_full_update_every(uint32_t full_update_every);
|
||||
|
||||
protected:
|
||||
|
@ -83,12 +107,18 @@ enum WaveshareEPaperTypeBModel {
|
|||
|
||||
class WaveshareEPaper2P7In : public WaveshareEPaper {
|
||||
public:
|
||||
void setup() override;
|
||||
void initialize() override;
|
||||
|
||||
void display() override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
void deep_sleep() override {
|
||||
// COMMAND DEEP SLEEP
|
||||
this->command(0x07);
|
||||
this->data(0xA5); // check byte
|
||||
}
|
||||
|
||||
protected:
|
||||
int get_width_internal() override;
|
||||
|
||||
|
@ -97,12 +127,41 @@ class WaveshareEPaper2P7In : public WaveshareEPaper {
|
|||
|
||||
class WaveshareEPaper4P2In : public WaveshareEPaper {
|
||||
public:
|
||||
void setup() override;
|
||||
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);
|
||||
|
||||
// COMMAND POWER SETTING
|
||||
this->command(0x01);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
this->data(0x00);
|
||||
delay(100);
|
||||
|
||||
// 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;
|
||||
|
||||
|
@ -113,12 +172,21 @@ class WaveshareEPaper4P2In : public WaveshareEPaper {
|
|||
|
||||
class WaveshareEPaper7P5In : public WaveshareEPaper {
|
||||
public:
|
||||
void setup() override;
|
||||
void initialize() override;
|
||||
|
||||
void display() override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
void deep_sleep() override {
|
||||
// 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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue