Przeglądaj źródła

Add new parameter to settings

Chris Mullins 6 lat temu
rodzic
commit
c069f77d32
2 zmienionych plików z 4 dodań i 0 usunięć
  1. 2 0
      lib/Settings/Settings.cpp
  2. 2 0
      lib/Settings/Settings.h

+ 2 - 0
lib/Settings/Settings.cpp

@@ -99,6 +99,7 @@ void Settings::patch(JsonObject parsedSettings) {
   this->setIfPresent(parsedSettings, "wifi_static_ip_netmask", wifiStaticIPNetmask);
   this->setIfPresent(parsedSettings, "packet_repeats_per_loop", packetRepeatsPerLoop);
   this->setIfPresent(parsedSettings, "home_assistant_discovery_prefix", homeAssistantDiscoveryPrefix);
+  this->setIfPresent(parsedSettings, "default_transition_period", defaultTransitionPeriod);
 
   if (parsedSettings.containsKey("wifi_mode")) {
     this->wifiMode = wifiModeFromString(parsedSettings["wifi_mode"]);
@@ -288,6 +289,7 @@ void Settings::serialize(Print& stream, const bool prettyPrint) {
   root["packet_repeats_per_loop"] = this->packetRepeatsPerLoop;
   root["home_assistant_discovery_prefix"] = this->homeAssistantDiscoveryPrefix;
   root["wifi_mode"] = wifiModeToString(this->wifiMode);
+  root["default_transition_period"] = this->defaultTransitionPeriod;
 
   JsonArray channelArr = root.createNestedArray("rf24_channels");
   JsonHelpers::vectorToJsonArr<RF24Channel, String>(channelArr, rf24Channels, RF24ChannelHelpers::nameFromValue);

+ 2 - 0
lib/Settings/Settings.h

@@ -118,6 +118,7 @@ public:
     rf24ListenChannel(RF24Channel::RF24_LOW),
     packetRepeatsPerLoop(10),
     wifiMode(WifiMode::N),
+    defaultTransitionPeriod(500),
     _autoRestartPeriod(0)
   { }
 
@@ -191,6 +192,7 @@ public:
   std::map<uint32_t, BulbId> deletedGroupIdAliases;
   String homeAssistantDiscoveryPrefix;
   WifiMode wifiMode;
+  uint16_t defaultTransitionPeriod;
 
 protected:
   size_t _autoRestartPeriod;