panel_579c_gdey0579f51.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #pragma once
  2. // GDEY0579F51 - HX8717 dual-chip, 792x272, 4-color, 2bpp packed (same
  3. // JD79667-family packing as GDEY029F51, see panel_290c_gdey029f51.h).
  4. //
  5. // Captured from the STOCK vendored driver
  6. // (third_party/GxEPD2/src/epd4c/GxEPD2_579c_GDEY0579F51.{h,cpp}), with no
  7. // local corrections. An earlier revision of this descriptor carried
  8. // hand-"fixes" derived from Waveshare's epd5in79g.cpp (swapped master/slave
  9. // PSR, power-on under select=Both, a changed BTST) to chase mirrored text /
  10. // split geometry / a non-converging slave. Those symptoms were later traced
  11. // to DRIVE-CURRENT STARVATION on the bench MCU, not a driver bug - the same
  12. // panel + firmware renders on an adequately-powered driver board - so the
  13. // corrections were unjustified and have been dropped. This descriptor now
  14. // reproduces the stock GxEPD2 driver's own on-wire behaviour byte-for-byte.
  15. //
  16. // Dual-region layer assembled by hand from the driver source, per
  17. // CONTRIBUTING.md "Limits - True dual-region command structure": the
  18. // emitter's segmentation doesn't model the 0xA2 master/slave region selects.
  19. // Window geometry and refresh were taken from the capture (byte-exact);
  20. // the init below transcribes the stock _InitDisplay() directly (the emitter
  21. // can't recover a dual-chip init - _InitDisplay runs during the earlier
  22. // writeScreenBuffer clear, so nothing is left in the writeImage pre-block).
  23. //
  24. // Region mapping: master = away from the FPC connector = region 0 (written
  25. // first), slave = near connector = region 1 (cross-checked against
  26. // GxEPD2_579_GDEY0579T93.cpp's own master/slave comments). "plane 0/1" in
  27. // the engine's terms are these two physical regions, not color planes;
  28. // window_per_plane gives each its own 0xA2-select window-set before its own
  29. // 0x10 byte burst.
  30. #include "epd_command.h"
  31. namespace esphome::gxepd2 {
  32. inline const uint8_t PANEL_579C_GDEY0579F51_SELECT_MASTER[] = {0x01};
  33. inline const uint8_t PANEL_579C_GDEY0579F51_SELECT_SLAVE[] = {0x02};
  34. inline const uint8_t PANEL_579C_GDEY0579F51_SELECT_BOTH[] = {0x00};
  35. inline const uint8_t PANEL_579C_GDEY0579F51_PSR_MASTER[] = {0x07, 0x29};
  36. inline const uint8_t PANEL_579C_GDEY0579F51_PSR_SLAVE[] = {0x03, 0x29};
  37. inline const uint8_t PANEL_579C_GDEY0579F51_BTST[] = {0x32, 0x32, 0x32, 0x32};
  38. inline const uint8_t PANEL_579C_GDEY0579F51_TRES[] = {0x01, 0x8C, 0x01, 0x10}; // 396x272 - one region
  39. inline const uint8_t PANEL_579C_GDEY0579F51_CDI_INIT[] = {0x97}; // border white
  40. inline const uint8_t PANEL_579C_GDEY0579F51_E9[] = {0x01};
  41. inline const uint8_t PANEL_579C_GDEY0579F51_E0[] = {0x01};
  42. // Stock _InitDisplay(): PSR written to each region under its own select,
  43. // then BTST/TRES/CDI/E9/E0 under select=Both, then re-select MASTER and
  44. // power-on (0x04). This is the vendor's order and select-state exactly.
  45. inline const EpdCommand PANEL_579C_GDEY0579F51_INIT[] = {
  46. {0xA2, PANEL_579C_GDEY0579F51_SELECT_MASTER, 1},
  47. {0x00, PANEL_579C_GDEY0579F51_PSR_MASTER, 2},
  48. {0xA2, PANEL_579C_GDEY0579F51_SELECT_SLAVE, 1},
  49. {0x00, PANEL_579C_GDEY0579F51_PSR_SLAVE, 2},
  50. {0xA2, PANEL_579C_GDEY0579F51_SELECT_BOTH, 1},
  51. {0x06, PANEL_579C_GDEY0579F51_BTST, 4},
  52. {0x61, PANEL_579C_GDEY0579F51_TRES, 4},
  53. {0x50, PANEL_579C_GDEY0579F51_CDI_INIT, 1},
  54. {0xE9, PANEL_579C_GDEY0579F51_E9, 1},
  55. {0xE0, PANEL_579C_GDEY0579F51_E0, 1},
  56. {0xA2, PANEL_579C_GDEY0579F51_SELECT_MASTER, 1},
  57. {0x04, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true}, // power on
  58. };
  59. // _setPartialRamArea*(0, 0, 396, 272) with partial_mode=true: both regions
  60. // are the same shape, differing only in the 0xA2 select byte sent first.
  61. inline const uint8_t PANEL_579C_GDEY0579F51_WINDOW_REGION[] = {
  62. 0x00, 0x00, // x = 0
  63. 0x01, 0x8B, // x+w-1 = 395
  64. 0x00, 0x00, // y = 0
  65. 0x01, 0x0F, // y+h-1 = 271
  66. 0x01, // partial_mode
  67. };
  68. inline const EpdCommand PANEL_579C_GDEY0579F51_WINDOW_MASTER[] = {
  69. {0xA2, PANEL_579C_GDEY0579F51_SELECT_MASTER, 1},
  70. {0x83, PANEL_579C_GDEY0579F51_WINDOW_REGION, 9},
  71. };
  72. inline const EpdCommand PANEL_579C_GDEY0579F51_WINDOW_SLAVE[] = {
  73. {0xA2, PANEL_579C_GDEY0579F51_SELECT_SLAVE, 1},
  74. {0x83, PANEL_579C_GDEY0579F51_WINDOW_REGION, 9},
  75. };
  76. // refresh(false): stock _setPartialRamAreaBoth(0,0,396,272) then _refresh:
  77. // CDI 0x50=0x37 (white), then 0x12 trigger (power-on 0x04 is skipped here -
  78. // already on from init).
  79. inline const uint8_t PANEL_579C_GDEY0579F51_CDI_REFRESH[] = {0x37};
  80. inline const uint8_t PANEL_579C_GDEY0579F51_REFRESH_TRIGGER[] = {0x00};
  81. inline const EpdCommand PANEL_579C_GDEY0579F51_REFRESH[] = {
  82. {0xA2, PANEL_579C_GDEY0579F51_SELECT_BOTH, 1},
  83. {0x83, PANEL_579C_GDEY0579F51_WINDOW_REGION, 9},
  84. {0x50, PANEL_579C_GDEY0579F51_CDI_REFRESH, 1},
  85. {0x12, PANEL_579C_GDEY0579F51_REFRESH_TRIGGER, 1, /*delay_before_ms=*/0, /*delay_after_ms=*/0,
  86. /*wait_busy_after=*/true},
  87. };
  88. inline const EpdPanelDescriptor PANEL_579C_GDEY0579F51 = {
  89. .width = 792, // full logical panel - the canvas ESPHome draws into
  90. .height = 272,
  91. .busy_active_level = false, // GxEPD2_EPD(..., /*busy_level=*/LOW, ...)
  92. .busy_timeout_ms = 25000, // full_refresh_time is 21000ms
  93. .init_sequence = PANEL_579C_GDEY0579F51_INIT,
  94. .init_sequence_len = sizeof(PANEL_579C_GDEY0579F51_INIT) / sizeof(PANEL_579C_GDEY0579F51_INIT[0]),
  95. .window_sequence = {PANEL_579C_GDEY0579F51_WINDOW_MASTER, PANEL_579C_GDEY0579F51_WINDOW_SLAVE},
  96. .window_sequence_len = {sizeof(PANEL_579C_GDEY0579F51_WINDOW_MASTER) / sizeof(PANEL_579C_GDEY0579F51_WINDOW_MASTER[0]),
  97. sizeof(PANEL_579C_GDEY0579F51_WINDOW_SLAVE) / sizeof(PANEL_579C_GDEY0579F51_WINDOW_SLAVE[0])},
  98. .window_per_plane = true,
  99. .plane_count = 2, // "plane" 0 = master region, "plane" 1 = slave region
  100. .plane_write_cmd = {0x10, 0x10},
  101. .plane_invert = {false, false},
  102. .plane_width = 396, // each region's own local width
  103. .row_interleave = true,
  104. .bits_per_pixel = 2,
  105. .palette = GXEPD2_PALETTE_4C,
  106. .palette_len = GXEPD2_PALETTE_4C_LEN,
  107. .blank_code = 0x01,
  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