|
@@ -2,17 +2,17 @@
|
|
|
|
|
|
#include <SmingCore/SmingCore.h>
|
|
#include <SmingCore/SmingCore.h>
|
|
|
|
|
|
-MeteoConfig ActiveConfig;
|
|
|
|
|
|
+ClockConfig ActiveConfig;
|
|
|
|
|
|
-MeteoConfig loadConfig()
|
|
|
|
|
|
+ClockConfig loadConfig()
|
|
{
|
|
{
|
|
DynamicJsonBuffer jsonBuffer;
|
|
DynamicJsonBuffer jsonBuffer;
|
|
- MeteoConfig cfg;
|
|
|
|
- if (fileExist(METEO_CONFIG_FILE))
|
|
|
|
|
|
+ ClockConfig cfg;
|
|
|
|
+ if (fileExist(CLOCK_CONFIG_FILE))
|
|
{
|
|
{
|
|
- int size = fileGetSize(METEO_CONFIG_FILE);
|
|
|
|
|
|
+ int size = fileGetSize(CLOCK_CONFIG_FILE);
|
|
char* jsonString = new char[size + 1];
|
|
char* jsonString = new char[size + 1];
|
|
- fileGetContent(METEO_CONFIG_FILE, jsonString, size + 1);
|
|
|
|
|
|
+ fileGetContent(CLOCK_CONFIG_FILE, jsonString, size + 1);
|
|
JsonObject& root = jsonBuffer.parseObject(jsonString);
|
|
JsonObject& root = jsonBuffer.parseObject(jsonString);
|
|
|
|
|
|
JsonObject& network = root["network"];
|
|
JsonObject& network = root["network"];
|
|
@@ -20,14 +20,16 @@ MeteoConfig loadConfig()
|
|
cfg.NetworkPassword = String((const char*)network["password"]);
|
|
cfg.NetworkPassword = String((const char*)network["password"]);
|
|
|
|
|
|
JsonObject& correction = root["correction"];
|
|
JsonObject& correction = root["correction"];
|
|
- cfg.AddT = correction["T"];
|
|
|
|
- cfg.AddRH = correction["RH"];
|
|
|
|
cfg.AddTZ = correction["TZ"];
|
|
cfg.AddTZ = correction["TZ"];
|
|
|
|
|
|
- JsonObject& trigger = root["trigger"];
|
|
|
|
- cfg.Trigger = (TriggerType)(int)trigger["type"];
|
|
|
|
- cfg.RangeMin = trigger["min"];
|
|
|
|
- cfg.RangeMax = trigger["max"];
|
|
|
|
|
|
+ JsonObject& light = root["light"];
|
|
|
|
+ cfg.LightTrhLow = light["low"];
|
|
|
|
+ cfg.LightTrhLow = light["high"];
|
|
|
|
+
|
|
|
|
+ JsonObject& bright = root["bright"];
|
|
|
|
+ cfg.BrightnessLow = bright["low"];
|
|
|
|
+ cfg.BrightnessMiddle = bright["mid"];
|
|
|
|
+ cfg.BrightnessHigh = bright["high"];
|
|
|
|
|
|
delete[] jsonString;
|
|
delete[] jsonString;
|
|
}
|
|
}
|
|
@@ -39,7 +41,7 @@ MeteoConfig loadConfig()
|
|
return cfg;
|
|
return cfg;
|
|
}
|
|
}
|
|
|
|
|
|
-void saveConfig(MeteoConfig& cfg)
|
|
|
|
|
|
+void saveConfig(ClockConfig& cfg)
|
|
{
|
|
{
|
|
ActiveConfig = cfg;
|
|
ActiveConfig = cfg;
|
|
|
|
|
|
@@ -53,19 +55,22 @@ void saveConfig(MeteoConfig& cfg)
|
|
|
|
|
|
JsonObject& correction = jsonBuffer.createObject();
|
|
JsonObject& correction = jsonBuffer.createObject();
|
|
root["correction"] = correction;
|
|
root["correction"] = correction;
|
|
- correction["T"] = cfg.AddT;
|
|
|
|
- correction["RH"] = cfg.AddRH;
|
|
|
|
correction["TZ"] = cfg.AddTZ;
|
|
correction["TZ"] = cfg.AddTZ;
|
|
|
|
|
|
- JsonObject& trigger = jsonBuffer.createObject();
|
|
|
|
- root["trigger"] = trigger;
|
|
|
|
- trigger["type"] = (int)cfg.Trigger;
|
|
|
|
- trigger["min"] = cfg.RangeMin;
|
|
|
|
- trigger["max"] = cfg.RangeMax;
|
|
|
|
|
|
+ JsonObject& light = jsonBuffer.createObject();
|
|
|
|
+ root["light"] = light;
|
|
|
|
+ light["low"] = cfg.LightTrhLow;
|
|
|
|
+ light["high"] = cfg.LightTrhHigh;
|
|
|
|
+
|
|
|
|
+ JsonObject& bright = jsonBuffer.createObject();
|
|
|
|
+ root["bright"] = bright;
|
|
|
|
+ bright["low"] = cfg.BrightnessLow;
|
|
|
|
+ bright["mid"] = cfg.BrightnessMiddle;
|
|
|
|
+ bright["high"] = cfg.BrightnessHigh;
|
|
|
|
|
|
char buf[3048];
|
|
char buf[3048];
|
|
root.prettyPrintTo(buf, sizeof(buf));
|
|
root.prettyPrintTo(buf, sizeof(buf));
|
|
- fileSetContent(METEO_CONFIG_FILE, buf);
|
|
|
|
|
|
+ fileSetContent(CLOCK_CONFIG_FILE, buf);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|