Remove triggerMoistureRead() call in ISR and it's trigger variable
- This was done at the very beginning when i thought to develop this part of the program in a different way. It is unnecessary with how I actually ended up to structure the program. - WDT should manage TWI only, as per current developement
This commit is contained in:
@@ -44,7 +44,6 @@ static const int8_t sensorPins[] = {
|
|||||||
extern volatile bool readSensors;
|
extern volatile bool readSensors;
|
||||||
|
|
||||||
void sensorsInit(void);
|
void sensorsInit(void);
|
||||||
void triggerMoistureRead(void);
|
|
||||||
uint16_t moistureRead(void);
|
uint16_t moistureRead(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ volatile uint16_t lastMoistureVal = 0;
|
|||||||
volatile uint16_t *pLastMoistureVal = &lastMoistureVal;
|
volatile uint16_t *pLastMoistureVal = &lastMoistureVal;
|
||||||
extern bool respondFlag;
|
extern bool respondFlag;
|
||||||
|
|
||||||
ISR(WDT_vect) {
|
|
||||||
triggerMoistureRead();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISR(TWI_vect) {
|
ISR(TWI_vect) {
|
||||||
twiListen();
|
twiListen();
|
||||||
}
|
}
|
||||||
@@ -50,11 +46,9 @@ int main(void) {
|
|||||||
pLastMoistureVal = &lastMoistureVal;
|
pLastMoistureVal = &lastMoistureVal;
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
if (readSensors) {
|
*pLastMoistureVal = moistureRead();
|
||||||
*pLastMoistureVal = moistureRead();
|
// nested if: (result outside range (see config.h)) {waterPlant()}
|
||||||
// nested if: (result outside range (see config.h)) {waterPlant()}
|
|
||||||
readSensors = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(respondFlag) {
|
if(respondFlag) {
|
||||||
twiRespond();
|
twiRespond();
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ void sensorsInit(void) {
|
|||||||
PORTC &= ~sensorMask;
|
PORTC &= ~sensorMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void triggerMoistureRead(void) {
|
|
||||||
readSensors = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint16_t moistureAverage(uint8_t sensorPin) {
|
static uint16_t moistureAverage(uint8_t sensorPin) {
|
||||||
uint16_t sum = 0;
|
uint16_t sum = 0;
|
||||||
for (uint8_t i = 0; i < SENSOR_READINGS; i++) {
|
for (uint8_t i = 0; i < SENSOR_READINGS; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user