From f04087dfd6337ed3761ca8e0d4a6e32ba717aedd Mon Sep 17 00:00:00 2001 From: ainyan03 Date: Sun, 16 Aug 2026 13:56:25 +0000 Subject: [PATCH] AtomS3R: re-probe the panel ID at low clock speed before giving up Some GC9107 batches return a valid ID over the RDDID command only at low clock rates; at the 8 MHz probe speed the readout is garbage, so autodetect rejected the panel and the unit appeared dead (issue #222). When the first probe matches neither known ID, re-probe once at 100 kHz. Verified on a healthy GC9107 unit that the 100 kHz readout returns the correct ID (0x079100), and on both GC9107 and ST7735 units that the normal first-probe path is unchanged. The ST7735 does not answer the RDDID readout at low clock rates at all (verified: 0xFFFFFFFF at 1 MHz and below, correct at 8 MHz), so the slow retry cannot misidentify it; a healthy ST7735 has already been caught by the first probe. --- src/M5GFX.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/M5GFX.cpp b/src/M5GFX.cpp index ccfd0b8..f6f3bac 100644 --- a/src/M5GFX.cpp +++ b/src/M5GFX.cpp @@ -2760,6 +2760,24 @@ The usage of each pin is as follows. bool is_st7735 = ((id & 0xFFFF) == 0x7683 || (id & 0xFFFF) == 0x897C); bool is_gc9107 = (id & 0xFFFFFF) == 0x079100; // ESP_LOGI(LIBRARY_NAME, "[Autodetect] panel_id: 0x%08x", id); + if (!is_st7735 && !is_gc9107) + { // Some GC9107 batches return a valid ID only at low clock rates; + // re-probe slowly before giving up. + // (ST7735 does not answer at this rate, but a healthy one has + // already been caught by the first probe above.) + bus_spi->release(); + bus_cfg.freq_write = 100000; + bus_cfg.freq_read = 100000; + bus_spi->config(bus_cfg); + bus_spi->init(); + id = _read_panel_id(bus_spi, GPIO_NUM_14); + // restore the probe speed in bus_cfg: later board probes reuse it + // without setting the frequency themselves. + bus_cfg.freq_write = 8000000; + bus_cfg.freq_read = 8000000; + is_st7735 = ((id & 0xFFFF) == 0x7683 || (id & 0xFFFF) == 0x897C); + is_gc9107 = (id & 0xFFFFFF) == 0x079100; + } if (is_st7735 || is_gc9107) { board = board_t::board_M5AtomS3R;