From 154fc108a0d52005b272321360731de990b835dc Mon Sep 17 00:00:00 2001 From: norbert-walter Date: Thu, 10 Mar 2022 20:25:04 +0100 Subject: [PATCH] Fixing problem PageBME280 when sensor disabled --- lib/obp60task/PageBME280.cpp | 28 +++++++++++++++++++++++++--- lib/obp60task/Pagedata.h | 6 +++--- lib/obp60task/obp60task.h | 2 ++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/obp60task/PageBME280.cpp b/lib/obp60task/PageBME280.cpp index 13ce912..f5a86d8 100644 --- a/lib/obp60task/PageBME280.cpp +++ b/lib/obp60task/PageBME280.cpp @@ -25,6 +25,9 @@ class PageBME280 : public Page double value1 = 0; double value2 = 0; double value3 = 0; + String svalue1 = ""; + String svalue2 = ""; + String svalue3 = ""; // Get config data String tempformat = config->getString(config->tempFormat); @@ -32,6 +35,7 @@ class PageBME280 : public Page String displaycolor = config->getString(config->displaycolor); String flashLED = config->getString(config->flashLED); String backlightMode = config->getString(config->backlight); + String useenvsensor = config->getString(config->useEnvSensor); // Get sensor values #1 String name1 = "Temp"; // Value name @@ -42,7 +46,13 @@ class PageBME280 : public Page else{ value1 = 23.0 + float(random(0, 10)) / 10.0; } - String svalue1 = String(value1, 1); // Formatted value as string including unit conversion and switching decimal places + // Display data when sensor activated + if(String(useenvsensor) == "BME280"){ + svalue1 = String(value1, 1); // Formatted value as string including unit conversion and switching decimal places + } + else{ + svalue1 = "---"; + } String unit1 = "Deg C"; // Unit of value // Get sensor values #2 @@ -54,7 +64,13 @@ class PageBME280 : public Page else{ value2 = 43 + float(random(0, 4)); } - String svalue2 = String(value2, 0); // Formatted value as string including unit conversion and switching decimal places + // Display data when sensor activated + if(String(useenvsensor) == "BME280"){ + svalue2 = String(value2, 0); // Formatted value as string including unit conversion and switching decimal places + } + else{ + svalue2 = "---"; + } String unit2 = "%"; // Unit of value // Get sensor values #3 @@ -66,7 +82,13 @@ class PageBME280 : public Page else{ value3 = 1006 + float(random(0, 5)); } - String svalue3 = String(value3, 0); // Formatted value as string including unit conversion and switching decimal places + // Display data when sensor activated + if(String(useenvsensor) == "BME280"){ + svalue3 = String(value3, 0); // Formatted value as string including unit conversion and switching decimal places + } + else{ + svalue3 = "---"; + } String unit3 = "mBar"; // Unit of value // Optical warning by limit violation (unused) diff --git a/lib/obp60task/Pagedata.h b/lib/obp60task/Pagedata.h index 8716fe9..ae6c8a6 100644 --- a/lib/obp60task/Pagedata.h +++ b/lib/obp60task/Pagedata.h @@ -22,9 +22,9 @@ typedef struct{ double generatorVoltage = 0; double generatorCurrent = 0; double generatorPower = 0; - double airTemperature = 21.3; - double airHumidity = 43.2; - double airPressure = 1018.8; + double airTemperature = 0; + double airHumidity = 0; + double airPressure = 0; double onewireTemp1 = 0; double onewireTemp2 = 0; double onewireTemp3 = 0; diff --git a/lib/obp60task/obp60task.h b/lib/obp60task/obp60task.h index 7e32e07..5b9068b 100644 --- a/lib/obp60task/obp60task.h +++ b/lib/obp60task/obp60task.h @@ -11,6 +11,8 @@ #define GWSERIAL_TX 26 #define GWSERIAL_RX 14 #define GWSERIAL_MODE "UNI" +// Allowed to set a new password for access point +#define FORCE_AP_PWCHANGE // Init OBP60 Task void OBP60Init(GwApi *param);