panel_213c_gdey0213f51.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #pragma once
  2. // Hand-derived from third_party/GxEPD2/src/epd4c/GxEPD2_213c_GDEY0213F51.{h,cpp}
  3. // (GDEY0213F51, JD79661 controller, 128x250 buffer / 122x250 visible,
  4. // 4-color BWRY). Same Good Display 4-color command template as
  5. // panel_290c_gdey029f51.h (JD79667) - the _InitDisplay() command sequence is
  6. // byte-for-byte identical except TRES (0x61, the resolution), so this is the
  7. // 290c descriptor retargeted to 128x250. See panel_290c_gdey029f51.h for the
  8. // per-command rationale (0x00 PSR / 0x01 PWRR / 0x03 POFS / 0x06 BTST / 0x50
  9. // CDI / 0x60 TCON / 0x61 TRES / 0x83 window-set / refresh via 0x50+0x12), and
  10. // GxEPD2Display::draw_packed_ for the 2bpp/4-pixels-per-byte buffer side.
  11. //
  12. // Pixel codes black=0x00, white=0x01, yellow=0x02, red=0x03 (GXEPD2_PALETTE_4C,
  13. // per GxEPD2_4C.h color4()); the vendor's own white clear writes 0x55 (code
  14. // 0x01 x4), confirming white=0x01. JD79661 vs JD79667 could in principle order
  15. // yellow/red differently - the bit-depth-aware test pattern's color bars will
  16. // show it directly if so, and only the palette codes would need swapping.
  17. //
  18. // NOTE: bench hardware is marked GDEY0213F52 (a V2 revision); this descriptor
  19. // is the F51 vendor driver, tried on F52 as a starting point pending a
  20. // datasheet/product-page diff. Same label (0213F52 vs 0213F51) aside, if the
  21. // F52 needs init tweaks they go in a separate descriptor.
  22. #include "epd_command.h"
  23. namespace esphome::gxepd2 {
  24. inline const uint8_t PANEL_213C_GDEY0213F51_CMD_4D[] = {0x78};
  25. inline const uint8_t PANEL_213C_GDEY0213F51_PSR[] = {0x0F, 0x29};
  26. inline const uint8_t PANEL_213C_GDEY0213F51_PWRR[] = {0x07, 0x00};
  27. inline const uint8_t PANEL_213C_GDEY0213F51_POFS[] = {0x10, 0x54, 0x44};
  28. inline const uint8_t PANEL_213C_GDEY0213F51_BTST[] = {0x05, 0x00, 0x3F, 0x0A, 0x25, 0x12, 0x1A};
  29. inline const uint8_t PANEL_213C_GDEY0213F51_CDI[] = {0x37};
  30. inline const uint8_t PANEL_213C_GDEY0213F51_TCON[] = {0x02, 0x02};
  31. inline const uint8_t PANEL_213C_GDEY0213F51_TRES[] = {0x00, 0x80, 0x00, 0xFA}; // WIDTH=128, HEIGHT=250
  32. inline const uint8_t PANEL_213C_GDEY0213F51_E7[] = {0x1C};
  33. inline const uint8_t PANEL_213C_GDEY0213F51_PWS[] = {0x22};
  34. inline const uint8_t PANEL_213C_GDEY0213F51_LVD[] = {0xD0};
  35. inline const uint8_t PANEL_213C_GDEY0213F51_B5[] = {0x03};
  36. inline const uint8_t PANEL_213C_GDEY0213F51_E9[] = {0x01};
  37. inline const uint8_t PANEL_213C_GDEY0213F51_PLL[] = {0x08};
  38. inline const EpdCommand PANEL_213C_GDEY0213F51_INIT[] = {
  39. {0x4D, PANEL_213C_GDEY0213F51_CMD_4D, 1},
  40. {0x00, PANEL_213C_GDEY0213F51_PSR, 2},
  41. {0x01, PANEL_213C_GDEY0213F51_PWRR, 2},
  42. {0x03, PANEL_213C_GDEY0213F51_POFS, 3},
  43. {0x06, PANEL_213C_GDEY0213F51_BTST, 7},
  44. {0x50, PANEL_213C_GDEY0213F51_CDI, 1},
  45. {0x60, PANEL_213C_GDEY0213F51_TCON, 2},
  46. {0x61, PANEL_213C_GDEY0213F51_TRES, 4},
  47. {0xE7, PANEL_213C_GDEY0213F51_E7, 1},
  48. {0xE3, PANEL_213C_GDEY0213F51_PWS, 1},
  49. {0xB4, PANEL_213C_GDEY0213F51_LVD, 1},
  50. {0xB5, PANEL_213C_GDEY0213F51_B5, 1},
  51. {0xE9, PANEL_213C_GDEY0213F51_E9, 1},
  52. {0x30, PANEL_213C_GDEY0213F51_PLL, 1},
  53. {0x04, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true}, // power on
  54. };
  55. // _setPartialRamArea(0, 0, 128, 250), default partial_mode=true.
  56. inline const uint8_t PANEL_213C_GDEY0213F51_WINDOW[] = {
  57. 0x00, 0x00, // x/256, x%256 = 0
  58. 0x00, 0x7F, // xe/256, xe%256 = 127
  59. 0x00, 0x00, // y/256, y%256 = 0
  60. 0x00, 0xF9, // ye/256, ye%256 = 249
  61. 0x01,
  62. };
  63. inline const EpdCommand PANEL_213C_GDEY0213F51_WINDOW_SEQ[] = {
  64. {0x83, PANEL_213C_GDEY0213F51_WINDOW, 9},
  65. };
  66. // _refresh(false): 0x50=0x37 (white/non-floating border), then 0x12+delay(1)+
  67. // _waitWhileBusy - collapsed into one wait_busy_after.
  68. inline const uint8_t PANEL_213C_GDEY0213F51_CDI_REFRESH[] = {0x37};
  69. inline const uint8_t PANEL_213C_GDEY0213F51_REFRESH_TRIGGER[] = {0x00};
  70. inline const EpdCommand PANEL_213C_GDEY0213F51_REFRESH[] = {
  71. {0x50, PANEL_213C_GDEY0213F51_CDI_REFRESH, 1},
  72. {0x12, PANEL_213C_GDEY0213F51_REFRESH_TRIGGER, 1, /*delay_before_ms=*/0, /*delay_after_ms=*/0,
  73. /*wait_busy_after=*/true},
  74. };
  75. inline const uint8_t PANEL_213C_GDEY0213F51_POWER_OFF_0_02[] = {0x00};
  76. inline const EpdCommand PANEL_213C_GDEY0213F51_POWER_OFF[] = {
  77. {0x02, PANEL_213C_GDEY0213F51_POWER_OFF_0_02, 1, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true},
  78. };
  79. inline const uint8_t PANEL_213C_GDEY0213F51_HIBERNATE_0_07[] = {0xA5};
  80. inline const EpdCommand PANEL_213C_GDEY0213F51_HIBERNATE[] = {
  81. {0x07, PANEL_213C_GDEY0213F51_HIBERNATE_0_07, 1},
  82. };
  83. inline const EpdPanelDescriptor PANEL_213C_GDEY0213F51 = {
  84. .width = 128,
  85. .height = 250,
  86. .busy_active_level = false, // GxEPD2_EPD(..., /*busy_level=*/LOW, ...)
  87. .busy_timeout_ms = 30000, // full_refresh_time is 25000ms
  88. .init_sequence = PANEL_213C_GDEY0213F51_INIT,
  89. .init_sequence_len = sizeof(PANEL_213C_GDEY0213F51_INIT) / sizeof(PANEL_213C_GDEY0213F51_INIT[0]),
  90. .window_sequence = {PANEL_213C_GDEY0213F51_WINDOW_SEQ, nullptr},
  91. .window_sequence_len = {sizeof(PANEL_213C_GDEY0213F51_WINDOW_SEQ) / sizeof(PANEL_213C_GDEY0213F51_WINDOW_SEQ[0]), 0},
  92. .plane_count = 1,
  93. .plane_write_cmd = {0x10, 0x00},
  94. .plane_invert = {false, false},
  95. .bits_per_pixel = 2,
  96. .palette = GXEPD2_PALETTE_4C,
  97. .palette_len = GXEPD2_PALETTE_4C_LEN,
  98. .blank_code = 0x01,
  99. .refresh_sequence = PANEL_213C_GDEY0213F51_REFRESH,
  100. .refresh_sequence_len = sizeof(PANEL_213C_GDEY0213F51_REFRESH) / sizeof(PANEL_213C_GDEY0213F51_REFRESH[0]),
  101. .power_off_sequence = PANEL_213C_GDEY0213F51_POWER_OFF,
  102. .power_off_sequence_len = sizeof(PANEL_213C_GDEY0213F51_POWER_OFF) / sizeof(PANEL_213C_GDEY0213F51_POWER_OFF[0]),
  103. .hibernate_sequence = PANEL_213C_GDEY0213F51_HIBERNATE,
  104. .hibernate_sequence_len = sizeof(PANEL_213C_GDEY0213F51_HIBERNATE) / sizeof(PANEL_213C_GDEY0213F51_HIBERNATE[0]),
  105. };
  106. } // namespace esphome::gxepd2