Minor optimization in Temperature UM.
This commit is contained in:
parent
1d833419aa
commit
72c5de6eae
@ -252,23 +252,21 @@ class UsermodTemperature : public Usermod {
|
|||||||
bool readFromConfig(JsonObject &root) {
|
bool readFromConfig(JsonObject &root) {
|
||||||
// we look for JSON object: {"Temperature": {"pin": 0, "degC": true}}
|
// we look for JSON object: {"Temperature": {"pin": 0, "degC": true}}
|
||||||
int8_t newTemperaturePin = temperaturePin;
|
int8_t newTemperaturePin = temperaturePin;
|
||||||
|
DEBUG_PRINT(FPSTR(_name));
|
||||||
|
|
||||||
JsonObject top = root[FPSTR(_name)];
|
JsonObject top = root[FPSTR(_name)];
|
||||||
if (top.isNull()) {
|
if (top.isNull()) {
|
||||||
DEBUG_PRINT(FPSTR(_name));
|
|
||||||
DEBUG_PRINTLN(F(": No config found. (Using defaults.)"));
|
DEBUG_PRINTLN(F(": No config found. (Using defaults.)"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled = top[FPSTR(_enabled)] | enabled;
|
enabled = top[FPSTR(_enabled)] | enabled;
|
||||||
newTemperaturePin = top["pin"] | newTemperaturePin;
|
newTemperaturePin = top["pin"] | newTemperaturePin;
|
||||||
// newTemperaturePin = min(33,max(-1,(int)newTemperaturePin)); // bounds check
|
|
||||||
degC = top["degC"] | degC;
|
degC = top["degC"] | degC;
|
||||||
readingInterval = top[FPSTR(_readInterval)] | readingInterval/1000;
|
readingInterval = top[FPSTR(_readInterval)] | readingInterval/1000;
|
||||||
readingInterval = min(120,max(10,(int)readingInterval)) * 1000; // convert to ms
|
readingInterval = min(120,max(10,(int)readingInterval)) * 1000; // convert to ms
|
||||||
parasite = top[FPSTR(_parasite)] | parasite;
|
parasite = top[FPSTR(_parasite)] | parasite;
|
||||||
|
|
||||||
DEBUG_PRINT(FPSTR(_name));
|
|
||||||
if (!initDone) {
|
if (!initDone) {
|
||||||
// first run: reading from cfg.json
|
// first run: reading from cfg.json
|
||||||
temperaturePin = newTemperaturePin;
|
temperaturePin = newTemperaturePin;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2110011
|
#define VERSION 2110021
|
||||||
|
|
||||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||||
//#define WLED_USE_MY_CONFIG
|
//#define WLED_USE_MY_CONFIG
|
||||||
@ -569,7 +569,7 @@ WLED_GLOBAL JsonDocument* fileDoc;
|
|||||||
WLED_GLOBAL bool doCloseFile _INIT(false);
|
WLED_GLOBAL bool doCloseFile _INIT(false);
|
||||||
|
|
||||||
// presets
|
// presets
|
||||||
WLED_GLOBAL int8_t currentPreset _INIT(-1);
|
WLED_GLOBAL int16_t currentPreset _INIT(-1);
|
||||||
|
|
||||||
WLED_GLOBAL byte errorFlag _INIT(0);
|
WLED_GLOBAL byte errorFlag _INIT(0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user