diff --git a/firmware/atmega/include/moisture.h b/firmware/atmega/include/moisture.h index f1eeaba..0c7c993 100644 --- a/firmware/atmega/include/moisture.h +++ b/firmware/atmega/include/moisture.h @@ -44,7 +44,6 @@ static const int8_t sensorPins[] = { extern volatile bool readSensors; void sensorsInit(void); -void triggerMoistureRead(void); uint16_t moistureRead(void); #endif diff --git a/firmware/atmega/source/main.c b/firmware/atmega/source/main.c index 057f1ac..75a6fc4 100644 --- a/firmware/atmega/source/main.c +++ b/firmware/atmega/source/main.c @@ -13,10 +13,6 @@ volatile uint16_t lastMoistureVal = 0; volatile uint16_t *pLastMoistureVal = &lastMoistureVal; extern bool respondFlag; -ISR(WDT_vect) { - triggerMoistureRead(); -} - ISR(TWI_vect) { twiListen(); } @@ -50,11 +46,9 @@ int main(void) { pLastMoistureVal = &lastMoistureVal; while(true) { - if (readSensors) { - *pLastMoistureVal = moistureRead(); - // nested if: (result outside range (see config.h)) {waterPlant()} - readSensors = false; - } + *pLastMoistureVal = moistureRead(); + // nested if: (result outside range (see config.h)) {waterPlant()} + if(respondFlag) { twiRespond(); diff --git a/firmware/atmega/source/moisture.c b/firmware/atmega/source/moisture.c index 09a30ff..943b41d 100644 --- a/firmware/atmega/source/moisture.c +++ b/firmware/atmega/source/moisture.c @@ -17,10 +17,6 @@ void sensorsInit(void) { PORTC &= ~sensorMask; } -void triggerMoistureRead(void) { - readSensors = true; -} - static uint16_t moistureAverage(uint8_t sensorPin) { uint16_t sum = 0; for (uint8_t i = 0; i < SENSOR_READINGS; i++) {