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);