diff --git a/src/main.cpp b/src/main.cpp index 86f8747..5d7e473 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -337,9 +337,15 @@ void loop() localtime_r(&now, &timeinfo); double seconds = difftime(now, mktime(&alarmTime)); + + bool stayAwake = false; + if (alarmArmed && seconds >= -2*5*60) stayAwake = true; + if (!mp3.playing && millis() - lastButtonPress >= 60*1000 && !stayAwake) suspend(); + Serial.printf("alarm in %f seconds (%d)\n", seconds, alarmArmed); if (seconds >= 0 && alarmArmed) { alarmArmed = false; + lastButtonPress = millis(); led.wakeUpLight(0); Serial.println("WAKEUP TIME!!!!!"); mp3.setVolume(2); @@ -350,10 +356,6 @@ void loop() led.wakeUpLight(255*(seconds+300)/300); } - bool stayAwake = false; - if (alarmArmed && seconds >= -2*5*60) stayAwake = true; - if (!mp3.playing && millis() - lastButtonPress >= 60*1000 && !stayAwake) suspend(); - int voltage = rom_phy_get_vdd33(); Serial.printf("voltage: %d\n", voltage);