From c21e386301b08c266f4e56ef8d8c7280a85355b8 Mon Sep 17 00:00:00 2001 From: Junhuang Date: Fri, 21 Aug 2026 14:50:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E7=9D=A1=E7=9C=A0=E5=89=8D?= =?UTF-8?q?=E7=94=B5=E6=BA=90=E7=81=AF=E5=85=B3=E9=97=AD=E3=80=81=E6=BB=91?= =?UTF-8?q?=E5=8A=A8=E5=85=B3=E6=9C=BA=E5=90=8E=E7=94=B5=E6=BA=90=E7=81=AF?= =?UTF-8?q?=E5=85=B3=E9=97=AD=EF=BC=8C=E8=A7=A3=E5=86=B3SD=E5=8D=A1?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E4=B8=AA=E7=9B=AE=E5=BD=95=E8=A2=AB=E8=B7=B3?= =?UTF-8?q?=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/PageRTC.hpp | 1 + src/PageTF.hpp | 14 +++++++++++--- src/main.hpp | 8 ++++++++ src/src.ino | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/PageRTC.hpp b/src/PageRTC.hpp index 33530d0..dd683e7 100644 --- a/src/PageRTC.hpp +++ b/src/PageRTC.hpp @@ -176,6 +176,7 @@ struct PageRTC : public PageBase if (_slide_x == 206) { int timer = _wake_timer.hours * 3600 + _wake_timer.minutes * 60 + _wake_timer.seconds; + prepareForPowerDown(); M5.Power.timerSleep(timer); } else diff --git a/src/PageTF.hpp b/src/PageTF.hpp index 0aca33f..7b82717 100644 --- a/src/PageTF.hpp +++ b/src/PageTF.hpp @@ -87,19 +87,26 @@ struct PageTF : public PageBase private: bool showFiles(File dir) { - File fp = dir.openNextFile(); bool abort = false; - while ((bool)(fp = dir.openNextFile())) + while (true) { + File fp = dir.openNextFile(); + if (!fp) { break; } + updateTouch(); abort = (prev_touchPoints < touchPoints); - if (abort) break; + if (abort) + { + fp.close(); + break; + } M5.Lcd.print(fp.name()); if (fp.isDirectory()) { M5.Lcd.println("/"); if (!showFiles(fp)) { + fp.close(); abort = true; break; } @@ -108,6 +115,7 @@ struct PageTF : public PageBase { M5.Lcd.println(); } + fp.close(); } dir.rewindDirectory(); return !abort; diff --git a/src/main.hpp b/src/main.hpp index a6e082e..9cd854e 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -122,6 +122,14 @@ static void buzzerFlush(void) #endif +static void prepareForPowerDown(void) +{ +#if M5TOOLS_TARGET_ESP32C5 + buzzerStop(); + M5.Power.M5pm1.setLedEnLevel(false); +#endif +} + void clickSound(void) { #if M5TOOLS_TARGET_ESP32C5 diff --git a/src/src.ino b/src/src.ino index b12cc6c..b1cb87b 100644 --- a/src/src.ino +++ b/src/src.ino @@ -243,6 +243,7 @@ Serial.print("done"); #if M5TOOLS_TARGET_ESP32C5 /// wakeup ピン (PM1 の IRQ 出力) の解放待ちを含む M5Unified 側の /// 手順に任せる (タッチ・電源ボタン・RTC アラームのいずれでも復帰可能) + prepareForPowerDown(); delay(100); M5.Lcd.fillScreen(TFT_BLACK); M5.Power.deepSleep(m5::Power_Class::sleep_no_timer, true);