mirror of
https://github.com/esphome/esphome.git
synced 2024-11-06 09:25:37 +01:00
Fix Waveshare 7.5v2 epaper screens are always powered on (#5283)
This commit is contained in:
parent
b3ca71c6fb
commit
ec20778d83
@ -1561,6 +1561,23 @@ void WaveshareEPaper7P5In::dump_config() {
|
||||
LOG_PIN(" Busy Pin: ", this->busy_pin_);
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
bool WaveshareEPaper7P5InV2::wait_until_idle_() {
|
||||
if (this->busy_pin_ == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const uint32_t start = millis();
|
||||
while (this->busy_pin_->digital_read()) {
|
||||
this->command(0x71);
|
||||
if (millis() - start > this->idle_timeout_()) {
|
||||
ESP_LOGE(TAG, "Timeout while displaying image!");
|
||||
return false;
|
||||
}
|
||||
App.feed_wdt();
|
||||
delay(10);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void WaveshareEPaper7P5InV2::initialize() {
|
||||
// COMMAND POWER SETTING
|
||||
this->command(0x01);
|
||||
@ -1568,10 +1585,21 @@ void WaveshareEPaper7P5InV2::initialize() {
|
||||
this->data(0x07);
|
||||
this->data(0x3f);
|
||||
this->data(0x3f);
|
||||
this->command(0x04);
|
||||
|
||||
// We don't want the display to be powered at this point
|
||||
|
||||
delay(100); // NOLINT
|
||||
this->wait_until_idle_();
|
||||
|
||||
// COMMAND VCOM AND DATA INTERVAL SETTING
|
||||
this->command(0x50);
|
||||
this->data(0x10);
|
||||
this->data(0x07);
|
||||
|
||||
// COMMAND TCON SETTING
|
||||
this->command(0x60);
|
||||
this->data(0x22);
|
||||
|
||||
// COMMAND PANEL SETTING
|
||||
this->command(0x00);
|
||||
this->data(0x1F);
|
||||
@ -1582,19 +1610,30 @@ void WaveshareEPaper7P5InV2::initialize() {
|
||||
this->data(0x20);
|
||||
this->data(0x01);
|
||||
this->data(0xE0);
|
||||
// COMMAND ...?
|
||||
|
||||
// COMMAND DUAL SPI MM_EN, DUSPI_EN
|
||||
this->command(0x15);
|
||||
this->data(0x00);
|
||||
// COMMAND VCOM AND DATA INTERVAL SETTING
|
||||
this->command(0x50);
|
||||
this->data(0x10);
|
||||
this->data(0x07);
|
||||
// COMMAND TCON SETTING
|
||||
this->command(0x60);
|
||||
this->data(0x22);
|
||||
|
||||
// COMMAND POWER DRIVER HAT DOWN
|
||||
// This command will turn off booster, controller, source driver, gate driver, VCOM, and
|
||||
// temperature sensor, but register data will be kept until VDD turned OFF or Deep Sleep Mode.
|
||||
// Source/Gate/Border/VCOM will be released to floating.
|
||||
this->command(0x02);
|
||||
}
|
||||
void HOT WaveshareEPaper7P5InV2::display() {
|
||||
uint32_t buf_len = this->get_buffer_length_();
|
||||
|
||||
// COMMAND POWER ON
|
||||
ESP_LOGI(TAG, "Power on the display and hat");
|
||||
|
||||
// This command will turn on booster, controller, regulators, and temperature sensor will be
|
||||
// activated for one-time sensing before enabling booster. When all voltages are ready, the
|
||||
// BUSY_N signal will return to high.
|
||||
this->command(0x04);
|
||||
delay(200); // NOLINT
|
||||
this->wait_until_idle_();
|
||||
|
||||
// COMMAND DATA START TRANSMISSION NEW DATA
|
||||
this->command(0x13);
|
||||
delay(2);
|
||||
@ -1602,14 +1641,23 @@ void HOT WaveshareEPaper7P5InV2::display() {
|
||||
this->data(~(this->buffer_[i]));
|
||||
}
|
||||
|
||||
delay(100); // NOLINT
|
||||
this->wait_until_idle_();
|
||||
|
||||
// COMMAND DISPLAY REFRESH
|
||||
this->command(0x12);
|
||||
delay(100); // NOLINT
|
||||
this->wait_until_idle_();
|
||||
|
||||
ESP_LOGV(TAG, "Before command(0x02) (>> power off)");
|
||||
this->command(0x02);
|
||||
this->wait_until_idle_();
|
||||
ESP_LOGV(TAG, "After command(0x02) (>> power off)");
|
||||
}
|
||||
|
||||
int WaveshareEPaper7P5InV2::get_width_internal() { return 800; }
|
||||
int WaveshareEPaper7P5InV2::get_height_internal() { return 480; }
|
||||
uint32_t WaveshareEPaper7P5InV2::idle_timeout_() { return 10000; }
|
||||
void WaveshareEPaper7P5InV2::dump_config() {
|
||||
LOG_DISPLAY("", "Waveshare E-Paper", this);
|
||||
ESP_LOGCONFIG(TAG, " Model: 7.5inV2rev2");
|
||||
|
@ -472,6 +472,8 @@ class WaveshareEPaper7P5InBC : public WaveshareEPaper {
|
||||
|
||||
class WaveshareEPaper7P5InV2 : public WaveshareEPaper {
|
||||
public:
|
||||
bool wait_until_idle_();
|
||||
|
||||
void initialize() override;
|
||||
|
||||
void display() override;
|
||||
@ -491,6 +493,8 @@ class WaveshareEPaper7P5InV2 : public WaveshareEPaper {
|
||||
int get_width_internal() override;
|
||||
|
||||
int get_height_internal() override;
|
||||
|
||||
uint32_t idle_timeout_() override;
|
||||
};
|
||||
|
||||
class WaveshareEPaper7P5InV2alt : public WaveshareEPaper7P5InV2 {
|
||||
|
Loading…
Reference in New Issue
Block a user