| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- /*
- * ConfigManager.h
- *
- * Created on: 21.06.2026
- * Author: FSmilari
- */
-
- #ifndef CONFIGMANAGER_H_
- #define CONFIGMANAGER_H_
-
- #include <Arduino.h>
- #include <ArduinoJson.h>
- #include <EEPROM.h>
- #include "LEDModes.h"
-
- #define CONFIG_VERSION 5
-
- typedef struct __attribute__((packed)) {
- uint8_t r;
- uint8_t g;
- uint8_t b;
- uint8_t w;
- } RGBWColor;
-
- typedef struct __attribute__((packed)) {
- uint32_t start; // Sekunden seit 00:00:00
- uint32_t end;
- } TimeInterval;
-
- typedef struct __attribute__((packed)) {
- bool on;
- TimeInterval timeInterval1;
- TimeInterval timeInterval2;
- } Timer;
-
- typedef struct __attribute__((packed)) {
- uint8_t version;
-
- char ssid[32];
- char pass[64];
- bool wifiValid;
- LEDModes mode;
- uint8_t brightness;
- RGBWColor singleColor;
- RGBWColor segmentColor1;
- RGBWColor segmentColor2;
- RGBWColor segmentColor3;
- uint32_t rainbowDelay;
- uint32_t spectralStepTime;
- uint32_t fadingHoldTime;
- uint32_t fadingFadeTime;
- uint32_t flashOnTime;
- uint32_t flashOffTime;
- Timer timer;
- } Config;
-
- class ConfigManager {
-
- public:
- ConfigManager();
- virtual ~ConfigManager();
-
- bool loadConfig();
- bool saveConfig(const Config &config);
- void resetConfig();
- Config& setToDefaultConfig();
- Config& setToDefaultWiFiConfig(Config &config);
- Config& setToDefaultLEDConfig(Config &config);
- Config& setToDefaultTimerConfig(Config &config);
- Config& getConfig();
- void getConfig(JsonDocument &doc);
-
- private:
- Config _config;
-
- void rgbwToJson(const RGBWColor &c, JsonObject obj);
- void timeIntervalToJson(const TimeInterval &ti, JsonObject obj);
- };
-
- #endif /* CONFIGMANAGER_H_ */
|