From ea3f7dd67fbec2af8c6692b9852d8609288a85cc Mon Sep 17 00:00:00 2001 From: ainyan03 <205502311+ainyan03@users.noreply.github.com> Date: Thu, 15 Oct 2026 09:06:25 +0000 Subject: [PATCH] ED2208: end the BUSY wait at the first high _wait_busy() treated BUSY as released only after it stayed high for 200 ms, assuming a short high between the steps of the AUTO sequence, and right after a refresh started it required the 200 ms even when BUSY was already high. Recording BUSY and CS edges with GPIO interrupts on a PaperColor showed BUSY goes low while the last byte of AUTO is being received and stays low for the whole sequence (POWER_ON, DISPLAY_REFRESH, POWER_OFF) with no short high, also on the first refresh after power-on and with 6-color and dithered images. The confirmation only delayed every wait by 200 ms (display() took about 1.33 s instead of 1.12 s). The wait now ends when displayBusy() turns false, which also covers boards without a BUSY pin. Without a reset pin the next refresh is started within about 1 ms of BUSY going high; three consecutive refreshes completed that way. --- src/lgfx/v1/panel/Panel_ED2208.inl | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/lgfx/v1/panel/Panel_ED2208.inl b/src/lgfx/v1/panel/Panel_ED2208.inl index 31624d5a..41466e4b 100644 --- a/src/lgfx/v1/panel/Panel_ED2208.inl +++ b/src/lgfx/v1/panel/Panel_ED2208.inl @@ -275,37 +275,19 @@ namespace lgfx _bus->writeData(data, 8); } - // Waits up to `timeout` ms for the controller to be idle. BUSY counts as released only - // after it has stayed high for 200 ms: a short high between the steps of an AUTO - // sequence is not the end of it. + // Waits up to `timeout` ms for the controller to be idle. BUSY stays low for the whole + // AUTO sequence (no short high between its steps was seen at 0.1 ms sampling), so the + // first high ends the wait. bool Panel_ED2208::_wait_busy(uint32_t timeout) { _bus->wait(); uint32_t start_time = millis(); - if (_cfg.pin_busy < 0) - { // No BUSY pin: wait out the time a refresh may take. - while (displayBusy()) - { - if (millis() - start_time >= timeout) { return false; } - lgfx::delay(10); - } - return true; - } - // Right after this instance started a refresh, a high BUSY at the entry may also be - // such a short high, so it needs the 200 ms as well. - bool confirm = _refresh_started && (millis() - _refresh_ms < REFRESH_TIMEOUT_MS); - if (!confirm && gpio_in(_cfg.pin_busy)) { return true; } - uint32_t high_since = 0; - bool high = false; - for (;;) + while (displayBusy()) { - uint32_t now = millis(); - if (!gpio_in(_cfg.pin_busy)) { high = false; } - else if (!high) { high = true; high_since = now; } - else if (now - high_since >= 200) { return true; } - if (now - start_time >= timeout) { return false; } + if (millis() - start_time >= timeout) { return false; } lgfx::delay(10); } + return true; } void Panel_ED2208::_init_sequence(void)