Przeglądaj źródła

Abort the whole update cycle on a busy timeout, don't press ahead

A timed-out WAIT_BUSY previously just continued to whatever state it was
headed to (SET_WINDOW, REFRESH_CMD, ...) as if busy had cleared normally.
If busy isn't behaving - unplugged panel, dead panel, wrong polarity - the
rest of the sequence is very unlikely to do anything useful and only
obscures which step actually failed. New ABORTED state logs it and returns
straight to IDLE instead.
ZiB 1 miesiąc temu
rodzic
commit
05a869051b
1 zmienionych plików z 18 dodań i 1 usunięć
  1. 18 1
      components/gxepd2/cycle_engine.h

+ 18 - 1
components/gxepd2/cycle_engine.h

@@ -137,6 +137,20 @@ class CycleEngine {
         ESP_LOGD("gxepd2", "Display update finished");
         this->set_state_(State::IDLE);
         return;
+
+      case State::ABORTED:
+        // A busy timeout means the panel isn't behaving as wired/expected
+        // (unplugged, dead, wrong busy polarity, ...) - pressing ahead
+        // with the rest of the sequence (more command bytes, another
+        // busy-wait) is very unlikely to "just work" and only obscures
+        // which step actually failed. Bail the whole cycle here instead of
+        // continuing to whatever state the timed-out wait was headed to.
+        ESP_LOGE("gxepd2", "Aborting display update: busy timeout");
+        this->cursor_ = 0;
+        this->plane_ = 0;
+        this->cmd_phase_ = CmdPhase::BEFORE_DELAY;
+        this->set_state_(State::IDLE);
+        return;
     }
   }
 
@@ -155,6 +169,7 @@ class CycleEngine {
     POST_DELAY,
     WAIT_BUSY,
     DONE,
+    ABORTED,
   };
   enum class CmdPhase { BEFORE_DELAY, ISSUE };
 
@@ -295,7 +310,7 @@ class CycleEngine {
     }
     if (millis() >= this->busy_wait_deadline_) {
       ESP_LOGW("gxepd2", "Busy timeout waiting for panel");
-      this->set_state_(this->busy_wait_next_);
+      this->set_state_(State::ABORTED);
     }
   }
 
@@ -338,6 +353,8 @@ class CycleEngine {
         return "WAIT_BUSY";
       case State::DONE:
         return "DONE";
+      case State::ABORTED:
+        return "ABORTED";
     }
     return "?";
   }