From 35f1635a3d7e57e0dad2940b8db9e90c3c651ce4 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Thu, 24 Nov 2022 19:17:21 +0100 Subject: [PATCH] Fixed wind sensor interrupt handling. --- firmware/sensor_wind.ino | 9 +++++++-- firmware/webUpdater.ino | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/firmware/sensor_wind.ino b/firmware/sensor_wind.ino index 5462a63..4b366e0 100644 --- a/firmware/sensor_wind.ino +++ b/firmware/sensor_wind.ino @@ -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; } diff --git a/firmware/webUpdater.ino b/firmware/webUpdater.ino index 02ea993..40d4d84 100644 --- a/firmware/webUpdater.ino +++ b/firmware/webUpdater.ino @@ -24,9 +24,7 @@ ESP8266HTTPUpdateServer httpUpdater; String _webUpdater_ip = "127.0.0.1"; String _webUpdater_dev = "unknown"; -#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE -float _webUpdater_sensValues[VALUES]; -#endif +float _webUpdater_sensValues[VALUES]; #define TR_TD_START_STR "" #define TR_TD_END_STR ""