Refactor TWI response system

- Avoid setting respondFlag in main, instead let it be managed directly
inside twiListen() and read inside twiRespond()
This commit is contained in:
2025-10-29 14:02:25 +01:00
parent 1721be5e66
commit b28b20f46a
2 changed files with 33 additions and 37 deletions
+1 -6
View File
@@ -11,7 +11,6 @@
volatile uint16_t lastMoistureVal = 0;
volatile uint16_t *pLastMoistureVal = &lastMoistureVal;
extern bool respondFlag;
ISR(TWI_vect) {
twiListen();
@@ -49,11 +48,7 @@ int main(void) {
*pLastMoistureVal = moistureRead();
// nested if: (result outside range (see config.h)) {waterPlant()}
if(respondFlag) {
twiRespond();
respondFlag = false;
}
twiRespond();
enterSleep();
}