Webupdater moved outside the fsm. Started to implement a semi parallel wind measurement.

This commit is contained in:
klaute 2022-09-14 00:10:03 +02:00
parent 446c7a5807
commit 35c62fbce2
3 changed files with 38 additions and 2 deletions

View file

@ -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

View file

@ -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;

View file

@ -3,6 +3,7 @@
#include "config.h"
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;
}