Kaynağa Gözat

Add GxEPD2_213c_GDEY0213F52 driver (128x250 JD79676 BWRY)

Based on Good Display demo A32-GDEY0213F52 (V2.0). Unlike the JD79661
F51, the JD79676 loads PSR/PWR/BTST/resolution/LUT from OTP, so init is
just reset + 0xE9=0x01 + PON. Full-refresh only for now (hasPartialUpdate
false); R83H PTLW adds a PTH_ENB bit vs F51 so the F51 windowing is not
reused unverified. Registered in GxEPD2.h, GxEPD2_4C.h, and example
selection/check headers.
ZiB 3 hafta önce
ebeveyn
işleme
d97d53e17e
27 değiştirilmiş dosya ile 1045 ekleme ve 1 silme
  1. 1 1
      examples/GxEPD2_Example/GxEPD2_Example.ino
  2. 1 0
      examples/GxEPD2_Example/GxEPD2_display_selection_new_style.h
  3. 1 0
      examples/GxEPD2_Example/GxEPD2_selection_check.h
  4. 1 0
      examples/GxEPD2_GFX_Example/GxEPD2_display_selection_new_style.h
  5. 1 0
      examples/GxEPD2_GFX_Example/GxEPD2_selection_check.h
  6. 1 0
      examples/GxEPD2_HelloWorld/GxEPD2_display_selection_new_style.h
  7. 1 0
      examples/GxEPD2_HelloWorld/GxEPD2_selection_check.h
  8. 1 0
      examples/GxEPD2_NotPagedExample/GxEPD2_display_selection_new_style.h
  9. 1 0
      examples/GxEPD2_NotPagedExample/GxEPD2_selection_check.h
  10. 1 0
      examples/GxEPD2_PagedDisplayUsingCallback/GxEPD2_display_selection_new_style.h
  11. 1 0
      examples/GxEPD2_PagedDisplayUsingCallback/GxEPD2_selection_check.h
  12. 1 0
      examples/GxEPD2_RotaryUsingBusyCallback/GxEPD2_display_selection_new_style.h
  13. 1 0
      examples/GxEPD2_RotaryUsingBusyCallback/GxEPD2_selection_check.h
  14. 1 0
      examples/GxEPD2_SD_Example/GxEPD2_display_selection_new_style.h
  15. 1 0
      examples/GxEPD2_SD_Example/GxEPD2_selection_check.h
  16. 1 0
      examples/GxEPD2_SerialFlash_Example/GxEPD2_display_selection_new_style.h
  17. 1 0
      examples/GxEPD2_SerialFlash_Example/GxEPD2_selection_check.h
  18. 1 0
      examples/GxEPD2_Spiffs_Example/GxEPD2_display_selection_new_style.h
  19. 1 0
      examples/GxEPD2_Spiffs_Example/GxEPD2_selection_check.h
  20. 1 0
      examples/GxEPD2_U8G2_Fonts_Example/GxEPD2_display_selection_new_style.h
  21. 1 0
      examples/GxEPD2_U8G2_Fonts_Example/GxEPD2_selection_check.h
  22. 1 0
      examples/GxEPD2_WiFi_CertStore_Example/GxEPD2_WiFi_CertStore_Example.ino
  23. 1 0
      examples/GxEPD2_WiFi_Example/GxEPD2_WiFi_DisplaySelection.h
  24. 1 0
      src/GxEPD2.h
  25. 3 0
      src/GxEPD2_4C.h
  26. 938 0
      src/epd4c/GxEPD2_213c_GDEY0213F52.cpp
  27. 80 0
      src/epd4c/GxEPD2_213c_GDEY0213F52.h

+ 1 - 1
examples/GxEPD2_Example/GxEPD2_Example.ino

