panel_213_z98c.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #pragma once
  2. // Hand-derived from vendor/src/epd3c/GxEPD2_213_Z98c.{h,cpp} (GDEY0213Z98,
  3. // SSD1680 controller, 128x250 RAM window (122 columns visible), black +
  4. // red). This is the panel actually on the bench for this first slice of the
  5. // native chunked engine; see the plan this was implemented from (and
  6. // gxepd2_task_watchdog_status in project memory) for why GxEPD2's own
  7. // control flow is being dropped in favor of just its per-panel data.
  8. #include "epd_command.h"
  9. namespace esphome::gxepd2 {
  10. // GxEPD2_213_Z98c::_InitDisplay(). Unlike GxEPD2_154_Z90c (the panel this
  11. // slice originally targeted), this controller's SWRESET is bracketed by
  12. // fixed 10ms delays rather than a busy-pin wait, and it has an extra
  13. // "Display update control" command (0x21) 154_Z90c doesn't. Minus the
  14. // trailing _setPartialRamArea() - CycleEngine's SET_WINDOW state (used for
  15. // every write, not just init) covers that.
  16. inline const uint8_t PANEL_213_Z98C_DRIVER_OUTPUT_CONTROL[] = {0xF9, 0x00, 0x00};
  17. inline const uint8_t PANEL_213_Z98C_DATA_ENTRY_MODE[] = {0x03};
  18. inline const uint8_t PANEL_213_Z98C_BORDER_WAVEFORM[] = {0x05};
  19. inline const uint8_t PANEL_213_Z98C_TEMP_SENSOR[] = {0x80};
  20. // Stock GxEPD2 vendor value. Was swapped to {0x80, 0x80} (matching the
  21. // epaper_spi reference) while chasing the solid-black/solid-red hardware
  22. // symptom - that turned out to be an unrelated bug (display.py never
  23. // wired the configured lambda to set_writer() at all, so nothing but
  24. // auto_clear's default fill ever rendered). Rolled back now that the real
  25. // cause is fixed, to test whether the stock GxEPD2 protocol works as-is
  26. // on this panel or genuinely needs epaper_spi's deviations.
  27. inline const uint8_t PANEL_213_Z98C_DISPLAY_UPDATE_CONTROL[] = {0x00, 0x80};
  28. inline const EpdCommand PANEL_213_Z98C_INIT[] = {
  29. {0x12, nullptr, 0, /*delay_before_ms=*/10, /*delay_after_ms=*/10, /*wait_busy_after=*/false}, // SWRESET
  30. {0x01, PANEL_213_Z98C_DRIVER_OUTPUT_CONTROL, 3},
  31. {0x11, PANEL_213_Z98C_DATA_ENTRY_MODE, 1},
  32. {0x3C, PANEL_213_Z98C_BORDER_WAVEFORM, 1},
  33. {0x18, PANEL_213_Z98C_TEMP_SENSOR, 1},
  34. {0x21, PANEL_213_Z98C_DISPLAY_UPDATE_CONTROL, 2},
  35. };
  36. // GxEPD2_213_Z98c::_Update_Full()/_Update_Part() - stock vendor sequence,
  37. // a single combined trigger that assumes it handles power internally.
  38. // Bracketed this with explicit power-on/off (matching epaper_spi) while
  39. // chasing the solid-black/solid-red symptom, which turned out to be
  40. // unrelated (see PANEL_213_Z98C_DISPLAY_UPDATE_CONTROL's comment). Rolled
  41. // back to the stock single-trigger sequence to test it now that the real
  42. // bug is fixed.
  43. inline const uint8_t PANEL_213_Z98C_UPDATE_MODE[] = {0xF7};
  44. inline const EpdCommand PANEL_213_Z98C_REFRESH[] = {
  45. {0x22, PANEL_213_Z98C_UPDATE_MODE, 1},
  46. {0x20, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true},
  47. };
  48. // GxEPD2_EPD::_setPartialRamArea(0, 0, WIDTH, HEIGHT) - SSD1680's
  49. // byte-column addressing (0x44's operands are RAM byte columns, not raw
  50. // pixels), no Y-reversal. Was hardcoded into CycleEngine as the assumed-
  51. // universal window layout until GxEPD2_426_GDEQ0426T82/GxEPD2_583_GDEQ0583T31
  52. // showed two other controllers do this differently - moved here as plain
  53. // descriptor data, computed for this panel's fixed 128x250 RAM window.
  54. inline const uint8_t PANEL_213_Z98C_WINDOW_X[] = {0x00, 0x0F}; // xe/8 = 127/8
  55. inline const uint8_t PANEL_213_Z98C_WINDOW_Y[] = {0x00, 0x00, 0xF9, 0x00}; // ye = 249
  56. inline const uint8_t PANEL_213_Z98C_WINDOW_XC[] = {0x00};
  57. inline const uint8_t PANEL_213_Z98C_WINDOW_YC[] = {0x00, 0x00};
  58. inline const EpdCommand PANEL_213_Z98C_WINDOW[] = {
  59. {0x44, PANEL_213_Z98C_WINDOW_X, 2},
  60. {0x45, PANEL_213_Z98C_WINDOW_Y, 4},
  61. {0x4E, PANEL_213_Z98C_WINDOW_XC, 1},
  62. {0x4F, PANEL_213_Z98C_WINDOW_YC, 2},
  63. };
  64. // full_refresh_time/partial_refresh_time from the vendor header are both
  65. // 15000ms; used as the ceiling for every busy wait in this slice, not just
  66. // the refresh one it was measured for - simpler than carrying a separate
  67. // timeout per wait site, and erring long only delays reporting a genuine
  68. // timeout, it doesn't cause one.
  69. inline const EpdPanelDescriptor PANEL_213_Z98C = {
  70. .width = 128, // RAM window width - _setPartialRamArea works in this, not WIDTH_VISIBLE (122)
  71. .height = 250,
  72. .busy_active_level = true, // GxEPD2_EPD(..., /*busy_level=*/HIGH, ...)
  73. .busy_timeout_ms = 60000, // temporarily generous - diagnosing a busy-never-clears hang, see commit message
  74. .init_sequence = PANEL_213_Z98C_INIT,
  75. .init_sequence_len = sizeof(PANEL_213_Z98C_INIT) / sizeof(PANEL_213_Z98C_INIT[0]),
  76. .window_sequence = {PANEL_213_Z98C_WINDOW, nullptr},
  77. .window_sequence_len = {sizeof(PANEL_213_Z98C_WINDOW) / sizeof(PANEL_213_Z98C_WINDOW[0]), 0},
  78. .plane_count = 2,
  79. .plane_write_cmd = {0x24, 0x26},
  80. // Stock GxEPD2 wire convention for the color plane, matched to
  81. // DISPLAY_UPDATE_CONTROL={0x00, 0x80} above: vendor's writeImage()
  82. // does _writeData(~data) where data's own "blank" default is 0xFF, so
  83. // wire 0x00 = blank/not-red there - the opposite of epaper_spi's
  84. // {0x80, 0x80} + inverted-buffer pairing. These two are coupled, not
  85. // independent facts - confirmed by testing {0x00,0x80} register with
  86. // invert=true still on: it cross-inverted (background/black text came
  87. // out red, drawn-red text came out white). invert=false here matches
  88. // this register value's actual polarity instead.
  89. .plane_invert = {false, false},
  90. .refresh_sequence = PANEL_213_Z98C_REFRESH,
  91. .refresh_sequence_len = sizeof(PANEL_213_Z98C_REFRESH) / sizeof(PANEL_213_Z98C_REFRESH[0]),
  92. };
  93. } // namespace esphome::gxepd2