From 2ad351c41b779188675a610db3e0608dbdc7bb30 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 27 Oct 2021 02:05:48 +0200 Subject: [PATCH] remove selfTest causing sideeffects for pumploop trigger --- esp32/src/main.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index b78d2cf..08b3c96 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -69,6 +69,7 @@ RTC_DATA_ATTR long consecutiveWateringPlant[MAX_PLANTS] = {0}; bool volatile mDownloadMode = false; /**< Controller must not sleep */ bool volatile mSensorsRead = false; /**< Sensors are read without Wifi or MQTT */ int volatile pumpToRun = -1; /** pump to run at the end of the cycle */ +int volatile selfTestPumpRun = -1; /** pump to run at the end of the cycle */ bool mConfigured = false; long nextBlink = 0; /**< Time needed in main loop to support expected blink code */ @@ -831,29 +832,29 @@ void setup() void selfTest() { - if (pumpToRun >= 0 && pumpToRun < MAX_PLANTS) + if (selfTestPumpRun >= 0 && selfTestPumpRun < MAX_PLANTS) { Serial << "self test mode pump deactivate " << pumpToRun << endl; Serial.flush(); - mPlants[pumpToRun].deactivatePump(); + mPlants[selfTestPumpRun].deactivatePump(); } - if (pumpToRun >= MAX_PLANTS) + if (selfTestPumpRun >= MAX_PLANTS) { - Serial << "self test finished all pumps, proceed to initial wait mode " << pumpToRun << endl; + Serial << "self test finished all pumps, proceed to initial wait mode " << selfTestPumpRun << endl; Serial.flush(); digitalWrite(OUTPUT_ENABLE_PUMP, LOW); nextBlink = millis() + 500; } else { - pumpToRun++; + selfTestPumpRun++; nextBlink = millis() + 5000; } - if (pumpToRun < MAX_PLANTS) + if (selfTestPumpRun < MAX_PLANTS) { - Serial << "self test activating pump " << pumpToRun << endl; + Serial << "self test activating pump " << selfTestPumpRun << endl; Serial.flush(); - mPlants[pumpToRun].activatePump(); + mPlants[selfTestPumpRun].activatePump(); } }