@@ -2232,7 +2232,7 @@ void drawBitmaps4c200x200()
 #if defined(_GxBitmaps4c128x250_H_)
 void drawBitmaps4c128x250()
 {
-  if (display.epd2.panel == GxEPD2::GDEY0213F51)
+  if ((display.epd2.panel == GxEPD2::GDEY0213F51) || (display.epd2.panel == GxEPD2::GDEY0213F52))
   {
     display.drawNative(Bitmap4c128x250, 0, 0, 0, 128, 250, false, false, true);
     delay(5000);

+ 1 - 0
examples/GxEPD2_Example/GxEPD2_display_selection_new_style.h

@@ -111,6 +111,7 @@
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_154c_GDEM0154F51H // GDEM0154F51H 200x200, JD79660 (FPC-8101)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
examples/GxEPD2_Example/GxEPD2_selection_check.h

@@ -105,6 +105,7 @@
 // 4-color e-paper
 #define GxEPD2_154c_GDEM0154F51H_IS_4C true
 #define GxEPD2_213c_GDEY0213F51_IS_4C true
+#define GxEPD2_213c_GDEY0213F52_IS_4C true
 #define GxEPD2_266c_GDEY0266F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51_IS_4C true

+ 1 - 0
examples/GxEPD2_GFX_Example/GxEPD2_display_selection_new_style.h

@@ -111,6 +111,7 @@
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_154c_GDEM0154F51H // GDEM0154F51H 200x200, JD79660 (FPC-8101)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
examples/GxEPD2_GFX_Example/GxEPD2_selection_check.h

@@ -105,6 +105,7 @@
 // 4-color e-paper
 #define GxEPD2_154c_GDEM0154F51H_IS_4C true
 #define GxEPD2_213c_GDEY0213F51_IS_4C true
+#define GxEPD2_213c_GDEY0213F52_IS_4C true
 #define GxEPD2_266c_GDEY0266F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51_IS_4C true

+ 1 - 0
examples/GxEPD2_HelloWorld/GxEPD2_display_selection_new_style.h

@@ -111,6 +111,7 @@
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_154c_GDEM0154F51H // GDEM0154F51H 200x200, JD79660 (FPC-8101)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
examples/GxEPD2_HelloWorld/GxEPD2_selection_check.h

@@ -105,6 +105,7 @@
 // 4-color e-paper
 #define GxEPD2_154c_GDEM0154F51H_IS_4C true
 #define GxEPD2_213c_GDEY0213F51_IS_4C true
+#define GxEPD2_213c_GDEY0213F52_IS_4C true
 #define GxEPD2_266c_GDEY0266F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51_IS_4C true

+ 1 - 0
examples/GxEPD2_NotPagedExample/GxEPD2_display_selection_new_style.h

@@ -111,6 +111,7 @@
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_154c_GDEM0154F51H // GDEM0154F51H 200x200, JD79660 (FPC-8101)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
examples/GxEPD2_NotPagedExample/GxEPD2_selection_check.h

@@ -105,6 +105,7 @@
 // 4-color e-paper
 #define GxEPD2_154c_GDEM0154F51H_IS_4C true
 #define GxEPD2_213c_GDEY0213F51_IS_4C true
+#define GxEPD2_213c_GDEY0213F52_IS_4C true
 #define GxEPD2_266c_GDEY0266F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51_IS_4C true

+ 1 - 0
examples/GxEPD2_PagedDisplayUsingCallback/GxEPD2_display_selection_new_style.h

@@ -111,6 +111,7 @@
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_154c_GDEM0154F51H // GDEM0154F51H 200x200, JD79660 (FPC-8101)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
examples/GxEPD2_PagedDisplayUsingCallback/GxEPD2_selection_check.h

@@ -105,6 +105,7 @@
 // 4-color e-paper
 #define GxEPD2_154c_GDEM0154F51H_IS_4C true
 #define GxEPD2_213c_GDEY0213F51_IS_4C true
+#define GxEPD2_213c_GDEY0213F52_IS_4C true
 #define GxEPD2_266c_GDEY0266F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51_IS_4C true

+ 1 - 0
examples/GxEPD2_RotaryUsingBusyCallback/GxEPD2_display_selection_new_style.h

@@ -111,6 +111,7 @@
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_154c_GDEM0154F51H // GDEM0154F51H 200x200, JD79660 (FPC-8101)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
examples/GxEPD2_RotaryUsingBusyCallback/GxEPD2_selection_check.h

@@ -105,6 +105,7 @@
 // 4-color e-paper
 #define GxEPD2_154c_GDEM0154F51H_IS_4C true
 #define GxEPD2_213c_GDEY0213F51_IS_4C true
+#define GxEPD2_213c_GDEY0213F52_IS_4C true
 #define GxEPD2_266c_GDEY0266F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51_IS_4C true

+ 1 - 0
examples/GxEPD2_SD_Example/GxEPD2_display_selection_new_style.h

@@ -111,6 +111,7 @@
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_154c_GDEM0154F51H // GDEM0154F51H 200x200, JD79660 (FPC-8101)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
examples/GxEPD2_SD_Example/GxEPD2_selection_check.h

@@ -105,6 +105,7 @@
 // 4-color e-paper
 #define GxEPD2_154c_GDEM0154F51H_IS_4C true
 #define GxEPD2_213c_GDEY0213F51_IS_4C true
+#define GxEPD2_213c_GDEY0213F52_IS_4C true
 #define GxEPD2_266c_GDEY0266F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51_IS_4C true

+ 1 - 0
examples/GxEPD2_SerialFlash_Example/GxEPD2_display_selection_new_style.h

@@ -111,6 +111,7 @@
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_154c_GDEM0154F51H // GDEM0154F51H 200x200, JD79660 (FPC-8101)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
examples/GxEPD2_SerialFlash_Example/GxEPD2_selection_check.h

@@ -105,6 +105,7 @@
 // 4-color e-paper
 #define GxEPD2_154c_GDEM0154F51H_IS_4C true
 #define GxEPD2_213c_GDEY0213F51_IS_4C true
+#define GxEPD2_213c_GDEY0213F52_IS_4C true
 #define GxEPD2_266c_GDEY0266F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51_IS_4C true

+ 1 - 0
examples/GxEPD2_Spiffs_Example/GxEPD2_display_selection_new_style.h

@@ -111,6 +111,7 @@
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_154c_GDEM0154F51H // GDEM0154F51H 200x200, JD79660 (FPC-8101)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
examples/GxEPD2_Spiffs_Example/GxEPD2_selection_check.h

@@ -105,6 +105,7 @@
 // 4-color e-paper
 #define GxEPD2_154c_GDEM0154F51H_IS_4C true
 #define GxEPD2_213c_GDEY0213F51_IS_4C true
+#define GxEPD2_213c_GDEY0213F52_IS_4C true
 #define GxEPD2_266c_GDEY0266F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51_IS_4C true

+ 1 - 0
examples/GxEPD2_U8G2_Fonts_Example/GxEPD2_display_selection_new_style.h

@@ -111,6 +111,7 @@
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_154c_GDEM0154F51H // GDEM0154F51H 200x200, JD79660 (FPC-8101)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
examples/GxEPD2_U8G2_Fonts_Example/GxEPD2_selection_check.h

@@ -105,6 +105,7 @@
 // 4-color e-paper
 #define GxEPD2_154c_GDEM0154F51H_IS_4C true
 #define GxEPD2_213c_GDEY0213F51_IS_4C true
+#define GxEPD2_213c_GDEY0213F52_IS_4C true
 #define GxEPD2_266c_GDEY0266F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51H_IS_4C true
 #define GxEPD2_290c_GDEY029F51_IS_4C true

+ 1 - 0
examples/GxEPD2_WiFi_CertStore_Example/GxEPD2_WiFi_CertStore_Example.ino

@@ -129,6 +129,7 @@
 //#define GxEPD2_DRIVER_CLASS GxEPD2_1330c_GDEM133Z91 // GDEM133Z91 960x680, SSD1677 (FPC-7701 REV.B)
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
examples/GxEPD2_WiFi_Example/GxEPD2_WiFi_DisplaySelection.h

@@ -87,6 +87,7 @@
 //#define GxEPD2_DRIVER_CLASS GxEPD2_1330c_GDEM133Z91 // GDEM133Z91 960x680, SSD1677 (FPC-7701 REV.B)
 // 4-color e-paper
 //#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F51 // GDEY0213F51 122x250, JD79661 (FPC-A002 20.04.08)
+//#define GxEPD2_DRIVER_CLASS GxEPD2_213c_GDEY0213F52 // GDEY0213F52 122x250, JD79676, full refresh only
 //#define GxEPD2_DRIVER_CLASS GxEPD2_266c_GDEY0266F51H // GDEY0266F51H 184x360, JD79667 (FPC-H006 22.04.02)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51H // GDEY029F51H 168x384, JD79667 (FPC-H004 22.03.24)
 //#define GxEPD2_DRIVER_CLASS GxEPD2_290c_GDEY029F51 // GDEY029F51 128x296, JD79667 (BWRY)

+ 1 - 0
src/GxEPD2.h

@@ -123,6 +123,7 @@ class GxEPD2
       // 4-color
       GDEM0154F51H,
       GDEY0213F51,
+      GDEY0213F52,
       GDEY0266F51H,
       GDEY029F51H,
       GDEY029F51,

+ 3 - 0
src/GxEPD2_4C.h

@@ -54,6 +54,9 @@
 #if __has_include("epd4c/GxEPD2_213c_GDEY0213F51.h")
 #include "epd4c/GxEPD2_213c_GDEY0213F51.h"
 #endif
+#if __has_include("epd4c/GxEPD2_213c_GDEY0213F52.h")
+#include "epd4c/GxEPD2_213c_GDEY0213F52.h"
+#endif
 #if __has_include("epd4c/GxEPD2_266c_GDEY0266F51H.h")
 #include "epd4c/GxEPD2_266c_GDEY0266F51H.h"
 #endif

+ 938 - 0
src/epd4c/GxEPD2_213c_GDEY0213F52.cpp

@@ -0,0 +1,938 @@
+// Display Library for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
+// Requires HW SPI and Adafruit_GFX. Caution: the e-paper panels require 3.3V supply AND data lines!
+//
+// based on Demo Example from Good Display: A32-GDEY0213F52-20240827 (V2.0)
+// Panel: GDEY0213F52 : https://www.good-display.com/product/463.html
+// Controller: JD79676
+//
+// Author: Jean-Marc Zingg
+//
+// Version: see library.properties
+//
+// Library: https://github.com/ZinggJM/GxEPD2
+
+#include "GxEPD2_213c_GDEY0213F52.h"
+
+GxEPD2_213c_GDEY0213F52::GxEPD2_213c_GDEY0213F52(int16_t cs, int16_t dc, int16_t rst, int16_t busy) :
+  GxEPD2_EPD(cs, dc, rst, busy, LOW, 50000000, WIDTH, HEIGHT, panel, hasColor, hasPartialUpdate, hasFastPartialUpdate)
+{
+  _paged = false;
+}
+
+void GxEPD2_213c_GDEY0213F52::clearScreen(uint8_t value)
+{
+  clearScreen(value, 0xFF);
+}
+
+void GxEPD2_213c_GDEY0213F52::clearScreen(uint8_t black_value, uint8_t color_value)
+{
+  writeScreenBuffer(black_value, color_value);
+  refresh();
+}
+
+void GxEPD2_213c_GDEY0213F52::writeScreenBuffer(uint8_t value)
+{
+  writeScreenBuffer(value, 0xFF);
+}
+
+void GxEPD2_213c_GDEY0213F52::writeScreenBuffer(uint8_t black_value, uint8_t color_value)
+{
+  //Serial.println("writeScreenBuffer");
+  if (!_init_display_done) _InitDisplay();
+  _writeCommand(0x10);
+  _startTransfer();
+  for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(HEIGHT) / 4; i++)
+  {
+    _transfer(0xFF == black_value ? 0x55 : 0x00);
+  }
+  _endTransfer();
+  _initial_write = false; // initial full screen buffer clean done
+}
+
+void GxEPD2_213c_GDEY0213F52::writeImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
+{
+  //Serial.print("writeImage("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
+  //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+  if (!_init_display_done) _InitDisplay();
+  if (_initial_write) writeScreenBuffer();
+  if (hasPartialUpdate)
+  {
+    int16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
+    x -= x % 8; // byte boundary
+    w = wb * 8; // byte boundary
+    int16_t x1 = x < 0 ? 0 : x; // limit
+    int16_t y1 = y < 0 ? 0 : y; // limit
+    int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
+    int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
+    int16_t dx = x1 - x;
+    int16_t dy = y1 - y;
+    w1 -= dx;
+    h1 -= dy;
+    if ((w1 <= 0) || (h1 <= 0)) return;
+    _setPartialRamArea(x1, y1, w1, h1);
+    _writeCommand(0x10);
+    _startTransfer();
+    for (int16_t i = 0; i < h1; i++)
+    {
+      for (int16_t j = 0; j < w1 / 8; j++)
+      {
+        uint8_t data = 0xFF;
+        // use wb, h of bitmap for index!
+        uint32_t idx = mirror_y ? j + dx / 8 + uint32_t((h - 1 - (i + dy))) * wb : j + dx / 8 + uint32_t(i + dy) * wb;
+        if (pgm)
+        {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+          data = pgm_read_byte(&bitmap[idx]);
+#else
+          data = bitmap[idx];
+#endif
+        }
+        else
+        {
+          data = bitmap[idx];
+        }
+        if (invert) data = ~data;
+        for (int16_t k = 0; k < 2; k++)
+        {
+          uint8_t data2 = (data & 0x80 ? 0x40 : 0x00) | (data & 0x40 ? 0x10 : 0x00) |
+                          (data & 0x20 ? 0x04 : 0x00) | (data & 0x10 ? 0x01 : 0x00);
+          data <<= 4;
+          _transfer(data2);
+        }
+      }
+    }
+    _endTransfer();
+  }
+  else
+  {
+    if (_paged && (x == 0) && (w == int16_t(WIDTH)) && (h < int16_t(HEIGHT)))
+    {
+      //Serial.println("paged");
+      _startTransfer();
+      for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(h) / 8; i++)
+      {
+        uint8_t data = bitmap[i];
+        for (int16_t k = 0; k < 2; k++)
+        {
+          uint8_t data2 = (data & 0x80 ? 0x40 : 0x00) | (data & 0x40 ? 0x10 : 0x00) |
+                          (data & 0x20 ? 0x04 : 0x00) | (data & 0x10 ? 0x01 : 0x00);
+          data <<= 4;
+          _transfer(data2);
+        }
+      }
+      _endTransfer();
+      if (y + h == HEIGHT) // last page
+      {
+        //Serial.println("paged ended");
+        _paged = false;
+      }
+    }
+    else
+    {
+      _paged = false;
+      int16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
+      x -= x % 8; // byte boundary
+      w = wb * 8; // byte boundary
+      if ((w <= 0) || (h <= 0)) return;
+      _writeCommand(0x10);
+      _startTransfer();
+      for (int16_t i = 0; i < int16_t(HEIGHT); i++)
+      {
+        for (int16_t j = 0; j < int16_t(WIDTH); j += 8)
+        {
+          uint8_t data = 0xFF;
+          if ((j >= x) && (j <= x + w) && (i >= y) && (i < y + h))
+          {
+            uint32_t idx = mirror_y ? (j - x) / 8 + uint32_t((h - 1 - (i - y))) * wb : (j - x) / 8 + uint32_t(i - y) * wb;
+            if (pgm)
+            {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+              data = pgm_read_byte(&bitmap[idx]);
+#else
+              data = bitmap[idx];
+#endif
+            }
+            else
+            {
+              data = bitmap[idx];
+            }
+            if (invert) data = ~data;
+          }
+          for (int16_t k = 0; k < 2; k++)
+          {
+            uint8_t data2 = (data & 0x80 ? 0x40 : 0x00) | (data & 0x40 ? 0x10 : 0x00) |
+                            (data & 0x20 ? 0x04 : 0x00) | (data & 0x10 ? 0x01 : 0x00);
+            data <<= 4;
+            _transfer(data2);
+          }
+        }
+      }
+      _endTransfer();
+    }
+  }
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+}
+
+void GxEPD2_213c_GDEY0213F52::writeImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
+{
+  if (!black && !color) return;
+  if (!color) return writeImage(black, x, y, w, h, invert, mirror_y, pgm);
+  //Serial.print("writeImage("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
+  //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+  if (!_init_display_done) _InitDisplay();
+  if (_initial_write) writeScreenBuffer();
+  if (hasPartialUpdate)
+  {
+    int16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
+    x -= x % 8; // byte boundary
+    w = wb * 8; // byte boundary
+    int16_t x1 = x < 0 ? 0 : x; // limit
+    int16_t y1 = y < 0 ? 0 : y; // limit
+    int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
+    int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
+    int16_t dx = x1 - x;
+    int16_t dy = y1 - y;
+    w1 -= dx;
+    h1 -= dy;
+    if ((w1 <= 0) || (h1 <= 0)) return;
+    _setPartialRamArea(x1, y1, w1, h1);
+    _writeCommand(0x10);
+    _startTransfer();
+    for (int16_t i = 0; i < h1; i++)
+    {
+      for (int16_t j = 0; j < w1 / 8; j++)
+      {
+        uint8_t black_data = 0xFF, color_data = 0xFF;
+        // use wb, h of bitmap for index!
+        uint32_t idx = mirror_y ? j + dx / 8 + uint32_t((h - 1 - (i + dy))) * wb : j + dx / 8 + uint32_t(i + dy) * wb;
+        if (pgm)
+        {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+          black_data = pgm_read_byte(&black[idx]);
+          color_data = pgm_read_byte(&color[idx]);
+#else
+          black_data = black[idx];
+          color_data = color[idx];
+#endif
+        }
+        else
+        {
+          black_data = black[idx];
+          color_data = color[idx];
+        }
+        if (invert)
+        {
+          black_data = ~black_data;
+          color_data = ~color_data;
+        }
+        for (int16_t k = 0; k < 2; k++)
+        {
+          uint8_t out_data = 0x00;
+          for (int16_t l = 0; l < 4; l++)
+          {
+            out_data <<= 2;
+            if (!(color_data & 0x80)) out_data |= 0x03; // red
+            else out_data |= black_data & 0x80 ? 0x01 : 0x00; // white or black
+            black_data <<= 1;
+            color_data <<= 1;
+          }
+          _transfer(out_data);
+        }
+      }
+    }
+    _endTransfer();
+  }
+  else
+  {
+    if (_paged && (x == 0) && (w == int16_t(WIDTH)) && (h < int16_t(HEIGHT)))
+    {
+      //Serial.println("paged");
+      _startTransfer();
+      for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(h) / 8; i++)
+      {
+        uint8_t black_data = black[i];
+        uint8_t color_data = color[i];
+        for (int16_t k = 0; k < 2; k++)
+        {
+          uint8_t out_data = 0x00;
+          for (int16_t l = 0; l < 4; l++)
+          {
+            out_data <<= 2;
+            if (!(color_data & 0x80)) out_data |= 0x03; // red
+            else out_data |= black_data & 0x80 ? 0x01 : 0x00; // white or black
+            black_data <<= 1;
+            color_data <<= 1;
+          }
+          _transfer(out_data);
+        }
+      }
+      _endTransfer();
+      if (y + h == HEIGHT) // last page
+      {
+        //Serial.println("paged ended");
+        _paged = false;
+      }
+    }
+    else
+    {
+      _paged = false;
+      int16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
+      x -= x % 8; // byte boundary
+      w = wb * 8; // byte boundary
+      if ((w <= 0) || (h <= 0)) return;
+      _writeCommand(0x10);
+      _startTransfer();
+      for (int16_t i = 0; i < int16_t(HEIGHT); i++)
+      {
+        for (int16_t j = 0; j < int16_t(WIDTH); j += 8)
+        {
+          uint8_t black_data = 0xFF, color_data = 0xFF;
+          if ((j >= x) && (j < x + w) && (i >= y) && (i < y + h))
+          {
+            uint32_t idx = mirror_y ? (j - x) / 8 + uint32_t((h - 1 - (i - y))) * wb : (j - x) / 8 + uint32_t(i - y) * wb;
+            if (pgm)
+            {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+              black_data = pgm_read_byte(&black[idx]);
+              color_data = pgm_read_byte(&color[idx]);
+#else
+              black_data = black[idx];
+              color_data = color[idx];
+#endif
+            }
+            else
+            {
+              black_data = black[idx];
+              color_data = color[idx];
+            }
+            if (invert)
+            {
+              black_data = ~black_data;
+              color_data = ~color_data;
+            }
+          }
+          for (int16_t k = 0; k < 2; k++)
+          {
+            uint8_t out_data = 0x00;
+            for (int16_t l = 0; l < 4; l++)
+            {
+              out_data <<= 2;
+              if (!(color_data & 0x80)) out_data |= 0x03; // red
+              else out_data |= black_data & 0x80 ? 0x01 : 0x00; // white or black
+              black_data <<= 1;
+              color_data <<= 1;
+            }
+            _transfer(out_data);
+          }
+        }
+      }
+      _endTransfer();
+    }
+  }
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+}
+
+void GxEPD2_213c_GDEY0213F52::writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
+    int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
+{
+  //Serial.print("writeImagePart("); Serial.print(x_part); Serial.print(", "); Serial.print(y_part); Serial.print(", ");
+  //Serial.print(w_bitmap); Serial.print(", "); Serial.print(h_bitmap); Serial.print(", ");
+  //Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
+  //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+  if (!_init_display_done) _InitDisplay();
+  if (_initial_write) writeScreenBuffer();
+  if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
+  if ((x_part < 0) || (x_part >= w_bitmap)) return;
+  if ((y_part < 0) || (y_part >= h_bitmap)) return;
+  int16_t wb_bitmap = (w_bitmap + 7) / 8; // width bytes, bitmaps are padded
+  x_part -= x_part % 8; // byte boundary
+  w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
+  h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
+  // make x, w multiple of 8
+  w += x % 8; // adjust for byte boundary of x
+  x -= x % 8; // byte boundary ox
+  w = 8 * ((w + 7) / 8); // byte boundary, bitmaps are padded
+  int16_t x1 = x < 0 ? 0 : x; // limit
+  int16_t y1 = y < 0 ? 0 : y; // limit
+  int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
+  int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
+  int16_t dx = x1 - x;
+  int16_t dy = y1 - y;
+  w1 -= dx;
+  h1 -= dy;
+  if ((w1 <= 0) || (h1 <= 0)) return;
+  if (hasPartialUpdate)
+  {
+    _setPartialRamArea(x1, y1, w1, h1);
+    _writeCommand(0x10);
+    _startTransfer();
+    for (int16_t i = 0; i < h1; i++)
+    {
+      for (int16_t j = 0; j < w1 / 8; j++)
+      {
+        uint8_t data;
+        // use wb_bitmap, h_bitmap of bitmap for index!
+        uint32_t idx = mirror_y ? x_part / 8 + j + dx / 8 + uint32_t((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / 8 + j + dx / 8 + uint32_t(y_part + i + dy) * wb_bitmap;
+        if (pgm)
+        {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+          data = pgm_read_byte(&bitmap[idx]);
+#else
+          data = bitmap[idx];
+#endif
+        }
+        else
+        {
+          data = bitmap[idx];
+        }
+        if (invert) data = ~data;
+        for (int16_t k = 0; k < 2; k++)
+        {
+          uint8_t data2 = (data & 0x80 ? 0x40 : 0x00) | (data & 0x40 ? 0x10 : 0x00) |
+                          (data & 0x20 ? 0x04 : 0x00) | (data & 0x10 ? 0x01 : 0x00);
+          data <<= 4;
+          _transfer(data2);
+        }
+      }
+    }
+    _endTransfer();
+  }
+  else
+  {
+    _writeCommand(0x10);
+    _startTransfer();
+    for (int16_t i = 0; i < int16_t(HEIGHT); i++)
+    {
+      for (int16_t j = 0; j < int16_t(WIDTH); j += 8)
+      {
+        uint8_t data = 0xFF;
+        if ((j >= x1) && (j < x1 + w) && (i >= y1) && (i < y1 + h))
+        {
+          // use wb_bitmap, h_bitmap of bitmap for index!
+          uint32_t idx = mirror_y ? (x_part + j - x1) / 8 + uint32_t((h_bitmap - 1 - (y_part + i - y1))) * wb_bitmap : (x_part + j - x1) / 8 + uint32_t(y_part + i - y1) * wb_bitmap;
+          if (pgm)
+          {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+            data = pgm_read_byte(&bitmap[idx]);
+#else
+            data = bitmap[idx];
+#endif
+          }
+          else
+          {
+            data = bitmap[idx];
+          }
+          if (invert) data = ~data;
+        }
+        for (int16_t k = 0; k < 2; k++)
+        {
+          uint8_t data2 = (data & 0x80 ? 0x40 : 0x00) | (data & 0x40 ? 0x10 : 0x00) |
+                          (data & 0x20 ? 0x04 : 0x00) | (data & 0x10 ? 0x01 : 0x00);
+          data <<= 4;
+          _transfer(data2);
+        }
+      }
+    }
+    _endTransfer();
+  }
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+}
+
+void GxEPD2_213c_GDEY0213F52::writeImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
+    int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
+{
+  //Serial.print("writeImagePart("); Serial.print(x_part); Serial.print(", "); Serial.print(y_part); Serial.print(", ");
+  //Serial.print(w_bitmap); Serial.print(", "); Serial.print(h_bitmap); Serial.print(", ");
+  //Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
+  //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
+  if (!black && !color) return;
+  if (!color) return writeImagePart(black, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
+  if (!_init_display_done) _InitDisplay();
+  if (_initial_write) writeScreenBuffer();
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+  if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
+  if ((x_part < 0) || (x_part >= w_bitmap)) return;
+  if ((y_part < 0) || (y_part >= h_bitmap)) return;
+  int16_t wb_bitmap = (w_bitmap + 7) / 8; // width bytes, bitmaps are padded
+  x_part -= x_part % 8; // byte boundary
+  w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
+  h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
+  // make x, w multiple of 8
+  w += x % 8; // adjust for byte boundary of x
+  x -= x % 8; // byte boundary ox
+  w = 8 * ((w + 7) / 8); // byte boundary, bitmaps are padded
+  int16_t x1 = x < 0 ? 0 : x; // limit
+  int16_t y1 = y < 0 ? 0 : y; // limit
+  int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
+  int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
+  int16_t dx = x1 - x;
+  int16_t dy = y1 - y;
+  w1 -= dx;
+  h1 -= dy;
+  if ((w1 <= 0) || (h1 <= 0)) return;
+  if (hasPartialUpdate)
+  {
+    _setPartialRamArea(x1, y1, w1, h1);
+    _writeCommand(0x10);
+    _startTransfer();
+    for (int16_t i = 0; i < h1; i++)
+    {
+      for (int16_t j = 0; j < w1 / 8; j++)
+      {
+        uint8_t black_data = 0xFF, color_data = 0xFF;
+        // use wb_bitmap, h_bitmap of bitmap for index!
+        uint32_t idx = mirror_y ? x_part / 8 + j + dx / 8 + uint32_t((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / 8 + j + dx / 8 + uint32_t(y_part + i + dy) * wb_bitmap;
+        if (pgm)
+        {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+          black_data = pgm_read_byte(&black[idx]);
+          color_data = pgm_read_byte(&color[idx]);
+#else
+          black_data = black[idx];
+          color_data = color[idx];
+#endif
+        }
+        else
+        {
+          black_data = black[idx];
+          color_data = color[idx];
+        }
+        for (int16_t k = 0; k < 2; k++)
+        {
+          uint8_t out_data = 0x00;
+          for (int16_t l = 0; l < 4; l++)
+          {
+            out_data <<= 2;
+            if (!(color_data & 0x80)) out_data |= 0x03; // red
+            else out_data |= black_data & 0x80 ? 0x01 : 0x00; // white or black
+            black_data <<= 1;
+            color_data <<= 1;
+          }
+          _transfer(out_data);
+        }
+      }
+    }
+    _endTransfer();
+  }
+  else
+  {
+    _writeCommand(0x10);
+    _startTransfer();
+    for (int16_t i = 0; i < int16_t(HEIGHT); i++)
+    {
+      for (int16_t j = 0; j < int16_t(WIDTH); j += 8)
+      {
+        uint8_t black_data = 0xFF, color_data = 0xFF;
+        if ((j >= x1) && (j < x1 + w) && (i >= y1) && (i < y1 + h))
+        {
+          // use wb_bitmap, h_bitmap of bitmap for index!
+          uint32_t idx = mirror_y ? (x_part + j - x1) / 8 + uint32_t((h_bitmap - 1 - (y_part + i - y1))) * wb_bitmap : (x_part + j - x1) / 8 + uint32_t(y_part + i - y1) * wb_bitmap;
+          if (pgm)
+          {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+            black_data = pgm_read_byte(&black[idx]);
+            color_data = pgm_read_byte(&color[idx]);
+#else
+            black_data = black[idx];
+            color_data = color[idx];
+#endif
+          }
+          else
+          {
+            black_data = black[idx];
+            color_data = color[idx];
+          }
+          if (invert)
+          {
+            black_data = ~black_data;
+            color_data = ~color_data;
+          }
+        }
+        for (int16_t k = 0; k < 2; k++)
+        {
+          uint8_t out_data = 0x00;
+          for (int16_t l = 0; l < 4; l++)
+          {
+            out_data <<= 2;
+            if (!(color_data & 0x80)) out_data |= 0x03; // red
+            else out_data |= black_data & 0x80 ? 0x01 : 0x00; // white or black
+            black_data <<= 1;
+            color_data <<= 1;
+          }
+          _transfer(out_data);
+        }
+      }
+    }
+    _endTransfer();
+  }
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+}
+
+void GxEPD2_213c_GDEY0213F52::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;
+  //Serial.print("writeNative("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
+  //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+  if (!_init_display_done) _InitDisplay();
+  if (_initial_write) writeScreenBuffer();
+  if (hasPartialUpdate)
+  {
+    int16_t wb = (w + 3) / 4; // width bytes, bitmaps are padded
+    x -= x % 4; // byte boundary
+    w = wb * 4; // byte boundary
+    int16_t x1 = x < 0 ? 0 : x; // limit
+    int16_t y1 = y < 0 ? 0 : y; // limit
+    int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
+    int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
+    int16_t dx = x1 - x;
+    int16_t dy = y1 - y;
+    w1 -= dx;
+    h1 -= dy;
+    if ((w1 <= 0) || (h1 <= 0)) return;
+    _setPartialRamArea(x1, y1, w1, h1);
+    _writeCommand(0x10);
+    _startTransfer();
+    for (int16_t i = 0; i < h1; i++)
+    {
+      for (int16_t j = 0; j < w1 / 4; j++)
+      {
+        uint8_t data;
+        // use wb, h of bitmap for index!
+        uint32_t idx = mirror_y ? j + dx / 4 + uint32_t((h - 1 - (i + dy))) * wb : j + dx / 4 + uint32_t(i + dy) * wb;
+        if (pgm)
+        {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+          data = pgm_read_byte(&data1[idx]);
+#else
+          data = data1[idx];
+#endif
+        }
+        else
+        {
+          data = data1[idx];
+        }
+        if (invert) data = ~data;
+        _transfer(data);
+      }
+    }
+    _endTransfer();
+  }
+  else
+  {
+    if (_paged && (x == 0) && (w == int16_t(WIDTH)) && (h < int16_t(HEIGHT)))
+    {
+      //Serial.println("paged");
+      _startTransfer();
+      for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(h) / 4; i++)
+      {
+        uint8_t data = data1[i];
+        _transfer(data);
+      }
+      _endTransfer();
+      if (y + h == HEIGHT) // last page
+      {
+        //Serial.println("paged ended");
+        _paged = false;
+      }
+    }
+    else
+    {
+      //Serial.println("not paged");
+      _paged = false;
+      int16_t wb = (w + 3) / 4; // width bytes, bitmaps are padded
+      x -= x % 4; // byte boundary
+      w = wb * 4; // byte boundary
+      if ((w <= 0) || (h <= 0)) return;
+      _writeCommand(0x10);
+      _startTransfer();
+      for (int16_t i = 0; i < int16_t(HEIGHT); i++)
+      {
+        for (int16_t j = 0; j < int16_t(WIDTH); j += 4)
+        {
+          uint8_t data = 0x55;
+          if (data1)
+          {
+            if ((j >= x) && (j < x + w) && (i >= y) && (i < y + h))
+            {
+              uint32_t idx = mirror_y ? (j - x) / 4 + uint32_t((h - 1 - (i - y))) * wb : (j - x) / 4 + uint32_t(i - y) * wb;
+              if (pgm)
+              {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+                data = pgm_read_byte(&data1[idx]);
+#else
+                data = data1[idx];
+#endif
+              }
+              else
+              {
+                data = data1[idx];
+              }
+              if (invert) data = ~data;
+            }
+          }
+          _transfer(data);
+        }
+      }
+      _endTransfer();
+    }
+  }
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+}
+
+void GxEPD2_213c_GDEY0213F52::writeNativePart(const uint8_t* data1, const uint8_t* data2, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
+    int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
+{
+  if (!data1) return;
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+  if (!_init_display_done) _InitDisplay();
+  if (_initial_write) writeScreenBuffer();
+  if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
+  if ((x_part < 0) || (x_part >= w_bitmap)) return;
+  if ((y_part < 0) || (y_part >= h_bitmap)) return;
+  int16_t wb_bitmap = (w_bitmap + 3) / 4; // width bytes, bitmaps are padded
+  x_part -= x_part % 4; // byte boundary
+  w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
+  h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
+  w += x % 4; // adjust for byte boundary of x
+  x -= x % 4; // byte boundary
+  w = 4 * ((w + 3) / 4); // byte boundary, bitmaps are padded
+  int16_t x1 = x < 0 ? 0 : x; // limit
+  int16_t y1 = y < 0 ? 0 : y; // limit
+  int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
+  int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
+  int16_t dx = x1 - x;
+  int16_t dy = y1 - y;
+  w1 -= dx;
+  h1 -= dy;
+  if ((w1 <= 0) || (h1 <= 0)) return;
+  if (hasPartialUpdate)
+  {
+    _setPartialRamArea(x1, y1, w1, h1);
+    _writeCommand(0x10);
+    _startTransfer();
+    for (int16_t i = 0; i < h1; i++)
+    {
+      for (int16_t j = 0; j < w1 / 4; j++)
+      {
+        uint8_t data;
+        // use wb_bitmap, h_bitmap of bitmap for index!
+        uint32_t idx = mirror_y ? x_part / 4 + j + dx / 4 + uint32_t((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / 4 + j + dx / 4 + uint32_t(y_part + i + dy) * wb_bitmap;
+        if (pgm)
+        {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+          data = pgm_read_byte(&data1[idx]);
+#else
+          data = data1[idx];
+#endif
+        }
+        else
+        {
+          data = data1[idx];
+        }
+        if (invert) data = ~data;
+        _transfer(data);
+      }
+    }
+    _endTransfer();
+  }
+  else
+  {
+    _writeCommand(0x10);
+    _startTransfer();
+    for (int16_t i = 0; i < int16_t(HEIGHT); i++)
+    {
+      for (int16_t j = 0; j < int16_t(WIDTH); j += 4)
+      {
+        uint8_t data = 0x55;
+        if ((j >= x1) && (j < x1 + w) && (i >= y1) && (i < y1 + h))
+        {
+          // use wb_bitmap, h_bitmap of bitmap for index!
+          uint32_t idx = mirror_y ? (x_part + j - x1) / 4 + uint32_t((h_bitmap - 1 - (y_part + i - y1))) * wb_bitmap : (x_part + j - x1) / 4 + uint32_t(y_part + i - y1) * wb_bitmap;
+          if (pgm)
+          {
+#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
+            data = pgm_read_byte(&data1[idx]);
+#else
+            data = data1[idx];
+#endif
+          }
+          else
+          {
+            data = data1[idx];
+          }
+          if (invert) data = ~data;
+        }
+        _transfer(data);
+      }
+    }
+    _endTransfer();
+  }
+  delay(1); // yield() to avoid WDT on ESP8266 and ESP32
+}
+
+void GxEPD2_213c_GDEY0213F52::drawImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
+{
+  writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
+  refresh(x, y, w, h);
+}
+
+void GxEPD2_213c_GDEY0213F52::drawImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
+    int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
+{
+  writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
+  refresh(x, y, w, h);
+}
+
+void GxEPD2_213c_GDEY0213F52::drawImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
+{
+  writeImage(black, color, x, y, w, h, invert, mirror_y, pgm);
+  refresh(x, y, w, h);
+}
+
+void GxEPD2_213c_GDEY0213F52::drawImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
+    int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
+{
+  writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
+  refresh(x, y, w, h);
+}
+
+void GxEPD2_213c_GDEY0213F52::drawNative(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)
+{
+  writeNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
+  refresh(x, y, w, h);
+}
+
+void GxEPD2_213c_GDEY0213F52::refresh(bool partial_update_mode)
+{
+  if (hasPartialUpdate) _setPartialRamArea(0, 0, WIDTH, HEIGHT);
+  _refresh(partial_update_mode);
+}
+
+void GxEPD2_213c_GDEY0213F52::refresh(int16_t x, int16_t y, int16_t w, int16_t h)
+{
+  // intersection with screen
+  int16_t w1 = x < 0 ? w + x : w; // reduce
+  int16_t h1 = y < 0 ? h + y : h; // reduce
+  int16_t x1 = x < 0 ? 0 : x; // limit
+  int16_t y1 = y < 0 ? 0 : y; // limit
+  w1 = x1 + w1 < int16_t(WIDTH) ? w1 : int16_t(WIDTH) - x1; // limit
+  h1 = y1 + h1 < int16_t(HEIGHT) ? h1 : int16_t(HEIGHT) - y1; // limit
+  if ((w1 <= 0) || (h1 <= 0)) return;
+  // make x1, w1 multiple of 4
+  w1 += x1 % 4;
+  if (w1 % 4 > 0) w1 += 4 - w1 % 4;
+  x1 -= x1 % 4;
+  bool fullscreen = ((x1 == 0) && (y1 == 0) && (w1 == WIDTH) && (h1 == HEIGHT));
+  if (hasPartialUpdate) _setPartialRamArea(x1, y1, w1, h1, !fullscreen);
+  _refresh(!fullscreen);
+}
+
+void GxEPD2_213c_GDEY0213F52::powerOff()
+{
+  _PowerOff();
+}
+
+void GxEPD2_213c_GDEY0213F52::hibernate()
+{
+  _PowerOff();
+  if (_rst >= 0)
+  {
+    _writeCommand(0x07); // deep sleep
+    _writeData(0xA5);    // control code
+    _hibernating = true;
+    _init_display_done = false;
+  }
+}
+
+void GxEPD2_213c_GDEY0213F52::setPaged()
+{
+  if (!hasPartialUpdate)
+  {
+    _paged = true;
+    _InitDisplay();
+    _writeCommand(0x10);
+  }
+}
+
+void GxEPD2_213c_GDEY0213F52::_refresh(bool partial_update_mode)
+{
+  // GDEY0213F52 demo (EPD_update) issues only the Display Refresh command and
+  // relies on the OTP default CDI (0x50 = 0x97); it does not reprogram CDI here.
+  // Full-refresh only for now; partial_update_mode is not yet supported.
+  (void)partial_update_mode;
+  _writeCommand(0x12); // Display Refresh
+  _writeData(0x00);
+  delay(1);
+  _waitWhileBusy("_refresh", full_refresh_time);
+  //_power_is_on = false; // not needed
+  _init_display_done = false; // needed
+}
+
+void GxEPD2_213c_GDEY0213F52::_setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial_mode)
+{
+  // NOTE (JD79676): R83H (PTLW) differs from F51 - it adds a PTH_ENB enable bit.
+  // This F51-style layout is NOT reached while hasPartialUpdate == false; it must
+  // be re-derived against the JD79676 datasheet before enabling partial update.
+  //Serial.print("_setPartialRamArea("); Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", ");
+  //Serial.print(w); Serial.print(", "); Serial.print(h); Serial.println(")");
+  _writeCommand(0x83);
+  _writeData(x / 256);
+  _writeData(x % 256);
+  _writeData((x + w - 1) / 256);
+  _writeData((x + w - 1) % 256);
+  _writeData(y / 256);
+  _writeData(y % 256);
+  _writeData((y + h - 1) / 256);
+  _writeData((y + h - 1) % 256);
+  _writeData(partial_mode ? 0x01 : 0x00);
+}
+
+void GxEPD2_213c_GDEY0213F52::_PowerOn()
+{
+  if (!_power_is_on)
+  {
+    _writeCommand(0x04);
+    _waitWhileBusy("_PowerOn", power_on_time);
+  }
+  _power_is_on = true;
+}
+
+void GxEPD2_213c_GDEY0213F52::_PowerOff()
+{
+  if (_power_is_on)
+  {
+    _writeCommand(0x02);
+    _writeData(0x00);
+    _waitWhileBusy("_PowerOff", power_off_time);
+  }
+  _power_is_on = false;
+}
+
+void GxEPD2_213c_GDEY0213F52::_InitDisplay()
+{
+  if ((_rst >= 0) && (_hibernating || _initial_write))
+  {
+    digitalWrite(_rst, HIGH);
+    delay(20); // At least 20ms delay
+    digitalWrite(_rst, LOW); // Module reset
+    delay(2);  // At least 40ms delay, 2ms for WS "clever" reset
+    digitalWrite(_rst, HIGH);
+    delay(2); // At least 50ms delay (32ms measured)
+    _waitWhileBusy("_InitDisplay reset", power_on_time);
+    _hibernating = false;
+    _power_is_on = false;
+  }
+  // GDEY0213F52 / JD79676: unlike the JD79661-based F51, this controller loads
+  // PSR / PWR / BTST / resolution and the full-refresh LUT from on-chip OTP, so
+  // the Good Display demo (A32-GDEY0213F52) writes no register setup here at all
+  // beyond 0xE9, then powers on. OTP resolution default is 128x250 (PSR RES=00),
+  // which already matches WIDTH x HEIGHT, so no TRES (0x61) override is needed.
+  _writeCommand(0xE9);
+  _writeData(0x01);
+  _PowerOn();
+  _init_display_done = true;
+}

+ 80 - 0
src/epd4c/GxEPD2_213c_GDEY0213F52.h

@@ -0,0 +1,80 @@
+// Display Library for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
+// Requires HW SPI and Adafruit_GFX. Caution: the e-paper panels require 3.3V supply AND data lines!
+//
+// based on Demo Example from Good Display: https://www.good-display.com/product/463.html
+// Panel: GDEY0213F52 : https://www.good-display.com/product/463.html
+// Controller: JD79676 : (Good Display JD79676 spec)
+//
+// Author: Jean-Marc Zingg
+//
+// Version: see library.properties
+//
+// Library: https://github.com/ZinggJM/GxEPD2
+
+#ifndef _GxEPD2_213c_GDEY0213F52_H_
+#define _GxEPD2_213c_GDEY0213F52_H_
+
+#include "../GxEPD2_EPD.h"
+
+class GxEPD2_213c_GDEY0213F52 : public GxEPD2_EPD
+{
+  public:
+    // attributes
+    static const uint16_t WIDTH = 128;
+    static const uint16_t WIDTH_VISIBLE = 122;
+    static const uint16_t HEIGHT = 250;
+    static const GxEPD2::Panel panel = GxEPD2::GDEY0213F52;
+    static const bool hasColor = true;
+    // F52 / JD79676: the Good Display demo is full-refresh only. Its partial-window
+    // command (R83H PTLW) adds a PTH_ENB bit vs. F51, so the F51 0x83 windowing is
+    // not reused unverified; use the paged full-frame path (setPaged) meanwhile.
+    static const bool hasPartialUpdate = false;
+    static const bool hasFastPartialUpdate = false; // F52 has a fast path (0xE0/0xE6/0xA5), not wired up yet
+    static const uint16_t power_on_time = 200; // ms, e.g. 157485us
+    static const uint16_t power_off_time = 100; // ms, e.g. 81338us
+    static const uint16_t full_refresh_time = 16000; // ms, F52 spec'd 16 s full
+    static const uint16_t partial_refresh_time = 16000; // ms, F52 spec'd 16 s full (fast path 11 s not wired up)
+    // constructor
+    GxEPD2_213c_GDEY0213F52(int16_t cs, int16_t dc, int16_t rst, int16_t busy);
+    // methods (virtual)
+    //  Support for Bitmaps (Sprites) to Controller Buffer and to Screen
+    void clearScreen(uint8_t value = 0xFF); // init controller memory and screen (default white)
+    void clearScreen(uint8_t black_value, uint8_t color_value); // init controller memory and screen
+    void writeScreenBuffer(uint8_t value = 0xFF); // init controller memory (default white)
+    void writeScreenBuffer(uint8_t black_value, uint8_t color_value); // init controller memory
+    // write to controller memory, without screen refresh; x and w should be multiple of 8
+    void writeImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
+    void writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
+                        int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
+    void writeImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
+    void writeImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
+                        int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
+    // write sprite of native data to controller memory, without screen refresh; x and w should be multiple of 8
+    void writeNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
+    void writeNativePart(const uint8_t* data1, const uint8_t* data2, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
+                        int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
+    // write to controller memory, with screen refresh; x and w should be multiple of 8
+    void drawImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
+    void drawImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
+                       int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
+    void drawImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
+    void drawImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
+                       int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
+    // write sprite of native data to controller memory, with screen refresh; x and w should be multiple of 8
+    void drawNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
+    void refresh(bool partial_update_mode = false); // screen refresh from controller memory to full screen
+    void refresh(int16_t x, int16_t y, int16_t w, int16_t h); // screen refresh from controller memory, partial screen
+    void powerOff(); // turns off generation of panel driving voltages, avoids screen fading over time
+    void hibernate(); // turns powerOff() and sets controller to deep sleep for minimum power use, ONLY if wakeable by RST (rst >= 0)
+    void setPaged(); // for GxEPD2_154c paged workaround, also for 4-color for use with hasPartialUpdate = false
+  private:
+    void _refresh(bool partial_update_mode);
+    void _setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial_mode = true);
+    void _PowerOn();
+    void _PowerOff();
+    void _InitDisplay();
+  private:
+    bool _paged;
+};
+
+#endif