panel_579c_gdey0579f51_master_only.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma once
  2. // Hand-derived from third_party/GxEPD2/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. // 0x03, not 0x07 - see panel_579c_gdey0579f51.h's header comment: this
  49. // value's SHL bit was backwards relative to Waveshare's own reference
  50. // driver for this panel (2026-09-19).
  51. inline const uint8_t PANEL_579C_GDEY0579F51_MO_PSR_MASTER[] = {0x03, 0x29};
  52. inline const uint8_t PANEL_579C_GDEY0579F51_MO_BTST[] = {0x32, 0x32, 0x32, 0x32};
  53. inline const uint8_t PANEL_579C_GDEY0579F51_MO_TRES[] = {0x01, 0x8C, 0x01, 0x10}; // 396x272
  54. inline const uint8_t PANEL_579C_GDEY0579F51_MO_CDI_INIT[] = {0x97};
  55. inline const uint8_t PANEL_579C_GDEY0579F51_MO_E9[] = {0x01};
  56. inline const uint8_t PANEL_579C_GDEY0579F51_MO_E0[] = {0x01};
  57. inline const EpdCommand PANEL_579C_GDEY0579F51_MO_INIT[] = {
  58. {0xA2, PANEL_579C_GDEY0579F51_MO_SELECT_MASTER, 1},
  59. {0x00, PANEL_579C_GDEY0579F51_MO_PSR_MASTER, 2},
  60. {0xA2, PANEL_579C_GDEY0579F51_MO_SELECT_BOTH, 1},
  61. {0x06, PANEL_579C_GDEY0579F51_MO_BTST, 4},
  62. {0x61, PANEL_579C_GDEY0579F51_MO_TRES, 4},
  63. {0x50, PANEL_579C_GDEY0579F51_MO_CDI_INIT, 1},
  64. {0xE9, PANEL_579C_GDEY0579F51_MO_E9, 1},
  65. {0xE0, PANEL_579C_GDEY0579F51_MO_E0, 1},
  66. {0xA2, PANEL_579C_GDEY0579F51_MO_SELECT_MASTER, 1},
  67. {0x04, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true}, // power on
  68. };
  69. // _setPartialRamAreaMaster(0, 0, 396, 272), default partial_mode=true.
  70. inline const uint8_t PANEL_579C_GDEY0579F51_MO_WINDOW[] = {
  71. 0x00, 0x00, // x/256, x%256 = 0
  72. 0x01, 0x8B, // xe/256, xe%256 = 395
  73. 0x00, 0x00, // y/256, y%256 = 0
  74. 0x01, 0x0F, // ye/256, ye%256 = 271
  75. 0x01,
  76. };
  77. inline const EpdCommand PANEL_579C_GDEY0579F51_MO_WINDOW_SEQ[] = {
  78. {0xA2, PANEL_579C_GDEY0579F51_MO_SELECT_MASTER, 1},
  79. {0x83, PANEL_579C_GDEY0579F51_MO_WINDOW, 9},
  80. };
  81. // refresh(false): vendor's own refresh(bool) uses _setPartialRamAreaBoth()
  82. // here, but see file header - deliberately using select=Master instead so
  83. // the 0x12 trigger's real electrical refresh never touches slave's
  84. // never-written RAM (that Both selection is what produced the noise/black
  85. // bands on the untouched half in the first hardware run).
  86. inline const uint8_t PANEL_579C_GDEY0579F51_MO_CDI_REFRESH[] = {0x37};
  87. inline const uint8_t PANEL_579C_GDEY0579F51_MO_REFRESH_TRIGGER[] = {0x00};
  88. inline const EpdCommand PANEL_579C_GDEY0579F51_MO_REFRESH[] = {
  89. {0xA2, PANEL_579C_GDEY0579F51_MO_SELECT_MASTER, 1},
  90. {0x83, PANEL_579C_GDEY0579F51_MO_WINDOW, 9},
  91. {0x50, PANEL_579C_GDEY0579F51_MO_CDI_REFRESH, 1},
  92. {0x12, PANEL_579C_GDEY0579F51_MO_REFRESH_TRIGGER, 1, /*delay_before_ms=*/0, /*delay_after_ms=*/0,
  93. /*wait_busy_after=*/true},
  94. };
  95. inline const EpdPanelDescriptor PANEL_579C_GDEY0579F51_MASTER_ONLY = {
  96. .width = 396, // WIDTH/2 of the real 792-wide panel - master half only
  97. .height = 272,
  98. .busy_active_level = false, // GxEPD2_EPD(..., /*busy_level=*/LOW, ...)
  99. .busy_timeout_ms = 25000, // full_refresh_time is 21000ms
  100. .init_sequence = PANEL_579C_GDEY0579F51_MO_INIT,
  101. .init_sequence_len = sizeof(PANEL_579C_GDEY0579F51_MO_INIT) / sizeof(PANEL_579C_GDEY0579F51_MO_INIT[0]),
  102. .window_sequence = {PANEL_579C_GDEY0579F51_MO_WINDOW_SEQ, nullptr},
  103. .window_sequence_len = {sizeof(PANEL_579C_GDEY0579F51_MO_WINDOW_SEQ) / sizeof(PANEL_579C_GDEY0579F51_MO_WINDOW_SEQ[0]),
  104. 0},
  105. .plane_count = 1,
  106. .plane_write_cmd = {0x10, 0x00},
  107. .plane_invert = {false, false},
  108. .line_order = LineOrder::PAIRED_EDGES,
  109. .bits_per_pixel = 2,
  110. .palette = GXEPD2_PALETTE_4C,
  111. .palette_len = GXEPD2_PALETTE_4C_LEN,
  112. .blank_code = 0x01,
  113. .refresh_sequence = PANEL_579C_GDEY0579F51_MO_REFRESH,
  114. .refresh_sequence_len = sizeof(PANEL_579C_GDEY0579F51_MO_REFRESH) / sizeof(PANEL_579C_GDEY0579F51_MO_REFRESH[0]),
  115. };
  116. } // namespace esphome::gxepd2