|
|
|
@ -2,15 +2,16 @@
|
|
|
|
|
#include "config_user.h"
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
unsigned int anemometerRotations = 0;
|
|
|
|
|
volatile unsigned int anemometerRotations = 0;
|
|
|
|
|
uint32_t start_meas_wind_time = 0;
|
|
|
|
|
int interruptNumber;
|
|
|
|
|
|
|
|
|
|
ICACHE_RAM_ATTR void _anemometerInterrupt()
|
|
|
|
|
void ICACHE_RAM_ATTR _anemometerInterrupt()
|
|
|
|
|
{
|
|
|
|
|
anemometerRotations++;
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
Serial.print("*");
|
|
|
|
|
debug("*");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -28,6 +29,7 @@ void start_measure_wind()
|
|
|
|
|
start_meas_wind_time = millis();
|
|
|
|
|
anemometerRotations = 0;
|
|
|
|
|
interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN);
|
|
|
|
|
attachInterrupt(interruptNumber, _anemometerInterrupt, FALLING);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean check_measure_wind_done()
|
|
|
|
@ -43,5 +45,8 @@ boolean check_measure_wind_done()
|
|
|
|
|
float measure_wind_result()
|
|
|
|
|
{
|
|
|
|
|
start_meas_wind_time = 0;
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
debug("rotations = " + String((float)anemometerRotations));
|
|
|
|
|
#endif
|
|
|
|
|
return (float)anemometerRotations * WINDSPEED_FACTOR;
|
|
|
|
|
}
|
|
|
|
|