panel_290c_gdey029f51.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #pragma once
  2. // Hand-derived from third_party/GxEPD2/src/epd4c/GxEPD2_290c_GDEY029F51.{h,cpp}
  3. // (GDEY029F51, JD79667 controller, 128x296, 4-color BWRY panel used here as
  4. // black/white/red via the black+color buffer interface). First panel on a
  5. // completely different command set from the SSD1680/1677/UC8179 mono
  6. // panels (0x00 PSR, 0x01 PWRR, 0x03 POFS, 0x06 BTST, 0x50 CDI, 0x60 TCON,
  7. // 0x61 TRES, 0x83 window-set, refresh via 0x50+0x12) and, more importantly,
  8. // a fundamentally different pixel format: 2 bits/pixel, 4 pixels/byte
  9. // (black=0x00, white=0x01, yellow=0x02, red=0x03 per GxEPD2_4C.h color4()),
  10. // not 1-bit-per-pixel planes - see EpdPanelDescriptor::bits_per_pixel /
  11. // palette and GxEPD2Display's draw_packed_() for the buffer-side half.
  12. //
  13. // _InitDisplay()'s reset pulse is itself gated on `_hibernating ||
  14. // _initial_write` in the vendor driver (steady-state cycles skip the
  15. // physical RST and go straight to re-issuing the command sequence) - this
  16. // engine always does a real hardware reset every cycle regardless (see
  17. // CycleEngine::request_full_update()), a superset of what the vendor
  18. // driver does on its own first cycle, so no special-casing needed here.
  19. #include "epd_command.h"
  20. namespace esphome::gxepd2 {
  21. inline const uint8_t PANEL_290C_GDEY029F51_CMD_4D[] = {0x78};
  22. inline const uint8_t PANEL_290C_GDEY029F51_PSR[] = {0x0F, 0x29};
  23. inline const uint8_t PANEL_290C_GDEY029F51_PWRR[] = {0x07, 0x00};
  24. inline const uint8_t PANEL_290C_GDEY029F51_POFS[] = {0x10, 0x54, 0x44};
  25. inline const uint8_t PANEL_290C_GDEY029F51_BTST[] = {0x05, 0x00, 0x3F, 0x0A, 0x25, 0x12, 0x1A};
  26. inline const uint8_t PANEL_290C_GDEY029F51_CDI[] = {0x37};
  27. inline const uint8_t PANEL_290C_GDEY029F51_TCON[] = {0x02, 0x02};
  28. inline const uint8_t PANEL_290C_GDEY029F51_TRES[] = {0x00, 0x80, 0x01, 0x28}; // WIDTH=128, HEIGHT=296
  29. inline const uint8_t PANEL_290C_GDEY029F51_E7[] = {0x1C};
  30. inline const uint8_t PANEL_290C_GDEY029F51_PWS[] = {0x22};
  31. inline const uint8_t PANEL_290C_GDEY029F51_LVD[] = {0xD0};
  32. inline const uint8_t PANEL_290C_GDEY029F51_B5[] = {0x03};
  33. inline const uint8_t PANEL_290C_GDEY029F51_E9[] = {0x01};
  34. inline const uint8_t PANEL_290C_GDEY029F51_PLL[] = {0x08};
  35. inline const EpdCommand PANEL_290C_GDEY029F51_INIT[] = {
  36. {0x4D, PANEL_290C_GDEY029F51_CMD_4D, 1},
  37. {0x00, PANEL_290C_GDEY029F51_PSR, 2},
  38. {0x01, PANEL_290C_GDEY029F51_PWRR, 2},
  39. {0x03, PANEL_290C_GDEY029F51_POFS, 3},
  40. {0x06, PANEL_290C_GDEY029F51_BTST, 7},
  41. {0x50, PANEL_290C_GDEY029F51_CDI, 1},
  42. {0x60, PANEL_290C_GDEY029F51_TCON, 2},
  43. {0x61, PANEL_290C_GDEY029F51_TRES, 4},
  44. {0xE7, PANEL_290C_GDEY029F51_E7, 1},
  45. {0xE3, PANEL_290C_GDEY029F51_PWS, 1},
  46. {0xB4, PANEL_290C_GDEY029F51_LVD, 1},
  47. {0xB5, PANEL_290C_GDEY029F51_B5, 1},
  48. {0xE9, PANEL_290C_GDEY029F51_E9, 1},
  49. {0x30, PANEL_290C_GDEY029F51_PLL, 1},
  50. {0x04, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true}, // power on
  51. };
  52. // _setPartialRamArea(0, 0, 128, 296), default partial_mode=true.
  53. inline const uint8_t PANEL_290C_GDEY029F51_WINDOW[] = {
  54. 0x00, 0x00, // x/256, x%256 = 0
  55. 0x00, 0x7F, // xe/256, xe%256 = 127
  56. 0x00, 0x00, // y/256, y%256 = 0
  57. 0x01, 0x27, // ye/256, ye%256 = 295
  58. 0x01,
  59. };
  60. inline const EpdCommand PANEL_290C_GDEY029F51_WINDOW_SEQ[] = {
  61. {0x83, PANEL_290C_GDEY029F51_WINDOW, 9},
  62. };
  63. // _refresh(false): 0x50=0x37 (white/non-floating border, not partial),
  64. // then 0x12+delay(1)+_waitWhileBusy - collapsed into one wait_busy_after.
  65. inline const uint8_t PANEL_290C_GDEY029F51_CDI_REFRESH[] = {0x37};
  66. inline const uint8_t PANEL_290C_GDEY029F51_REFRESH_TRIGGER[] = {0x00};
  67. inline const EpdCommand PANEL_290C_GDEY029F51_REFRESH[] = {
  68. {0x50, PANEL_290C_GDEY029F51_CDI_REFRESH, 1},
  69. {0x12, PANEL_290C_GDEY029F51_REFRESH_TRIGGER, 1, /*delay_before_ms=*/0, /*delay_after_ms=*/0,
  70. /*wait_busy_after=*/true},
  71. };
  72. inline const EpdPanelDescriptor PANEL_290C_GDEY029F51 = {
  73. .width = 128,
  74. .height = 296,
  75. .busy_active_level = false, // GxEPD2_EPD(..., /*busy_level=*/LOW, ...)
  76. .busy_timeout_ms = 30000, // full_refresh_time is 25000ms
  77. .init_sequence = PANEL_290C_GDEY029F51_INIT,
  78. .init_sequence_len = sizeof(PANEL_290C_GDEY029F51_INIT) / sizeof(PANEL_290C_GDEY029F51_INIT[0]),
  79. .window_sequence = {PANEL_290C_GDEY029F51_WINDOW_SEQ, nullptr},
  80. .window_sequence_len = {sizeof(PANEL_290C_GDEY029F51_WINDOW_SEQ) / sizeof(PANEL_290C_GDEY029F51_WINDOW_SEQ[0]), 0},
  81. .plane_count = 1,
  82. .plane_write_cmd = {0x10, 0x00},
  83. .plane_invert = {false, false},
  84. .bits_per_pixel = 2,
  85. .palette = GXEPD2_PALETTE_4C,
  86. .palette_len = GXEPD2_PALETTE_4C_LEN,
  87. .blank_code = 0x01,
  88. .refresh_sequence = PANEL_290C_GDEY029F51_REFRESH,
  89. .refresh_sequence_len = sizeof(PANEL_290C_GDEY029F51_REFRESH) / sizeof(PANEL_290C_GDEY029F51_REFRESH[0]),
  90. };
  91. } // namespace esphome::gxepd2