Prevent calculations if tick is zero

This commit is contained in:
Antonio Lignan 2016-01-17 02:25:00 +01:00
parent aacbcd904f
commit 0cb80b0605

View file

@ -123,6 +123,7 @@ PROCESS_THREAD(weather_meter_int_process, ev, data)
}
if(ev == PROCESS_EVENT_TIMER) {
if(weather_sensors.anemometer.ticks) {
/* Disable to make the calculations in an interrupt-safe context */
GPIO_DISABLE_INTERRUPT(ANEMOMETER_SENSOR_PORT_BASE,
@ -147,6 +148,7 @@ PROCESS_THREAD(weather_meter_int_process, ev, data)
etimer_restart(&et);
}
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
@ -236,6 +238,8 @@ configure(int type, int value)
weather_sensors.rain_gauge.int_en = 0;
weather_sensors.anemometer.ticks = 0;
weather_sensors.rain_gauge.ticks = 0;
weather_sensors.anemometer.value = 0;
weather_sensors.rain_gauge.value = 0;
if(!value) {
anemometer_int_callback = NULL;