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

Fix inverted black/white for THREE_COLOR panels; add 579c master-only debug toggle

gxepd2_display.h: THREE_COLOR's non-red fallback used color.is_on()
(raw_32 != 0), the on/off convention correct only for the BW path's
DISPLAY_TYPE_BINARY. THREE_COLOR reports DISPLAY_TYPE_COLOR, so callers
draw with literal RGB (Color(255,255,255,...) for white, Color(0,0,0,...)
for black) - is_on() saw those as background/foreground and inverted
both. Switch to a brightness check on the literal RGB value, matching
how the FOUR_COLOR/SEVEN_COLOR path already works.

GxEPD2_579c_GDEY0579F51.cpp: add a GXEPD2_579C_DEBUG_MASTER_ONLY toggle
(default 0, no behavior change) to skip the slave-side (right half)
write in writeNative() for isolating whether that panel's master/slave
split is where its partial-render bug lives. Temporary diagnostic, not
a real feature - revert once understood.

Added a throwaway test fixture for the 579c model to exercise the new
toggle.
ZiB 1 месяц назад
Родитель
Сommit
20485a43f4

+ 8 - 1
components/gxepd2/gxepd2_display.h

@@ -124,7 +124,14 @@ class GxEPD2Display : public display::DisplayBuffer {
       if (color.red > color.green && color.red > color.blue && color.red > 0x7f) {
       if (color.red > color.green && color.red > color.blue && color.red > 0x7f) {
         this->driver_->drawPixel(x, y, GxEPD_RED);
         this->driver_->drawPixel(x, y, GxEPD_RED);
       } else {
       } else {
-        this->driver_->drawPixel(x, y, color.is_on() ? GxEPD_BLACK : GxEPD_WHITE);
+        // get_display_type() reports DISPLAY_TYPE_COLOR for this mode, so
+        // callers draw with literal RGB colors (Color(255,255,255,...) for
+        // white, Color(0,0,0,...) for black) - not the on/off convention
+        // is_on() (raw_32 != 0) assumes, which is only correct for the BW
+        // path above (DISPLAY_TYPE_BINARY). Using is_on() here inverted
+        // black and white for any lambda drawing literal colors.
+        bool bright = color.red > 0x7f || color.green > 0x7f || color.blue > 0x7f;
+        this->driver_->drawPixel(x, y, bright ? GxEPD_WHITE : GxEPD_BLACK);
       }
       }
     } else {
     } else {
       uint16_t rgb565 = ((color.red & 0xF8) << 8) | ((color.green & 0xFC) << 3) | (color.blue >> 3);
       uint16_t rgb565 = ((color.red & 0xF8) << 8) | ((color.green & 0xFC) << 3) | (color.blue >> 3);

+ 7 - 1
components/gxepd2/vendor/src/epd4c/GxEPD2_579c_GDEY0579F51.cpp

@@ -436,6 +436,12 @@ void GxEPD2_579c_GDEY0579F51::_writeDataFromNative(const uint8_t* native, int16_
   _endTransfer();
   _endTransfer();
 }
 }
 
 
+// TEMPORARY DIAGNOSTIC: set to 1 to skip the slave-side (right half) write in
+// writeNative() below entirely, to isolate whether the master-only path
+// renders correctly on its own. Revert to 0 once the split-screen bug is
+// understood - this is not meant to be a real feature.
+#define GXEPD2_579C_DEBUG_MASTER_ONLY 0
+
 void GxEPD2_579c_GDEY0579F51::writeNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
 void GxEPD2_579c_GDEY0579F51::writeNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
 {
 {
   if (!data1) return;
   if (!data1) return;
@@ -506,7 +512,7 @@ void GxEPD2_579c_GDEY0579F51::writeNative(const uint8_t* data1, const uint8_t* d
       }
       }
     }
     }
   }
   }
-  if ((x1 + w1 > WIDTH / 2) && true) // SlaveSide ****
+  if ((x1 + w1 > WIDTH / 2) && true && !GXEPD2_579C_DEBUG_MASTER_ONLY) // SlaveSide ****
   {
   {
     int16_t pw_w = x1 <= WIDTH / 2 ? x1 + w1 - WIDTH / 2 : w1;
     int16_t pw_w = x1 <= WIDTH / 2 ? x1 + w1 - WIDTH / 2 : w1;
     int16_t pw_x = x1 <= WIDTH / 2 ? 0 : x1 - WIDTH / 2;
     int16_t pw_x = x1 <= WIDTH / 2 ? 0 : x1 - WIDTH / 2;

+ 25 - 0
tests/test_gxepd2_579c_master_only_debug.esp32-idf.yaml

@@ -0,0 +1,25 @@
+esphome:
+  name: gxepd2-test-579c-debug
+esp32:
+  board: esp32dev
+  framework:
+    type: esp-idf
+external_components:
+  - source:
+      type: local
+      path: ../components
+    components: [gxepd2]
+spi:
+  clk_pin: 18
+  mosi_pin: 23
+logger:
+display:
+  - platform: gxepd2
+    model: GxEPD2_579c_GDEY0579F51
+    cs_pin: 5
+    dc_pin: 17
+    reset_pin: 16
+    busy_pin: 4
+    update_interval: 60s
+    lambda: |-
+      it.fill(Color::WHITE);