panel_579c_gdey0579f51.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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). The real dual-
  5. // region version, superseding panel_579c_gdey0579f51_master_only.h's
  6. // deliberate single-region simplification - uses CycleEngine's
  7. // window_per_plane mechanism to give "master" and "slave" (0xA2-select
  8. // logical regions, not separate physical CS pins) their own window-set
  9. // before each one's own 0x10 byte burst, "plane 0"/"plane 1" in the
  10. // engine's terms even though they're physical regions here, not black/red
  11. // color planes - see EpdPanelDescriptor::window_per_plane.
  12. //
  13. // Region physical placement (2026-09-19, confirmed two independent ways):
  14. // GxEPD2_579_GDEY0579T93.cpp (SSD1683, same 792x272 panel family) comments
  15. // its own master/slave split explicitly - "near connector" = slave,
  16. // "opposite to connector" = master. User independently confirmed the same
  17. // physical mapping driving this actual panel with the GDEY0213F51 driver
  18. // (same underlying chip): master = away from the FPC connector. So master
  19. // is region 0 here (window_sequence[0], written first, right after init
  20. // leaves the controller select=master already) and slave is region 1.
  21. //
  22. // The master-only descriptor's single-region run showed real, correctly-
  23. // decoded content but compressed/duplicated within half the driven
  24. // region's own width, plus noise/black bands on the untouched slave half.
  25. // The noise was explained and fixed there (0x12's refresh trigger fires a
  26. // real electrical refresh across the WHOLE panel regardless of 0xA2
  27. // select, so refreshing with slave's RAM never written "developed" its
  28. // stale/undefined content) - this descriptor writes both regions before
  29. // refreshing, which should eliminate that on its own. The duplication
  30. // artifact's cause is still unconfirmed; writing both regions may or may
  31. // not resolve it - that's what this descriptor is for finding out.
  32. #include "epd_command.h"
  33. namespace esphome::gxepd2 {
  34. inline const uint8_t PANEL_579C_GDEY0579F51_SELECT_MASTER[] = {0x01};
  35. inline const uint8_t PANEL_579C_GDEY0579F51_SELECT_SLAVE[] = {0x02};
  36. inline const uint8_t PANEL_579C_GDEY0579F51_SELECT_BOTH[] = {0x00};
  37. inline const uint8_t PANEL_579C_GDEY0579F51_PSR_MASTER[] = {0x07, 0x29};
  38. inline const uint8_t PANEL_579C_GDEY0579F51_PSR_SLAVE[] = {0x03, 0x29};
  39. inline const uint8_t PANEL_579C_GDEY0579F51_BTST[] = {0x32, 0x32, 0x32, 0x32};
  40. inline const uint8_t PANEL_579C_GDEY0579F51_TRES[] = {0x01, 0x8C, 0x01, 0x10}; // 396x272 - one region's resolution
  41. inline const uint8_t PANEL_579C_GDEY0579F51_CDI_INIT[] = {0x97};
  42. inline const uint8_t PANEL_579C_GDEY0579F51_E9[] = {0x01};
  43. inline const uint8_t PANEL_579C_GDEY0579F51_E0[] = {0x01};
  44. // _InitDisplay(): PSR written to each side individually (master and slave
  45. // scan in mirrored directions, hence different first PSR byte - 0x07 vs
  46. // 0x03), then BTST/TRES/CDI/E9/E0 written once under select=Both since
  47. // they're genuinely shared/global registers, then re-select master ready
  48. // for the first region's window-set.
  49. inline const EpdCommand PANEL_579C_GDEY0579F51_INIT[] = {
  50. {0xA2, PANEL_579C_GDEY0579F51_SELECT_MASTER, 1},
  51. {0x00, PANEL_579C_GDEY0579F51_PSR_MASTER, 2},
  52. {0xA2, PANEL_579C_GDEY0579F51_SELECT_SLAVE, 1},
  53. {0x00, PANEL_579C_GDEY0579F51_PSR_SLAVE, 2},
  54. {0xA2, PANEL_579C_GDEY0579F51_SELECT_BOTH, 1},
  55. {0x06, PANEL_579C_GDEY0579F51_BTST, 4},
  56. {0x61, PANEL_579C_GDEY0579F51_TRES, 4},
  57. {0x50, PANEL_579C_GDEY0579F51_CDI_INIT, 1},
  58. {0xE9, PANEL_579C_GDEY0579F51_E9, 1},
  59. {0xE0, PANEL_579C_GDEY0579F51_E0, 1},
  60. {0xA2, PANEL_579C_GDEY0579F51_SELECT_MASTER, 1},
  61. {0x04, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true}, // power on
  62. };
  63. // _setPartialRamAreaMaster/Slave(0, 0, 396, 272), default partial_mode=true
  64. // - both regions are the same shape, just a different select byte.
  65. inline const uint8_t PANEL_579C_GDEY0579F51_WINDOW_REGION[] = {
  66. 0x00, 0x00, // x/256, x%256 = 0
  67. 0x01, 0x8B, // xe/256, xe%256 = 395
  68. 0x00, 0x00, // y/256, y%256 = 0
  69. 0x01, 0x0F, // ye/256, ye%256 = 271
  70. 0x01,
  71. };
  72. inline const EpdCommand PANEL_579C_GDEY0579F51_WINDOW_MASTER[] = {
  73. {0xA2, PANEL_579C_GDEY0579F51_SELECT_MASTER, 1},
  74. {0x83, PANEL_579C_GDEY0579F51_WINDOW_REGION, 9},
  75. };
  76. inline const EpdCommand PANEL_579C_GDEY0579F51_WINDOW_SLAVE[] = {
  77. {0xA2, PANEL_579C_GDEY0579F51_SELECT_SLAVE, 1},
  78. {0x83, PANEL_579C_GDEY0579F51_WINDOW_REGION, 9},
  79. };
  80. // refresh(false): vendor's own _setPartialRamAreaBoth(0,0,396,272) then
  81. // _refresh(false) - select=Both is correct here (unlike the master-only
  82. // descriptor) since both regions' RAM genuinely holds real content now.
  83. inline const uint8_t PANEL_579C_GDEY0579F51_CDI_REFRESH[] = {0x37};
  84. inline const uint8_t PANEL_579C_GDEY0579F51_REFRESH_TRIGGER[] = {0x00};
  85. inline const EpdCommand PANEL_579C_GDEY0579F51_REFRESH[] = {
  86. {0xA2, PANEL_579C_GDEY0579F51_SELECT_BOTH, 1},
  87. {0x83, PANEL_579C_GDEY0579F51_WINDOW_REGION, 9},
  88. {0x50, PANEL_579C_GDEY0579F51_CDI_REFRESH, 1},
  89. {0x12, PANEL_579C_GDEY0579F51_REFRESH_TRIGGER, 1, /*delay_before_ms=*/0, /*delay_after_ms=*/0,
  90. /*wait_busy_after=*/true},
  91. };
  92. inline const EpdPanelDescriptor PANEL_579C_GDEY0579F51 = {
  93. .width = 792, // full logical panel - the canvas ESPHome draws into
  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_INIT,
  98. .init_sequence_len = sizeof(PANEL_579C_GDEY0579F51_INIT) / sizeof(PANEL_579C_GDEY0579F51_INIT[0]),
  99. .window_sequence = {PANEL_579C_GDEY0579F51_WINDOW_MASTER, PANEL_579C_GDEY0579F51_WINDOW_SLAVE},
  100. .window_sequence_len = {sizeof(PANEL_579C_GDEY0579F51_WINDOW_MASTER) / sizeof(PANEL_579C_GDEY0579F51_WINDOW_MASTER[0]),
  101. sizeof(PANEL_579C_GDEY0579F51_WINDOW_SLAVE) / sizeof(PANEL_579C_GDEY0579F51_WINDOW_SLAVE[0])},
  102. .window_per_plane = true,
  103. .plane_count = 2, // "plane" 0 = master region, "plane" 1 = slave region
  104. .plane_write_cmd = {0x10, 0x10},
  105. .plane_invert = {false, false},
  106. .plane_width = 396, // each region's own local width
  107. .packed_2bpp_plane = true,
  108. .refresh_sequence = PANEL_579C_GDEY0579F51_REFRESH,
  109. .refresh_sequence_len = sizeof(PANEL_579C_GDEY0579F51_REFRESH) / sizeof(PANEL_579C_GDEY0579F51_REFRESH[0]),
  110. };
  111. } // namespace esphome::gxepd2