diff --git a/src/main.cpp b/src/main.cpp index cd0423f..b97a3e6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,11 +42,11 @@ String shuttleServer = "https://ias-tea-axum.shuttleapp.rs"; TeaData currentTea(-1, "Teafault", "c0derfid", "", -1, 30); // config -long feedbackTimeout = 15; +unsigned long feedbackTimeoutSeconds = 15; int defaultSteepingTime = 120; // timeout -unsigned long timeoutTime; +unsigned long timeoutTimeMillis; // macros #define CATCH_NET_FAILURE(netResult, msg) \ @@ -109,7 +109,7 @@ void setup() else { defaultSteepingTime = result["default_steeping_time"]; - feedbackTimeout = result["feedback_timeout"]; + feedbackTimeoutSeconds = result["feedback_timeout"]; } smartDisplay.playTeaAnimation(); @@ -250,14 +250,14 @@ void loop() if (teaTimer.isSteeping()) { // abort if red button pressed - if (buttonLeft.isJustPressed()) + if (buttonLeft.isJustPressed() && buttonRight.isJustPressed()) { teaTimer.endSteeping(); - smartDisplay.printMsg("Ready!"); - smartStrip.animateBottomToTop(0, 1, 0); + smartDisplay.printMsg("Aborting..."); + smartStrip.animateBottomToTop(1, 0, 0); delay(1000); - state = State::REQUEST_FEEDBACK; - timeoutTime = millis() + (feedbackTimeout * 1000 * 60); + smartStrip.reset(); + state = State::WAIT_FOR_RFID_SCAN; break; } @@ -272,7 +272,7 @@ void loop() smartDisplay.printMsg("Ready!"); smartStrip.animateBottomToTop(0, 1, 0); state = State::REQUEST_FEEDBACK; - timeoutTime = millis() + (feedbackTimeout * 1000 * 60); + timeoutTimeMillis = millis() + (feedbackTimeoutSeconds * 1000); } break; } @@ -280,7 +280,7 @@ void loop() { // timeout - if (millis() >= timeoutTime) + if (millis() >= timeoutTimeMillis) { // we still want to save the last configuration (treated as perfect, no steeping time change) String steeepingTimePayload = teaNet.bundleSteepingTimeLogEntry(currentTea.m_steepingSeconds); @@ -348,7 +348,6 @@ void loop() // request steeping log JSONVar steepingLog = teaNet.httpsGETRequest(shuttleServer + "/brewing-events/" + currentTea.m_id); CATCH_NET_FAILURE(steepingLog, "TRY AGAIN") - String steeepingTimePayload = teaNet.bundleSteepingTimeLogEntry(currentTea.m_steepingSeconds); Serial.println(steeepingTimePayload);