panel_730c_gdep073e01.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #pragma once
  2. // Captured via tools/capture.py from
  3. // third_party/GxEPD2/src/epd7c/GxEPD2_730c_GDEP073E01.{h,cpp} (GDEP073E01,
  4. // controller unknown per the vendor header comment, 800x480, 7-color
  5. // Spectra6). Init/window/refresh command sequences are observed byte-for-
  6. // byte by the emitter, not hand-transcribed.
  7. //
  8. // FIRST panel on this engine's 4bpp/7-color path (bits_per_pixel=4,
  9. // GXEPD2_PALETTE_7C was scaffolded but never consumed before this).
  10. //
  11. // Two surprises the emitter flagged / the window sweep confirmed, both
  12. // genuinely new vs. the other 4 window-encoder families already seen
  13. // (gxepd2-window-encoders memory):
  14. //
  15. // 1. Non-standard 7-color code map: this driver's own
  16. // GxEPD2_730c_GDEP073E01::_convert_to_native() remaps the wire code
  17. // AFTER the vendor's GxEPD2_7C wrapper produces the standard
  18. // black/white/green/blue/red/yellow/orange = 0..6 codes. Driving the
  19. // real wrapper (emit_palette_7c.h) and reading the wire byte - not
  20. // hand-reading the switch statement - gave the true native codes:
  21. // black=0x00, white=0x01, green=0x06, blue=0x05, red=0x03, yellow=0x02,
  22. // orange=0x04 (white stays 0x01, only the other five rotate). Encoded
  23. // below as its own palette table rather than GXEPD2_PALETTE_7C.
  24. // 2. Asymmetric window-end encoding on its single 0x83 command: X is
  25. // inclusive-end (xe = x+w-1) but Y is exclusive-end (ye = y+h, one
  26. // more than X's convention) - confirmed by sweeping 5 distinct rects
  27. // (tools/gxepd2_harness/run_730c_gdep073e01.cpp) and seeing ye = y+h
  28. // hold at every point, including non-8-aligned y. The driver's own
  29. // comment on _setPartialRamArea calls this out: "controller issue (one
  30. // more)". Captured here as plain data bytes, so the asymmetry needs no
  31. // special engine support - just don't hand-rederive this window math
  32. // for a sibling panel and assume symmetric inclusive ends.
  33. //
  34. // Single plane, single region, plain row-major writeNative addressing (no
  35. // row_interleave, no window_per_plane) - structurally the simplest shape
  36. // once the above two facts are captured correctly.
  37. #include "epd_command.h"
  38. namespace esphome::gxepd2 {
  39. inline const uint8_t PANEL_730C_GDEP073E01_CMDH[] = {0x49, 0x55, 0x20, 0x08, 0x09, 0x18};
  40. inline const uint8_t PANEL_730C_GDEP073E01_PWRR[] = {0x3F};
  41. inline const uint8_t PANEL_730C_GDEP073E01_PSR[] = {0x5F, 0x69};
  42. inline const uint8_t PANEL_730C_GDEP073E01_POFS[] = {0x00, 0x54, 0x00, 0x44};
  43. inline const uint8_t PANEL_730C_GDEP073E01_BTST1[] = {0x40, 0x1F, 0x1F, 0x2C};
  44. inline const uint8_t PANEL_730C_GDEP073E01_BTST2[] = {0x6F, 0x1F, 0x17, 0x49};
  45. inline const uint8_t PANEL_730C_GDEP073E01_BTST3[] = {0x6F, 0x1F, 0x1F, 0x22};
  46. inline const uint8_t PANEL_730C_GDEP073E01_PLL[] = {0x08};
  47. inline const uint8_t PANEL_730C_GDEP073E01_CDI[] = {0x3F};
  48. inline const uint8_t PANEL_730C_GDEP073E01_TCON[] = {0x02, 0x00};
  49. inline const uint8_t PANEL_730C_GDEP073E01_TRES[] = {0x03, 0x20, 0x01, 0xE0}; // WIDTH=800, HEIGHT=480
  50. inline const uint8_t PANEL_730C_GDEP073E01_T_VDCS[] = {0x01};
  51. inline const uint8_t PANEL_730C_GDEP073E01_PWS[] = {0x2F};
  52. inline const EpdCommand PANEL_730C_GDEP073E01_INIT[] = {
  53. {0xAA, PANEL_730C_GDEP073E01_CMDH, 6},
  54. {0x01, PANEL_730C_GDEP073E01_PWRR, 1},
  55. {0x00, PANEL_730C_GDEP073E01_PSR, 2},
  56. {0x03, PANEL_730C_GDEP073E01_POFS, 4},
  57. {0x05, PANEL_730C_GDEP073E01_BTST1, 4},
  58. {0x06, PANEL_730C_GDEP073E01_BTST2, 4},
  59. {0x08, PANEL_730C_GDEP073E01_BTST3, 4},
  60. {0x30, PANEL_730C_GDEP073E01_PLL, 1},
  61. {0x50, PANEL_730C_GDEP073E01_CDI, 1},
  62. {0x60, PANEL_730C_GDEP073E01_TCON, 2},
  63. {0x61, PANEL_730C_GDEP073E01_TRES, 4},
  64. {0x84, PANEL_730C_GDEP073E01_T_VDCS, 1},
  65. {0xE3, PANEL_730C_GDEP073E01_PWS, 1},
  66. {0x04, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true}, // power on
  67. };
  68. // _setPartialRamArea(0, 0, 800, 480): xe = x+w-1 = 799 (inclusive), but
  69. // ye = y+h = 480 (exclusive - see the file header note). Confirmed by the
  70. // 5-point window sweep, not just this one full-frame capture.
  71. inline const uint8_t PANEL_730C_GDEP073E01_WINDOW[] = {
  72. 0x00, 0x00, // x/256, x%256 = 0
  73. 0x03, 0x1F, // xe/256, xe%256 = 799
  74. 0x00, 0x00, // y/256, y%256 = 0
  75. 0x01, 0xE0, // ye/256, ye%256 = 480
  76. 0x01,
  77. };
  78. inline const EpdCommand PANEL_730C_GDEP073E01_WINDOW_SEQ[] = {
  79. {0x83, PANEL_730C_GDEP073E01_WINDOW, 9},
  80. };
  81. // _refresh(false): 0x50=0x3F, then 0x12+delay(1)+_waitWhileBusy - collapsed
  82. // into one wait_busy_after.
  83. inline const uint8_t PANEL_730C_GDEP073E01_CDI_REFRESH[] = {0x3F};
  84. inline const uint8_t PANEL_730C_GDEP073E01_REFRESH_TRIGGER[] = {0x00};
  85. inline const EpdCommand PANEL_730C_GDEP073E01_REFRESH[] = {
  86. {0x50, PANEL_730C_GDEP073E01_CDI_REFRESH, 1},
  87. {0x12, PANEL_730C_GDEP073E01_REFRESH_TRIGGER, 1, /*delay_before_ms=*/0, /*delay_after_ms=*/0,
  88. /*wait_busy_after=*/true},
  89. };
  90. // NOT GXEPD2_PALETTE_7C - see the file header. Codes observed by driving
  91. // the vendor's own GxEPD2_7C wrapper and reading the wire byte
  92. // (emit_palette_7c.h), then cross-checked against
  93. // GxEPD2_730c_GDEP073E01::_convert_to_native() in the driver source.
  94. inline const EpdPaletteEntry PANEL_730C_GDEP073E01_PALETTE[] = {
  95. {0x00, 0x00, 0x00, 0x00}, // black
  96. {0xFF, 0xFF, 0xFF, 0x01}, // white
  97. {0x00, 0xFF, 0x00, 0x06}, // green
  98. {0x00, 0x00, 0xFF, 0x05}, // blue
  99. {0xFF, 0x00, 0x00, 0x03}, // red
  100. {0xFF, 0xFF, 0x00, 0x02}, // yellow
  101. {0xFF, 0xA4, 0x00, 0x04}, // orange
  102. };
  103. inline const uint8_t PANEL_730C_GDEP073E01_PALETTE_LEN =
  104. sizeof(PANEL_730C_GDEP073E01_PALETTE) / sizeof(PANEL_730C_GDEP073E01_PALETTE[0]);
  105. inline const uint8_t PANEL_730C_GDEP073E01_POWER_OFF_0_02[] = {0x00};
  106. inline const EpdCommand PANEL_730C_GDEP073E01_POWER_OFF[] = {
  107. {0x02, PANEL_730C_GDEP073E01_POWER_OFF_0_02, 1, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true},
  108. };
  109. inline const uint8_t PANEL_730C_GDEP073E01_HIBERNATE_0_07[] = {0xA5};
  110. inline const EpdCommand PANEL_730C_GDEP073E01_HIBERNATE[] = {
  111. {0x07, PANEL_730C_GDEP073E01_HIBERNATE_0_07, 1},
  112. };
  113. inline const EpdPanelDescriptor PANEL_730C_GDEP073E01 = {
  114. .width = 800,
  115. .height = 480,
  116. .busy_active_level = false, // GxEPD2_EPD(..., /*busy_level=*/LOW, ...)
  117. .busy_timeout_ms = 60000, // full_refresh_time is 15000ms; generous diagnostic ceiling
  118. .init_sequence = PANEL_730C_GDEP073E01_INIT,
  119. .init_sequence_len = sizeof(PANEL_730C_GDEP073E01_INIT) / sizeof(PANEL_730C_GDEP073E01_INIT[0]),
  120. .window_sequence = {PANEL_730C_GDEP073E01_WINDOW_SEQ, nullptr},
  121. .window_sequence_len = {sizeof(PANEL_730C_GDEP073E01_WINDOW_SEQ) / sizeof(PANEL_730C_GDEP073E01_WINDOW_SEQ[0]), 0},
  122. .plane_count = 1,
  123. .plane_write_cmd = {0x10, 0x00},
  124. .plane_invert = {false, false},
  125. .bits_per_pixel = 4,
  126. .palette = PANEL_730C_GDEP073E01_PALETTE,
  127. .palette_len = PANEL_730C_GDEP073E01_PALETTE_LEN,
  128. .blank_code = 0x01,
  129. .refresh_sequence = PANEL_730C_GDEP073E01_REFRESH,
  130. .refresh_sequence_len = sizeof(PANEL_730C_GDEP073E01_REFRESH) / sizeof(PANEL_730C_GDEP073E01_REFRESH[0]),
  131. .power_off_sequence = PANEL_730C_GDEP073E01_POWER_OFF,
  132. .power_off_sequence_len = sizeof(PANEL_730C_GDEP073E01_POWER_OFF) / sizeof(PANEL_730C_GDEP073E01_POWER_OFF[0]),
  133. .hibernate_sequence = PANEL_730C_GDEP073E01_HIBERNATE,
  134. .hibernate_sequence_len = sizeof(PANEL_730C_GDEP073E01_HIBERNATE) / sizeof(PANEL_730C_GDEP073E01_HIBERNATE[0]),
  135. };
  136. } // namespace esphome::gxepd2