panel_579c_gdey0579f51_master_only.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #pragma once
  2. // Hand-derived from vendor/src/epd4c/GxEPD2_579c_GDEY0579F51.{h,cpp}
  3. // (GDEY0579F51, HX8717 controller, 792x272, same JD79667-family 2bpp/4-color
  4. // packing as GDEY029F51 - see panel_290c_gdey029f51.h). This is the actual
  5. // dual-CS-like split panel from the original bench list: NOT two physical
  6. // CS pins, but two logical regions ("master"/"slave", left/right halves)
  7. // selected over one bus via an 0xA2 command, each with its own window-set
  8. // and its own 0x10 plane-write burst.
  9. //
  10. // Deliberate scope cut (2026-09-19, per user): CycleEngine's state machine
  11. // only knows one window-set + one plane-write per update cycle, and
  12. // extending it to loop over two regions is real work, not just descriptor
  13. // data - so this descriptor addresses the "master" half ONLY, as if it
  14. // were a self-contained 396x272 single-region panel, to validate the 2bpp
  15. // packing and this controller family's init/refresh shape before building
  16. // the master+slave loop.
  17. //
  18. // First hardware run (2026-09-19) showed real content, correctly decoded,
  19. // but compressed/duplicated within roughly half the driven region, plus
  20. // noise/black bands on the untouched half - not yet fully explained. One
  21. // finding so far: don't assume "master" = the physically-left/near-
  22. // connector half. GxEPD2_579_GDEY0579T93.cpp (SSD1683, same 792x272
  23. // panel family, comments explicit) maps "near connector" -> SLAVE and
  24. // "opposite to connector" -> MASTER - the reverse of what might be
  25. // guessed. GDEY0579F51's own driver has no such comment, so which
  26. // physical side "master" actually addresses here is unverified, not
  27. // assumed-correct. A slave-only variant of this same descriptor (swap
  28. // every SELECT_MASTER for SELECT_MASTER->0x02) would empirically test
  29. // whether content moves to the other half - not yet done.
  30. //
  31. // The refresh sequence originally used select=Both (0x00) before the
  32. // 0x12 trigger, matching the vendor's own refresh(bool)'s
  33. // _setPartialRamAreaBoth() call - but 0x12 appears to fire a real
  34. // electrical refresh across the WHOLE physical panel regardless of which
  35. // side's RAM was ever written, which explains the noise/black bands as
  36. // slave's never-initialized RAM being "developed" onto glass. Changed to
  37. // select=Master only, since we only ever want to touch the side we wrote.
  38. // Does not yet explain the duplication/compression artifact.
  39. //
  40. // _InitDisplay()'s reset pulse is gated the same way GDEY029F51's is
  41. // (`_hibernating || _initial_write`) - this engine always does a real
  42. // hardware reset every cycle regardless, a superset of the vendor
  43. // driver's own first-cycle behavior, so no special-casing needed.
  44. #include "epd_command.h"
  45. namespace esphome::gxepd2 {
  46. inline const uint8_t PANEL_579C_GDEY0579F51_MO_SELECT_MASTER[] = {0x01};
  47. inline const uint8_t PANEL_579C_GDEY0579F51_MO_SELECT_BOTH[] = {0x00};
  48. inline const uint8_t PANEL_579C_GDEY0579F51_MO_PSR_MASTER[] = {0x07, 0x29};
  49. inline const uint8_t PANEL_579C_GDEY0579F51_MO_BTST[] = {0x32, 0x32, 0x32, 0x32};
  50. inline const uint8_t PANEL_579C_GDEY0579F51_MO_TRES[] = {0x01, 0x8C, 0x01, 0x10}; // 396x272
  51. inline const uint8_t PANEL_579C_GDEY0579F51_MO_CDI_INIT[] = {0x97};
  52. inline const uint8_t PANEL_579C_GDEY0579F51_MO_E9[] = {0x01};
  53. inline const uint8_t PANEL_579C_GDEY0579F51_MO_E0[] = {0x01};
  54. inline const EpdCommand PANEL_579C_GDEY0579F51_MO_INIT[] = {
  55. {0xA2, PANEL_579C_GDEY0579F51_MO_SELECT_MASTER, 1},
  56. {0x00, PANEL_579C_GDEY0579F51_MO_PSR_MASTER, 2},
  57. {0xA2, PANEL_579C_GDEY0579F51_MO_SELECT_BOTH, 1},
  58. {0x06, PANEL_579C_GDEY0579F51_MO_BTST, 4},
  59. {0x61, PANEL_579C_GDEY0579F51_MO_TRES, 4},
  60. {0x50, PANEL_579C_GDEY0579F51_MO_CDI_INIT, 1},
  61. {0xE9, PANEL_579C_GDEY0579F51_MO_E9, 1},
  62. {0xE0, PANEL_579C_GDEY0579F51_MO_E0, 1},
  63. {0xA2, PANEL_579C_GDEY0579F51_MO_SELECT_MASTER, 1},
  64. {0x04, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true}, // power on
  65. };
  66. // _setPartialRamAreaMaster(0, 0, 396, 272), default partial_mode=true.
  67. inline const uint8_t PANEL_579C_GDEY0579F51_MO_WINDOW[] = {
  68. 0x00, 0x00, // x/256, x%256 = 0
  69. 0x01, 0x8B, // xe/256, xe%256 = 395
  70. 0x00, 0x00, // y/256, y%256 = 0
  71. 0x01, 0x0F, // ye/256, ye%256 = 271
  72. 0x01,
  73. };
  74. inline const EpdCommand PANEL_579C_GDEY0579F51_MO_WINDOW_SEQ[] = {
  75. {0xA2, PANEL_579C_GDEY0579F51_MO_SELECT_MASTER, 1},
  76. {0x83, PANEL_579C_GDEY0579F51_MO_WINDOW, 9},
  77. };
  78. // refresh(false): vendor's own refresh(bool) uses _setPartialRamAreaBoth()
  79. // here, but see file header - deliberately using select=Master instead so
  80. // the 0x12 trigger's real electrical refresh never touches slave's
  81. // never-written RAM (that Both selection is what produced the noise/black
  82. // bands on the untouched half in the first hardware run).
  83. inline const uint8_t PANEL_579C_GDEY0579F51_MO_CDI_REFRESH[] = {0x37};
  84. inline const uint8_t PANEL_579C_GDEY0579F51_MO_REFRESH_TRIGGER[] = {0x00};
  85. inline const EpdCommand PANEL_579C_GDEY0579F51_MO_REFRESH[] = {
  86. {0xA2, PANEL_579C_GDEY0579F51_MO_SELECT_MASTER, 1},
  87. {0x83, PANEL_579C_GDEY0579F51_MO_WINDOW, 9},
  88. {0x50, PANEL_579C_GDEY0579F51_MO_CDI_REFRESH, 1},
  89. {0x12, PANEL_579C_GDEY0579F51_MO_REFRESH_TRIGGER, 1, /*delay_before_ms=*/0, /*delay_after_ms=*/0,
  90. /*wait_busy_after=*/true},
  91. };
  92. inline const EpdPanelDescriptor PANEL_579C_GDEY0579F51_MASTER_ONLY = {
  93. .width = 396, // WIDTH/2 of the real 792-wide panel - master half only
  94. .height = 272,
  95. .busy_active_level = false, // GxEPD2_EPD(..., /*busy_level=*/LOW, ...)
  96. .busy_timeout_ms = 25000, // full_refresh_time is 21000ms
  97. .init_sequence = PANEL_579C_GDEY0579F51_MO_INIT,
  98. .init_sequence_len = sizeof(PANEL_579C_GDEY0579F51_MO_INIT) / sizeof(PANEL_579C_GDEY0579F51_MO_INIT[0]),
  99. .window_sequence = {PANEL_579C_GDEY0579F51_MO_WINDOW_SEQ, nullptr},
  100. .window_sequence_len = {sizeof(PANEL_579C_GDEY0579F51_MO_WINDOW_SEQ) / sizeof(PANEL_579C_GDEY0579F51_MO_WINDOW_SEQ[0]),
  101. 0},
  102. .plane_count = 1,
  103. .plane_write_cmd = {0x10, 0x00},
  104. .plane_invert = {false, false},
  105. .packed_2bpp_plane = true,
  106. .refresh_sequence = PANEL_579C_GDEY0579F51_MO_REFRESH,
  107. .refresh_sequence_len = sizeof(PANEL_579C_GDEY0579F51_MO_REFRESH) / sizeof(PANEL_579C_GDEY0579F51_MO_REFRESH[0]),
  108. };
  109. } // namespace esphome::gxepd2