From 2d1d2682fc48e19529dfff5a64010b3840b9acb5 Mon Sep 17 00:00:00 2001 From: ainyan03 Date: Sun, 16 Aug 2026 03:04:58 +0000 Subject: [PATCH 1/2] Remove the OPI-PSRAM requirement from the M5StopWatch detection Panel_CO5300 supports direct drawing: the optional PSRAM frame buffer (initPanelFb) may fail to allocate and is not required, so the PSRAM guard (introduced alongside the EPD boards, which genuinely need the buffer) is unnecessary here. Worse, with PSRAM disabled the guard skipped the panel setup after the board had already been identified, and the autodetection then fell through and misidentified the device as an AtomS3Lite. Direct drawing has a limitation: drawing whose origin is at an odd coordinate may render incorrectly, so a warning is logged when the build lacks OPI-PSRAM. Verified on the real device: with PSRAM disabled the board is now detected as M5StopWatch and the display works via direct drawing; builds with and without OPI-PSRAM are both green. --- src/M5GFX.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/M5GFX.cpp b/src/M5GFX.cpp index b704c71..0ffbd02 100644 --- a/src/M5GFX.cpp +++ b/src/M5GFX.cpp @@ -1888,11 +1888,14 @@ namespace m5gfx board = board_t::board_M5StopWatch; ESP_LOGI(LIBRARY_NAME, "[Autodetect] board_M5StopWatch"); -#if !(defined(CONFIG_ESP32S3_SPIRAM_SUPPORT)) - ESP_LOGE(LIBRARY_NAME, "M5StopWatch need OPI-PSRAM enabled"); -#elif !defined (CONFIG_SPIRAM_MODE_OCT) - ESP_LOGE(LIBRARY_NAME, "M5StopWatch need OPI-PSRAM enabled"); -#else + // Panel_CO5300 supports direct drawing; the optional PSRAM frame + // buffer (initPanelFb) may fail to allocate and is not required, + // so no PSRAM requirement applies here (unlike the EPD boards). +#if !(defined(CONFIG_ESP32S3_SPIRAM_SUPPORT)) || !defined (CONFIG_SPIRAM_MODE_OCT) + // Without the frame buffer, drawing whose origin is at an odd + // coordinate may render incorrectly (this affects e.g. text glyphs). + ESP_LOGW(LIBRARY_NAME, "M5StopWatch: OPI-PSRAM is disabled; the display falls back to direct drawing, which may render incorrectly when the drawing origin is at an odd coordinate. Enable OPI-PSRAM for correct rendering."); +#endif // GPIO39:OLED CS Pin lgfx::pinMode(GPIO_NUM_39, lgfx::pin_mode_t::output); @@ -1983,7 +1986,6 @@ namespace m5gfx } goto init_clear; -#endif } if (is_papermono) { From 12002e98f6b6514f5d301f7f5a61986f3da04416 Mon Sep 17 00:00:00 2001 From: ainyan03 Date: Sun, 16 Aug 2026 03:38:36 +0000 Subject: [PATCH 2/2] Keep the board identification when the EPD boards lack OPI-PSRAM When PSRAM was disabled in the build, the EPD board blocks (PaperMono, PaperS3/PaperDIY, PaperColor, ChainCaptain) logged the requirement but skipped the panel setup and fell through the rest of the autodetection, which ended with board_unknown and let the caller misidentify the device as a display-less model. Jump to init_clear instead so the board identification is kept; the display simply stays unavailable. Clear _panel_last and _touch_last before the jump: autodetect() only detaches the active panel at entry, so a stale panel object from a previous detection round would otherwise be re-attached at init_clear. --- src/M5GFX.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/M5GFX.cpp b/src/M5GFX.cpp index 0ffbd02..830fac7 100644 --- a/src/M5GFX.cpp +++ b/src/M5GFX.cpp @@ -1994,8 +1994,14 @@ namespace m5gfx #if !(defined(CONFIG_ESP32S3_SPIRAM_SUPPORT)) ESP_LOGE(LIBRARY_NAME, "M5PaperMono need OPI-PSRAM enabled"); + _panel_last.reset(); + _touch_last.reset(); + goto init_clear; // keep the board identification; the display stays unavailable #elif !defined (CONFIG_SPIRAM_MODE_OCT) ESP_LOGE(LIBRARY_NAME, "M5PaperMono need OPI-PSRAM enabled"); + _panel_last.reset(); + _touch_last.reset(); + goto init_clear; // keep the board identification; the display stays unavailable #else // GPIO16:EINK CS Pin @@ -2104,8 +2110,14 @@ namespace m5gfx #if !(defined(CONFIG_ESP32S3_SPIRAM_SUPPORT)) ESP_LOGE(LIBRARY_NAME, "M5ChainCaptain needs OPI-PSRAM enabled"); + _panel_last.reset(); + _touch_last.reset(); + goto init_clear; // keep the board identification; the display stays unavailable #elif !defined (CONFIG_SPIRAM_MODE_OCT) ESP_LOGE(LIBRARY_NAME, "M5ChainCaptain needs OPI-PSRAM enabled"); + _panel_last.reset(); + _touch_last.reset(); + goto init_clear; // keep the board identification; the display stays unavailable #else // M5PM1 and M5IOE1 may retain their idle-sleep settings across battery-powered shutdown. lgfx::i2c::writeRegister8(i2c_port, m5pm1_i2c_addr, 0x09, 0x00, 0, m5pm1_i2c_freq); @@ -2187,8 +2199,14 @@ namespace m5gfx #if !(defined(CONFIG_ESP32S3_SPIRAM_SUPPORT)) ESP_LOGE(LIBRARY_NAME, "M5PaperColor need OPI-PSRAM enabled"); + _panel_last.reset(); + _touch_last.reset(); + goto init_clear; // keep the board identification; the display stays unavailable #elif !defined (CONFIG_SPIRAM_MODE_OCT) ESP_LOGE(LIBRARY_NAME, "M5PaperColor need OPI-PSRAM enabled"); + _panel_last.reset(); + _touch_last.reset(); + goto init_clear; // keep the board identification; the display stays unavailable #else // Disable watchdog (WDT_CNT=0 disables) lgfx::i2c::writeRegister8(i2c_port, m5pm1_i2c_addr, 0x0A, 0x00, 0x00, m5pm1_i2c_freq); @@ -2313,8 +2331,14 @@ namespace m5gfx #if !(defined(CONFIG_ESP32S3_SPIRAM_SUPPORT)) ESP_LOGE(LIBRARY_NAME, "%s need OPI-PSRAM enabled", board == board_t::board_M5PaperDIY ? "M5PaperDIY" : "M5PaperS3"); + _panel_last.reset(); + _touch_last.reset(); + goto init_clear; // keep the board identification; the display stays unavailable #elif !defined (CONFIG_SPIRAM_MODE_OCT) ESP_LOGE(LIBRARY_NAME, "%s need OPI-PSRAM enabled", board == board_t::board_M5PaperDIY ? "M5PaperDIY" : "M5PaperS3"); + _panel_last.reset(); + _touch_last.reset(); + goto init_clear; // keep the board identification; the display stays unavailable #else auto bus_epd = new Bus_EPD(); _bus_last.reset(bus_epd);