| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- #pragma once
- // GDEY0579F51 - HX8717 dual-chip, 792x272, 4-color, 2bpp packed (same
- // JD79667-family packing as GDEY029F51, see panel_290c_gdey029f51.h).
- //
- // Faithful replay of the STOCK vendored driver
- // (third_party/GxEPD2/src/epd4c/GxEPD2_579c_GDEY0579F51.{h,cpp}): init, PSR,
- // BTST, window, refresh, master/slave split and plane order all match
- // GxEPD2's own on-wire behaviour. The only non-default engine setting is
- // line_order = PAIRED_EDGES, which reproduces GxEPD2 writeNative's doubled,
- // both-edges-to-middle line emission (544 lines/region) - a general engine
- // mechanism, not a panel hack. The user confirmed GxEPD2 itself drives this
- // panel correctly when run natively, so a byte-faithful replay is correct by
- // construction.
- //
- // Every value below is stock (PSR/BTST/power-on included) - earlier hand-
- // "fixes" chasing a mirror/convergence bug turned out to be compensating for
- // drive-current starvation and the missing line_order, not a driver bug; see
- // project memory (gxepd2_579_retest_plan) for that history. Only
- // busy_timeout_ms is tuned (engine hard-aborts where GxEPD2 polls on).
- //
- // Dual-region layer assembled by hand from the driver source, per
- // CONTRIBUTING.md "Limits - True dual-region command structure": the
- // emitter's segmentation doesn't model the 0xA2 master/slave region selects.
- // Window geometry and refresh were taken from the capture (byte-exact);
- // the init below transcribes the stock _InitDisplay() directly (the emitter
- // can't recover a dual-chip init - _InitDisplay runs during the earlier
- // writeScreenBuffer clear, so nothing is left in the writeImage pre-block).
- //
- // Region mapping: master = away from the FPC connector = region 0 (written
- // first), slave = near connector = region 1 (cross-checked against
- // GxEPD2_579_GDEY0579T93.cpp's own master/slave comments). "plane 0/1" in
- // the engine's terms are these two physical regions, not color planes;
- // window_per_plane gives each its own 0xA2-select window-set before its own
- // 0x10 byte burst.
- #include "epd_command.h"
- namespace esphome::gxepd2 {
- inline const uint8_t PANEL_579C_GDEY0579F51_SELECT_MASTER[] = {0x01};
- inline const uint8_t PANEL_579C_GDEY0579F51_SELECT_SLAVE[] = {0x02};
- inline const uint8_t PANEL_579C_GDEY0579F51_SELECT_BOTH[] = {0x00};
- // Stock PSR values, matching GxEPD2's _InitDisplay() exactly: master
- // {0x07,0x29}, slave {0x03,0x29}.
- inline const uint8_t PANEL_579C_GDEY0579F51_PSR_MASTER[] = {0x07, 0x29};
- inline const uint8_t PANEL_579C_GDEY0579F51_PSR_SLAVE[] = {0x03, 0x29};
- inline const uint8_t PANEL_579C_GDEY0579F51_BTST[] = {0x32, 0x32, 0x32, 0x32};
- inline const uint8_t PANEL_579C_GDEY0579F51_TRES[] = {0x01, 0x8C, 0x01, 0x10}; // 396x272 - one region
- inline const uint8_t PANEL_579C_GDEY0579F51_CDI_INIT[] = {0x97}; // border white
- inline const uint8_t PANEL_579C_GDEY0579F51_E9[] = {0x01};
- inline const uint8_t PANEL_579C_GDEY0579F51_E0[] = {0x01};
- // Stock _InitDisplay(): PSR written to each region under its own select,
- // then BTST/TRES/CDI/E9/E0 under select=Both, then re-select MASTER and
- // power-on (0x04). This is the vendor's order and select-state exactly.
- inline const EpdCommand PANEL_579C_GDEY0579F51_INIT[] = {
- {0xA2, PANEL_579C_GDEY0579F51_SELECT_MASTER, 1},
- {0x00, PANEL_579C_GDEY0579F51_PSR_MASTER, 2},
- {0xA2, PANEL_579C_GDEY0579F51_SELECT_SLAVE, 1},
- {0x00, PANEL_579C_GDEY0579F51_PSR_SLAVE, 2},
- {0xA2, PANEL_579C_GDEY0579F51_SELECT_BOTH, 1},
- {0x06, PANEL_579C_GDEY0579F51_BTST, 4},
- {0x61, PANEL_579C_GDEY0579F51_TRES, 4},
- {0x50, PANEL_579C_GDEY0579F51_CDI_INIT, 1},
- {0xE9, PANEL_579C_GDEY0579F51_E9, 1},
- {0xE0, PANEL_579C_GDEY0579F51_E0, 1},
- {0xA2, PANEL_579C_GDEY0579F51_SELECT_MASTER, 1},
- {0x04, nullptr, 0, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true}, // power on
- };
- // _setPartialRamArea*(0, 0, 396, 272) with partial_mode=true: both regions
- // are the same shape, differing only in the 0xA2 select byte sent first.
- inline const uint8_t PANEL_579C_GDEY0579F51_WINDOW_REGION[] = {
- 0x00, 0x00, // x = 0
- 0x01, 0x8B, // x+w-1 = 395
- 0x00, 0x00, // y = 0
- 0x01, 0x0F, // y+h-1 = 271
- 0x01, // partial_mode
- };
- inline const EpdCommand PANEL_579C_GDEY0579F51_WINDOW_MASTER[] = {
- {0xA2, PANEL_579C_GDEY0579F51_SELECT_MASTER, 1},
- {0x83, PANEL_579C_GDEY0579F51_WINDOW_REGION, 9},
- };
- inline const EpdCommand PANEL_579C_GDEY0579F51_WINDOW_SLAVE[] = {
- {0xA2, PANEL_579C_GDEY0579F51_SELECT_SLAVE, 1},
- {0x83, PANEL_579C_GDEY0579F51_WINDOW_REGION, 9},
- };
- // refresh(false): stock _setPartialRamAreaBoth(0,0,396,272) then _refresh:
- // CDI 0x50=0x37 (white), then 0x12 trigger (power-on 0x04 is skipped here -
- // already on from init).
- inline const uint8_t PANEL_579C_GDEY0579F51_CDI_REFRESH[] = {0x37};
- inline const uint8_t PANEL_579C_GDEY0579F51_REFRESH_TRIGGER[] = {0x00};
- inline const EpdCommand PANEL_579C_GDEY0579F51_REFRESH[] = {
- {0xA2, PANEL_579C_GDEY0579F51_SELECT_BOTH, 1},
- {0x83, PANEL_579C_GDEY0579F51_WINDOW_REGION, 9},
- {0x50, PANEL_579C_GDEY0579F51_CDI_REFRESH, 1},
- {0x12, PANEL_579C_GDEY0579F51_REFRESH_TRIGGER, 1, /*delay_before_ms=*/0, /*delay_after_ms=*/0,
- /*wait_busy_after=*/true},
- };
- inline const uint8_t PANEL_579C_GDEY0579F51_POWER_OFF_0_02[] = {0x00};
- inline const EpdCommand PANEL_579C_GDEY0579F51_POWER_OFF[] = {
- {0x02, PANEL_579C_GDEY0579F51_POWER_OFF_0_02, 1, /*delay_before_ms=*/0, /*delay_after_ms=*/0, /*wait_busy_after=*/true},
- };
- inline const uint8_t PANEL_579C_GDEY0579F51_HIBERNATE_0_07[] = {0xA5};
- inline const EpdCommand PANEL_579C_GDEY0579F51_HIBERNATE[] = {
- {0x07, PANEL_579C_GDEY0579F51_HIBERNATE_0_07, 1},
- };
- inline const EpdPanelDescriptor PANEL_579C_GDEY0579F51 = {
- .width = 792, // full logical panel - the canvas ESPHome draws into
- .height = 272,
- .busy_active_level = false, // GxEPD2_EPD(..., /*busy_level=*/LOW, ...)
- .busy_timeout_ms = 40000, // vendor full_refresh_time is 21000ms, but it's
- // a soft estimate (GxEPD2 polls BUSY past it);
- // give a 4-color refresh real headroom before
- // the engine hard-aborts
- .init_sequence = PANEL_579C_GDEY0579F51_INIT,
- .init_sequence_len = sizeof(PANEL_579C_GDEY0579F51_INIT) / sizeof(PANEL_579C_GDEY0579F51_INIT[0]),
- // plane 0 = LEFT canvas half -> master (chip 0x01), plane 1 = RIGHT half
- // -> slave (chip 0x02), matching GxEPD2 writeNative's MasterSide/SlaveSide
- // split (left<WIDTH/2 -> master). (The 2026-10-18 detour swapped this to
- // compensate for the one-line-per-row bug; with line_order faithful it's
- // back to GxEPD2's own order.)
- .window_sequence = {PANEL_579C_GDEY0579F51_WINDOW_MASTER, PANEL_579C_GDEY0579F51_WINDOW_SLAVE},
- .window_sequence_len = {sizeof(PANEL_579C_GDEY0579F51_WINDOW_MASTER) / sizeof(PANEL_579C_GDEY0579F51_WINDOW_MASTER[0]),
- sizeof(PANEL_579C_GDEY0579F51_WINDOW_SLAVE) / sizeof(PANEL_579C_GDEY0579F51_WINDOW_SLAVE[0])},
- .window_per_plane = true,
- .plane_count = 2, // plane 0 = left half -> chip 0x01 (master); plane 1 = right half -> chip 0x02 (slave)
- .plane_write_cmd = {0x10, 0x10},
- .plane_invert = {false, false},
- .plane_width = 396, // each region's own local width
- // GxEPD2 writeNative sends each region as 544 lines (2x272) in paired
- // top/bottom-from-edges order, filling a 2x-height RAM - reproduce that
- // exactly rather than one line per row. This is what makes the stock PSR
- // and window order render correctly; the earlier swaps were compensating
- // for not doing it.
- .line_order = LineOrder::PAIRED_EDGES,
- .bits_per_pixel = 2,
- .palette = GXEPD2_PALETTE_4C,
- .palette_len = GXEPD2_PALETTE_4C_LEN,
- .blank_code = 0x01,
- .refresh_sequence = PANEL_579C_GDEY0579F51_REFRESH,
- .refresh_sequence_len = sizeof(PANEL_579C_GDEY0579F51_REFRESH) / sizeof(PANEL_579C_GDEY0579F51_REFRESH[0]),
- .power_off_sequence = PANEL_579C_GDEY0579F51_POWER_OFF,
- .power_off_sequence_len = sizeof(PANEL_579C_GDEY0579F51_POWER_OFF) / sizeof(PANEL_579C_GDEY0579F51_POWER_OFF[0]),
- .hibernate_sequence = PANEL_579C_GDEY0579F51_HIBERNATE,
- .hibernate_sequence_len = sizeof(PANEL_579C_GDEY0579F51_HIBERNATE) / sizeof(PANEL_579C_GDEY0579F51_HIBERNATE[0]),
- };
- } // namespace esphome::gxepd2
|