Indention fixed and comment added.
This commit is contained in:
parent
1e4075a0f5
commit
ebd964e923
1 changed files with 10 additions and 4 deletions
|
@ -5,19 +5,25 @@
|
||||||
#define WIND_DEFAULT_MEAS_INIT 255
|
#define WIND_DEFAULT_MEAS_INIT 255
|
||||||
|
|
||||||
volatile unsigned int anemometerRotations = 0;
|
volatile unsigned int anemometerRotations = 0;
|
||||||
uint32_t start_meas_wind_time = 0;
|
volatile uint32_t start_meas_wind_time = 0;
|
||||||
int interruptNumber;
|
int interruptNumber;
|
||||||
|
|
||||||
#ifndef SENSOR_WIND_NO_ISR
|
#ifndef SENSOR_WIND_NO_ISR
|
||||||
void ICACHE_RAM_ATTR _anemometerInterrupt()
|
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++;
|
anemometerRotations++;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.print("*");
|
Serial.print("*");
|
||||||
debug("*");
|
debug("*");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif // end of if not defined SENSOR_WIND_NO_ISR
|
||||||
|
|
||||||
float wind_speed()
|
float wind_speed()
|
||||||
{
|
{
|
||||||
|
@ -30,9 +36,9 @@ float wind_speed()
|
||||||
|
|
||||||
void start_measure_wind()
|
void start_measure_wind()
|
||||||
{
|
{
|
||||||
start_meas_wind_time = millis();
|
|
||||||
anemometerRotations = 0;
|
anemometerRotations = 0;
|
||||||
#ifndef SENSOR_WIND_NO_ISR
|
#ifndef SENSOR_WIND_NO_ISR
|
||||||
|
start_meas_wind_time = millis();
|
||||||
interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN);
|
interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN);
|
||||||
attachInterrupt(interruptNumber, _anemometerInterrupt, FALLING);
|
attachInterrupt(interruptNumber, _anemometerInterrupt, FALLING);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue