From 35c62fbce2fd1a71951bfc7ce4944aaa5b33b0d6 Mon Sep 17 00:00:00 2001 From: klaute Date: Wed, 14 Sep 2022 00:10:03 +0200 Subject: [PATCH] Webupdater moved outside the fsm. Started to implement a semi parallel wind measurement. --- firmware/config.h | 2 +- firmware/firmware.ino | 11 +++++++++++ firmware/sensor_wind.ino | 27 ++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/firmware/config.h b/firmware/config.h index a064015..376c171 100644 --- a/firmware/config.h +++ b/firmware/config.h @@ -5,7 +5,7 @@ #define WIFI_AUTOCONNECT_TIMEOUT_S 120 #define WIFI_CONFIG_PORTAL_TIMEOUT_S 120 -#define UPDATE_SENSOR_INTERVAL_S 180 +#define UPDATE_SENSOR_INTERVAL_S 300 #define UPDATE_WEBSERVER_INTVERVAL_S 1 // Do not change, bigger values will prevent using webupdater webinterface #define DELAY_LOOP_MS 100 #define POWERSAVING_SLEEP_S 600 diff --git a/firmware/firmware.ino b/firmware/firmware.ino index ea4ccf2..4948864 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -318,10 +318,20 @@ void loop() void _loop() { +#ifdef WEBUPDATER_FEATURE + if ((update_webserver_cnt + (UPDATE_WEBSERVER_INTVERVAL_S * 1000)) <= millis()) + { + //debug("web updater call"); + update_webserver_cnt = millis(); + doWebUpdater(); + } +#endif + switch (fsm_state) { case FSM_STATE_WU: +/* //debug("web updater call if required"); #ifdef WEBUPDATER_FEATURE if ((update_webserver_cnt + (UPDATE_WEBSERVER_INTVERVAL_S * 1000)) <= millis()) @@ -331,6 +341,7 @@ void _loop() doWebUpdater(); } #endif +*/ fsm_state = FSM_STATE_WSE; break; diff --git a/firmware/sensor_wind.ino b/firmware/sensor_wind.ino index f7cd6bd..a420ddc 100644 --- a/firmware/sensor_wind.ino +++ b/firmware/sensor_wind.ino @@ -2,7 +2,8 @@ #include "config_user.h" #include "config.h" -unsigned int anemometerRotations = 0; +unsigned int anemometerRotations = 0; +uint32_t start_meas_wind_time = 0; ICACHE_RAM_ATTR void _anemometerInterrupt() { @@ -12,6 +13,7 @@ ICACHE_RAM_ATTR void _anemometerInterrupt() #endif } +/* float wind_speed() { anemometerRotations = 0; @@ -32,3 +34,26 @@ float wind_speed() return tmp_speed; } +*/ + +void start_measure_wind() +{ + start_meas_wind_time = millis(); + anemometerRotations = 0; + interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN); +} + +boolean check_measure_wind_done() +{ + if (start_meas_wind + WIND_SENSOR_MEAS_TIME_S <= millis()) + { + detachInterrupt(interruptNumber); + return true; + } + return false; +} + +float stop_measure_wind() +{ + return (float)anemometerRotations * WINDSPEED_FACTOR; +}