From 0ae44ec987717e7491b811615ffc758c24a52fb2 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Tue, 15 Nov 2022 14:39:21 +0100 Subject: [PATCH] Added a preprocessor flag to enable/disable sensor walue table on webupdater main page. --- firmware/config_user.h.example | 13 ++++++++++--- firmware/firmware.ino | 10 ++++++++-- firmware/webUpdater.ino | 10 +++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/firmware/config_user.h.example b/firmware/config_user.h.example index 67f0fc2..9375af4 100755 --- a/firmware/config_user.h.example +++ b/firmware/config_user.h.example @@ -1,6 +1,5 @@ // Copy this file to config_user.h and adjust it to your needs. - #ifndef __CONFIG_USER_H__ #define __CONFIG_USER_H__ @@ -52,12 +51,19 @@ String DEVICE_NAME = "weatherstation"; //#define DEBUG_WINDSPEED_MEASUREMENT //#define HTTP_CALL_ON_WINDSPEED_EXCEED //#define HTTP_CALL_SEND_JSON_DATA +//#define SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE +/********************************************************************************/ + +// measurement correction factors const float HUMIDITY_FACTOR = 1.0; const float LIGHT_FACTOR = 1.0; const float TEMP_FACTOR = 1.0; -// InfluxDB credentials +/********************************************************************************/ + + +// InfluxDB1 credentials const char *INFLUXDB_HOST = "hostname"; const uint16_t INFLUXDB_PORT = 80; const char *INFLUXDB_DB = "database"; @@ -70,7 +76,8 @@ const char *INFLUXDB_URL = "http://192.168.0.123:3124"; const char *INFLUXDB_ORG = "home_org"; const char *INFLUXDB_BUCKET = "mybucket"; const char *INFLUXDB_TOKEN = "your api token"; -*/ + +/********************************************************************************/ // enable HTTP_CALL_ON_WINDSPEED_EXCEED to enable this feature #define HTTP_CALL_ON_WINDSPEED_EXCEED_MPS 5.0 // 5.0 m/s == 18 km/h diff --git a/firmware/firmware.ino b/firmware/firmware.ino index fb0a739..e3dc09a 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -530,7 +530,9 @@ void _fsm_loop() case FSM_STATE_8: //debug("set sensor data in webupdater if required"); #ifdef WEBUPDATER_FEATURE +#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE setSensorData(currentSensorData); +#endif #endif fsm_state = FSM_STATE_1; @@ -611,9 +613,11 @@ void _fsm_loop() } #ifdef WEBUPDATER_FEATURE +#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE sentWindspeed(currentSensorData[SENSOR_WINDSPEED]); -#endif -#endif +#endif // SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE +#endif // WEBUPDATER_FEATURE +#endif // HTTP_CALL_ON_WINDSPEED_EXCEED // step into read of next fsm state fsm_state = FSM_STATE_2; @@ -661,8 +665,10 @@ void _battery_mode_main() { #endif #ifdef WEBUPDATER_FEATURE +#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE setSensorData(currentSensorData); #endif +#endif } //*************************************************************************// diff --git a/firmware/webUpdater.ino b/firmware/webUpdater.ino index 906d2d6..02ea993 100644 --- a/firmware/webUpdater.ino +++ b/firmware/webUpdater.ino @@ -23,7 +23,10 @@ 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 #define TR_TD_START_STR "" #define TR_TD_END_STR "" @@ -70,17 +73,19 @@ void doWebUpdater(void) } //*************************************************************************// - +#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE void sentWindspeed(float ws) { _webUpdater_sensValues[SENSOR_WINDSPEED] = ws; } +#endif void setWifiReconnectCnt(uint32_t wrc) { _wifi_reconnect_cnt = wrc; } +#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE void setSensorData(float sensorValues[]) { @@ -102,6 +107,7 @@ void setSensorData(float sensorValues[]) } } } +#endif //*************************************************************************// @@ -121,6 +127,7 @@ void showHTMLMain(void) #ifdef HOMEBRIDGE_WEBSTAT "
homebridge websatt
" #endif +#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE "

" TR_TD_START_STR + "temperature" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_TEMPERATURE]) + TR_TD_END_STR TR_TD_START_STR + "humidity" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_HUMIDITY]) + TR_TD_END_STR @@ -133,6 +140,7 @@ void showHTMLMain(void) TR_TD_START_STR + "wifi rssi" + TD_TD_MID_STR + WiFi.RSSI() + TR_TD_END_STR TR_TD_START_STR + "wifi rec cnt" + TD_TD_MID_STR + String(_wifi_reconnect_cnt) + TR_TD_END_STR "
" +#endif #ifndef DISABLE_WIFIMANAGER "




reset WiFi Manager
" #endif