be334245ff
That makes it easier to enable/disable sensors. Also added support for APDS9930
23 lines
513 B
C++
23 lines
513 B
C++
#include "config_user.h"
|
|
|
|
int anemometerRotations = 0;
|
|
unsigned long currentTime = 0;
|
|
|
|
ICACHE_RAM_ATTR void _anemometerInterrupt() {
|
|
anemometerRotations++;
|
|
#ifdef DEBUG
|
|
Serial.print("*");
|
|
#endif
|
|
}
|
|
|
|
float wind_speed() {
|
|
anemometerRotations = 0;
|
|
currentTime = millis();
|
|
int interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN);
|
|
|
|
attachInterrupt(interruptNumber, _anemometerInterrupt, RISING);
|
|
delay(1000 * 5);
|
|
detachInterrupt(interruptNumber);
|
|
|
|
return (float)anemometerRotations / 5.0 * 2.4;
|
|
}
|