Fixed wind sensor interrupt handling.

This commit is contained in:
Kai Lauterbach 2022-11-24 19:17:21 +01:00
parent 0ae44ec987
commit 35f1635a3d
2 changed files with 8 additions and 5 deletions

View file

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

View file

@ -24,9 +24,7 @@ ESP8266HTTPUpdateServer httpUpdater;
String _webUpdater_ip = "127.0.0.1"; String _webUpdater_ip = "127.0.0.1";
String _webUpdater_dev = "unknown"; String _webUpdater_dev = "unknown";
#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
float _webUpdater_sensValues[VALUES]; float _webUpdater_sensValues[VALUES];
#endif
#define TR_TD_START_STR "<tr><td>" #define TR_TD_START_STR "<tr><td>"
#define TR_TD_END_STR "</td></tr>" #define TR_TD_END_STR "</td></tr>"