diff --git a/README.md b/README.md index 67bce0d..839cfd2 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ I started this project back in october 2019 and never expected it to become that * Partition-layout for ESP32 is changed along with this branch. This step was necessary in order to resize (enlarge) the memory-region where especially the assignments for the RFID-tags are saved. As all permanent settings (e.g. WiFi-settings) are saved there too, it's necessary to re-enter WiFi-credentials after update. But the most important thing is to recover the assignments for the RFID-tags. Please consult my [migration-document](https://forum.espuino.de/t/wechsel-zum-refactoring-branch-was-ist-zu-beachten/510). ## Changelog Last three events: +* 27.10.2021: Added feature `SAVE_PLAYPOS_BEFORE_SHUTDOWN`. When enabled last playposition for audiobook is saved when shutdown is initiated. Without having this feature enabled, it's necessary to press pause first, in order to do this manually. * 30.09.2021: Added feature `PAUSE_WHEN_RFID_REMOVED` for RC522 after having it already for PN5180 (thanks @elmar-ops for contribution) * 23.07.2021: Adding new playmode: from local .m3u-file (files or webstreams) -* 13.07.2021: Adding OTA-support via webGUI ## Known bugs * Some webstreams don't run. Guess it's a combination of saturated connection-pool and lack of heap-memory. Works probably better if ESP32-WROVER (e.g. Lolin D32 pro) is used, as this chip has PSRAM. Advice: Don't enable modules (e.g. MQTT) if you don't need them as this could save memory (and trouble). * For ESPuinos making use of SPI for SD (instead of SD_MMC), there's currently a problem that sometimes leads to incomplete file-transfers via webtransfer or FTP. I'm about to [investigate...](https://forum.espuino.de/t/probleme-beim-webtransfer/542) diff --git a/changelog.md b/changelog.md index e24e8e0..4380a1d 100644 --- a/changelog.md +++ b/changelog.md @@ -11,6 +11,7 @@ * 13.07.2021: Adding OTA-support via webGUI * 23.07.2021: Adding new playmode: from local .m3u-file (files or webstreams) * 30.09.2021: Added feature `PAUSE_WHEN_RFID_REMOVED` for RC522 after having it already for PN5180 (thanks @elmar-ops for contribution) +* 27.10.2021: Added feature `SAVE_PLAYPOS_BEFORE_SHUTDOWN`. When enabled last playposition for audiobook is saved when shutdown is initiated. Without having this feature enabled, it's necessary to press pause first, in order to do this manually. ## Old (monolithic main.cpp) * 11.07.2020: Added support for reversed Neopixel addressing. * 09.10.2020: mqttUser / mqttPassword can now be configured via webgui. diff --git a/src/System.cpp b/src/System.cpp index 815c97b..607a7a5 100644 --- a/src/System.cpp +++ b/src/System.cpp @@ -11,6 +11,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_system.h" +#include "Audio.h" constexpr const char prefsRfidNamespace[] PROGMEM = "rfidTags"; // Namespace used to save IDs of rfid-tags constexpr const char prefsSettingsNamespace[] PROGMEM = "settings"; // Namespace used for generic settings @@ -190,6 +191,19 @@ void System_DeepSleepManager(void) { return; } + System_Sleeping = true; + Log_Println((char *) FPSTR(goToSleepNow), LOGLEVEL_NOTICE); + + // Make sure last playposition for audiobook is saved when playback is active while shutdown was initiated + #ifdef SAVE_PLAYPOS_BEFORE_SHUTDOWN + if (!gPlayProperties.pausePlay && (gPlayProperties.playMode == AUDIOBOOK || gPlayProperties.playMode == AUDIOBOOK_LOOP)) { + AudioPlayer_TrackControlToQueueSender(PAUSEPLAY); + while (!gPlayProperties.pausePlay) { // Make sure to wait until playback is paused in order to be sure that playposition saved in NVS + vTaskDelay(portTICK_RATE_MS * 100u); + } + } + #endif + // Disable amps in order to avoid ugly noises when powering off #ifdef GPIO_PA_EN Port_Write(GPIO_PA_EN, false); @@ -198,9 +212,6 @@ void System_DeepSleepManager(void) { Port_Write(GPIO_HP_EN, false); #endif - System_Sleeping = true; - Log_Println((char *) FPSTR(goToSleepNow), LOGLEVEL_NOTICE); - Mqtt_Exit(); Led_Exit(); diff --git a/src/revision.h b/src/revision.h index 6685551..f5b9cd5 100644 --- a/src/revision.h +++ b/src/revision.h @@ -1,4 +1,4 @@ #ifndef __REVISION_H__ #define __REVISION_H__ - constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20211016-1"; + constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20211027-1"; #endif \ No newline at end of file diff --git a/src/settings.h b/src/settings.h index d20b9f3..3c25c15 100644 --- a/src/settings.h +++ b/src/settings.h @@ -46,6 +46,7 @@ //#define IR_CONTROL_ENABLE // Enables remote control (https://forum.espuino.de/t/neues-feature-fernsteuerung-per-infrarot-fernbedienung/265) #define CACHED_PLAYLIST_ENABLE // Enables playlist-caching (infos: https://forum.espuino.de/t/neues-feature-cached-playlist/515) //#define PAUSE_WHEN_RFID_REMOVED // Playback starts when card is applied and pauses automatically, when card is removed (https://forum.espuino.de/t/neues-feature-pausieren-wenn-rfid-karte-entfernt-wurde/541) + //#define SAVE_PLAYPOS_BEFORE_SHUTDOWN // When playback is active and mode audiobook was selected, last play-position is saved automatically when shutdown is initiated //################## select SD card mode #############################