panel_583_gdeq0583t31.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #pragma once
  2. // Hand-derived from third_party/GxEPD2/src/gdeq/GxEPD2_583_GDEQ0583T31.{h,cpp}
  3. // (GDEQ0583T31, UC8179 controller, 648x480, monochrome).
  4. //
  5. // Structurally the oddest of the panels covered so far: UC8179 has no
  6. // SSD1680/1677-style 0x44/0x45/0x4E/0x4F window registers at all - a single
  7. // 0x90 command carries the whole region, bracketed by 0x91 "partial in" /
  8. // 0x92 "partial out" markers that live *around* the plane write, not just
  9. // before it. 0x91+0x90 fits this engine's existing window_sequence slot
  10. // fine; 0x92 has nowhere else to go but the front of refresh_sequence,
  11. // since it must fire after the plane byte burst and before the refresh
  12. // trigger, and those are the only two sequence slots this engine has.
  13. //
  14. // Also the only panel here where _InitDisplay() (0x00 panel setting + 0x50
  15. // VCOM/data-interval) genuinely runs twice in one real update cycle even
  16. // with GxEPD2's own priming dropped: the vendor driver's _using_partial_mode
  17. // flag flips between _Init_Part() (before the write, TSSET=0x6E) and
  18. // _Init_Full() (before the refresh trigger, TSSET=0x5A) on *every* call, not
  19. // just the first - confirmed by reading refresh()/writeImage() themselves,
  20. // not just the traced first call. This engine has no persistent
  21. // _using_partial_mode to skip either pass, and resets the panel via a real
  22. // hardware reset pulse every cycle anyway (see CycleEngine's
  23. // request_full_update()), so re-running both init variants every time
  24. // matches the vendor driver's own behavior under that same "always reset,
  25. // never assume prior state" model, not a shortcut around it.
  26. #include "epd_command.h"
  27. namespace esphome::gxepd2 {
  28. inline const uint8_t PANEL_583_GDEQ0583T31_PANEL_SETTING[] = {0x1F};
  29. inline const uint8_t PANEL_583_GDEQ0583T31_VCOM_DATA_INTERVAL[] = {0x29, 0x07};
  30. inline const uint8_t PANEL_583_GDEQ0583T31_CASCADE_SETTING[] = {0x02};
  31. inline const uint8_t PANEL_583_GDEQ0583T31_TEMP_PARTIAL[] = {0x6E}; // TSSET, _Init_Part's value (110)
  32. inline const EpdCommand PANEL_583_GDEQ0583T31_INIT[] = {
  33. // _Init_Part(): _InitDisplay() + cascade/temp-force + _PowerOn().
  34. {0x00, PANEL_583_GDEQ0583T31_PANEL_SETTING, 1},
  35. {0x50, PANEL_583_GDEQ0583T31_VCOM_DATA_INTERVAL, 2},
  36. {0xE0, PANEL_583_GDEQ0583T31_CASCADE_SETTING, 1},
  37. {0xE5, PANEL_583_GDEQ0583T31_TEMP_PARTIAL, 1},
  38. {0x04, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true}, // power on
  39. };
  40. // _setPartialRamArea(0, 0, 648, 480): xe = (0+648-1)|0x0007 = 647 (already
  41. // byte-boundary inclusive - 647 % 8 == 7), ye = 479; x masked to byte
  42. // boundary is 0 either way. First pass wrote xe%256 as 0x8F (655) instead
  43. // of 0x87 (647) - an 8-column-too-wide window that shifted each row's data
  44. // by a byte relative to the next, hardware-confirmed as diagonal smear/
  45. // noise rather than a clean image (2026-09-19).
  46. inline const uint8_t PANEL_583_GDEQ0583T31_WINDOW_REGION[] = {
  47. 0x00, 0x00, // x/256, x%256 = 0, 0
  48. 0x02, 0x87, // xe/256, xe%256 = 647
  49. 0x00, 0x00, // y/256, y%256 = 0, 0
  50. 0x01, 0xDF, // ye/256, ye%256 = 479
  51. 0x01,
  52. };
  53. inline const EpdCommand PANEL_583_GDEQ0583T31_WINDOW[] = {
  54. {0x91, nullptr, 0}, // partial in
  55. {0x90, PANEL_583_GDEQ0583T31_WINDOW_REGION, 9},
  56. };
  57. // _Init_Full() + _Update_Full(): cascade/temp-force (full-context value)
  58. // re-run before the trigger, matching what the vendor driver actually does
  59. // on every call (see file header comment) - then 0x92 "partial out" closes
  60. // the window this engine's window_sequence opened, since it has to fire
  61. // after the plane write and there's no other slot for it.
  62. inline const uint8_t PANEL_583_GDEQ0583T31_TEMP_FULL[] = {0x5A}; // TSSET, _Init_Full's value (90)
  63. inline const EpdCommand PANEL_583_GDEQ0583T31_REFRESH[] = {
  64. {0x92, nullptr, 0}, // partial out
  65. {0x00, PANEL_583_GDEQ0583T31_PANEL_SETTING, 1},
  66. {0x50, PANEL_583_GDEQ0583T31_VCOM_DATA_INTERVAL, 2},
  67. {0xE0, PANEL_583_GDEQ0583T31_CASCADE_SETTING, 1},
  68. {0xE5, PANEL_583_GDEQ0583T31_TEMP_FULL, 1},
  69. {0x12, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true}, // display refresh
  70. };
  71. inline const EpdCommand PANEL_583_GDEQ0583T31_POWER_OFF[] = {
  72. {0x02, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true},
  73. };
  74. inline const uint8_t PANEL_583_GDEQ0583T31_HIBERNATE_0_07[] = {0xA5};
  75. inline const EpdCommand PANEL_583_GDEQ0583T31_HIBERNATE[] = {
  76. {0x07, PANEL_583_GDEQ0583T31_HIBERNATE_0_07, 1},
  77. };
  78. inline const EpdPanelDescriptor PANEL_583_GDEQ0583T31 = {
  79. .width = 648,
  80. .height = 480,
  81. .busy_active_level = false, // GxEPD2_EPD(..., /*busy_level=*/LOW, ...) - inverted vs. the SSD1677/1680 panels
  82. .busy_timeout_ms = 20000, // full_refresh_time is 1200ms; generous ceiling, matches PANEL_213_Z98C's style
  83. .init_sequence = PANEL_583_GDEQ0583T31_INIT,
  84. .init_sequence_len = sizeof(PANEL_583_GDEQ0583T31_INIT) / sizeof(PANEL_583_GDEQ0583T31_INIT[0]),
  85. .window_sequence = {PANEL_583_GDEQ0583T31_WINDOW, nullptr},
  86. .window_sequence_len = {sizeof(PANEL_583_GDEQ0583T31_WINDOW) / sizeof(PANEL_583_GDEQ0583T31_WINDOW[0]), 0},
  87. .plane_count = 1,
  88. .plane_write_cmd = {0x13, 0x00},
  89. .plane_write_cmd_for_full_refresh = {0x10, 0x00}, // writeImageForFullRefresh also re-writes this "previous RAM" bank before the 0x13 write above - not read by this full-refresh-only engine yet, captured for future partial-refresh use
  90. .plane_invert = {false, false},
  91. .refresh_sequence = PANEL_583_GDEQ0583T31_REFRESH,
  92. .refresh_sequence_len = sizeof(PANEL_583_GDEQ0583T31_REFRESH) / sizeof(PANEL_583_GDEQ0583T31_REFRESH[0]),
  93. .power_off_sequence = PANEL_583_GDEQ0583T31_POWER_OFF,
  94. .power_off_sequence_len = sizeof(PANEL_583_GDEQ0583T31_POWER_OFF) / sizeof(PANEL_583_GDEQ0583T31_POWER_OFF[0]),
  95. .hibernate_sequence = PANEL_583_GDEQ0583T31_HIBERNATE,
  96. .hibernate_sequence_len = sizeof(PANEL_583_GDEQ0583T31_HIBERNATE) / sizeof(PANEL_583_GDEQ0583T31_HIBERNATE[0]),
  97. };
  98. } // namespace esphome::gxepd2