From b9024d455b93dcdaed8144825cc772bbede488c6 Mon Sep 17 00:00:00 2001 From: Torsten Stauder Date: Mon, 30 Nov 2020 23:14:45 +0100 Subject: [PATCH] Sleeptimer-bugfix --- README.md | 2 +- src/main.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5733eb8..b46f221 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ Keep in mind the RFID-lib I used is intended for default-SPI-pins only (SCK, MIS * If you want to monitor the battery-voltage, make sure to enable `MEASURE_BATTERY_VOLTAGE`. Use a voltage-divider as voltage of a LiPo is way too high for ESP32 (only 3.3V supported!). For my tests I connected VBat with a serial connection of 130k + 390k resistors (VBat--130k--X--390k--GND). X is the measure-point where to connect the GPIO to. Please note: via GUI upper and lower voltage for visualisation of battery-voltage (Neopixel) is available. Additional GUI-configurable values are interval (in minutes) for checking battery voltage and the cut off-voltage below whose a warning is shown via Neopixel. * If you're using a headphone-pcb with a [headphone jack](https://www.conrad.de/de/p/cliff-fcr1295-klinken-steckverbinder-3-5-mm-buchse-einbau-horizontal-polzahl-3-stereo-schwarz-1-st-705830.html) that has a pin to indicate if there's a plug, you can use this signal along with the feature `HEADPHONE_ADJUST_ENABLE` to limit the maximum headphone-voltage automatically. As per default you have to invert this signal and connect it to GPIO22. * Enabling `SHUTDOWN_IF_SD_BOOT_FAILS` is really recommended if you run your Tonuino in battery-mode without having a restart-button exposed to the outside of the Tonuino's enclosure. Because otherwise there's no way to restart your Tonuino and the error-state will remain until battery is empty (or you open the enclosure, hehe). -* Enabling `PLAY_LAST_RFID_AFTER_REBOOT` will tell Tonuino to remember the last RFID-tag played after reboot. So rebooting Tonuino will end up in autoplay. +* Enabling `PLAY_LAST_RFID_AFTER_REBOOT` will tell Tonuino to remember the last RFID-tag played after next reboot. So rebooting Tonuino will end up in autoplay. * compile and upload the sketch ## Starting Tonuino-ESP32 first time diff --git a/src/main.cpp b/src/main.cpp index 831f84f..f442076 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2343,8 +2343,8 @@ void doRfidCardModifications(const uint32_t mod) { } break; - case SLEEP_TIMER_MOD_15: // Puts/undo uC to sleep after 15 minutes - if (sleepTimer == 15) { + case SLEEP_TIMER_MOD_15: // Enables/disables sleep after 15 minutes + if (sleepTimerStartTimestamp && sleepTimer == 15) { sleepTimerStartTimestamp = 0; #ifdef NEOPIXEL_ENABLE ledBrightness = initialLedBrightness; @@ -2376,8 +2376,8 @@ void doRfidCardModifications(const uint32_t mod) { #endif break; - case SLEEP_TIMER_MOD_30: // Puts/undo uC to sleep after 30 minutes - if (sleepTimer == 30) { + case SLEEP_TIMER_MOD_30: // Enables/disables sleep after 30 minutes + if (sleepTimerStartTimestamp && sleepTimer == 30) { sleepTimerStartTimestamp = 0; #ifdef NEOPIXEL_ENABLE ledBrightness = initialLedBrightness; @@ -2409,8 +2409,8 @@ void doRfidCardModifications(const uint32_t mod) { #endif break; - case SLEEP_TIMER_MOD_60: // Puts/undo uC to sleep after 60 minutes - if (sleepTimer == 60) { + case SLEEP_TIMER_MOD_60: // Enables/disables sleep after 60 minutes + if (sleepTimerStartTimestamp && sleepTimer == 60) { sleepTimerStartTimestamp = 0; #ifdef NEOPIXEL_ENABLE ledBrightness = initialLedBrightness; @@ -2442,8 +2442,8 @@ void doRfidCardModifications(const uint32_t mod) { #endif break; - case SLEEP_TIMER_MOD_120: // Puts/undo uC to sleep after 2 hrs - if (sleepTimer == 120) { + case SLEEP_TIMER_MOD_120: // Enables/disables sleep after 2 hrs + if (sleepTimerStartTimestamp && sleepTimer == 120) { sleepTimerStartTimestamp = 0; #ifdef NEOPIXEL_ENABLE ledBrightness = initialLedBrightness;