Просмотр исходного кода

Log a byte histogram of each plane buffer before transmitting it

Skeleton trace confirmed every command/data byte and busy timing exactly
matches the intended sequence, and the panel is now confirmed good (the
epaper_spi-based epaper-nametag.yaml still renders correctly on it), so
the remaining suspect is content computed by our own draw_absolute_pixel_
internal path, not the protocol. Log a 0x00/0xFF/other count plus the
first and last byte for each plane right before sending it, to see
directly whether the fill/text lambda actually produced the expected
mostly-white content or something else. Also fixes an uninitialized-stack
read in the command logger that printed garbage for zero-data commands
(cosmetic, unrelated to the actual bug).
ZiB 1 месяц назад
Родитель
Сommit
8b14801c6b
1 измененных файлов с 18 добавлено и 4 удалено
  1. 18 4
      components/gxepd2/cycle_engine.h

+ 18 - 4
components/gxepd2/cycle_engine.h

@@ -176,7 +176,7 @@ class CycleEngine {
     // epaper_spi trace on the same panel. Bulk plane data isn't logged
     // here (see step_write_plane_) - only the command skeleton matters for
     // that comparison.
-    char buf[32];
+    char buf[32] = {0};
     int n = 0;
     for (uint8_t i = 0; i < data_len && n < (int) sizeof(buf) - 3; i++)
       n += snprintf(buf + n, sizeof(buf) - n, "%02X ", data[i]);
@@ -242,9 +242,23 @@ class CycleEngine {
 
   void step_write_plane_() {
     if (this->cursor_ == 0) {
-      ESP_LOGD("gxepd2", "plane %u: cmd 0x%02X, %u bytes, invert=%d", this->plane_,
-               this->desc_->plane_write_cmd[this->plane_], (unsigned) this->plane_bytes_,
-               this->desc_->plane_invert[this->plane_]);
+      const uint8_t *buf = this->planes_[this->plane_];
+      uint32_t histo[3] = {0, 0, 0};  // [0]=0x00, [1]=0xFF, [2]=other
+      if (buf != nullptr) {
+        for (uint32_t i = 0; i < this->plane_bytes_; i++) {
+          if (buf[i] == 0x00)
+            histo[0]++;
+          else if (buf[i] == 0xFF)
+            histo[1]++;
+          else
+            histo[2]++;
+        }
+      }
+      ESP_LOGD("gxepd2", "plane %u: cmd 0x%02X, %u bytes, invert=%d, buf[0]=0x%02X buf[last]=0x%02X, histo(00/FF/other)=%u/%u/%u",
+               this->plane_, this->desc_->plane_write_cmd[this->plane_], (unsigned) this->plane_bytes_,
+               this->desc_->plane_invert[this->plane_], buf != nullptr ? buf[0] : 0,
+               buf != nullptr ? buf[this->plane_bytes_ - 1] : 0, (unsigned) histo[0], (unsigned) histo[1],
+               (unsigned) histo[2]);
       this->write_byte_(this->desc_->plane_write_cmd[this->plane_], false);
     }
     const uint8_t *buf = this->planes_[this->plane_];