Big wheaterstation update #2
1 changed files with 10 additions and 4 deletions
|
@ -5,19 +5,25 @@
|
|||
#define WIND_DEFAULT_MEAS_INIT 255
|
||||
|
||||
volatile unsigned int anemometerRotations = 0;
|
||||
uint32_t start_meas_wind_time = 0;
|
||||
volatile uint32_t start_meas_wind_time = 0;
|
||||
int interruptNumber;
|
||||
|
||||
#ifndef SENSOR_WIND_NO_ISR
|
||||
void ICACHE_RAM_ATTR _anemometerInterrupt()
|
||||
{
|
||||
if ((start_meas_wind_time + (WIND_SENSOR_MEAS_TIME_S * 1000)) <= millis())
|
||||
{
|
||||
// measurement already done, prevent read of further rotations
|
||||
return;
|
||||
}
|
||||
|
||||
anemometerRotations++;
|
||||
#ifdef DEBUG
|
||||
Serial.print("*");
|
||||
debug("*");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif // end of if not defined SENSOR_WIND_NO_ISR
|
||||
|
||||
float wind_speed()
|
||||
{
|
||||
|
@ -30,9 +36,9 @@ float wind_speed()
|
|||
|
||||
void start_measure_wind()
|
||||
{
|
||||
start_meas_wind_time = millis();
|
||||
anemometerRotations = 0;
|
||||
#ifndef SENSOR_WIND_NO_ISR
|
||||
start_meas_wind_time = millis();
|
||||
interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN);
|
||||
attachInterrupt(interruptNumber, _anemometerInterrupt, FALLING);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue