Move TWI response handling from watchdog to main loop

This commit is contained in:
2025-10-12 21:10:18 +02:00
parent 0f0408df9b
commit 2a36d1356c
3 changed files with 22 additions and 14 deletions
+7 -2
View File
@@ -11,6 +11,7 @@
volatile uint16_t lastMoistureVal = 0;
volatile uint16_t *pLastMoistureVal = &lastMoistureVal;
extern bool respondFlag;
ISR(WDT_vect) {
triggerMoistureRead();
@@ -52,10 +53,14 @@ int main(void) {
if (readSensors) {
*pLastMoistureVal = moistureRead();
// nested if: (result outside range (see config.h)) {waterPlant()}
readSensors = false;
}
if(respondFlag) {
twiRespond();
respondFlag = false;
}
readSensors = false;
enterSleep();
}
return -1;