Wemos D1 Mini Frimware zur Steuerung einer RGBW-LED-Lampe
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ConfigManager.h 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * ConfigManager.h
  3. *
  4. * Created on: 21.06.2026
  5. * Author: FSmilari
  6. */
  7. #ifndef CONFIGMANAGER_H_
  8. #define CONFIGMANAGER_H_
  9. #include <Arduino.h>
  10. #include <ArduinoJson.h>
  11. #include <EEPROM.h>
  12. #include "LEDModes.h"
  13. #define CONFIG_VERSION 4
  14. typedef struct __attribute__((packed)) {
  15. uint8_t r;
  16. uint8_t g;
  17. uint8_t b;
  18. uint8_t w;
  19. } RGBWColor;
  20. typedef struct __attribute__((packed)) {
  21. uint32_t start; // Sekunden seit 00:00:00
  22. uint32_t end;
  23. } TimeInterval;
  24. typedef struct __attribute__((packed)) {
  25. uint8_t version;
  26. char ssid[32];
  27. char pass[64];
  28. bool wifiValid;
  29. LEDModes mode;
  30. uint8_t brightness;
  31. RGBWColor singleColor;
  32. RGBWColor segmentColor1;
  33. RGBWColor segmentColor2;
  34. RGBWColor segmentColor3;
  35. uint32_t rainbowDelay;
  36. uint32_t spectralStepTime;
  37. uint32_t fadingHoldTime;
  38. uint32_t fadingFadeTime;
  39. uint32_t flashOnTime;
  40. uint32_t flashOffTime;
  41. TimeInterval timeInterval1;
  42. TimeInterval timeInterval2;
  43. } Config;
  44. class ConfigManager {
  45. public:
  46. ConfigManager();
  47. virtual ~ConfigManager();
  48. bool loadConfig();
  49. bool saveConfig(const Config &config);
  50. void resetConfig();
  51. Config& setToDefaultConfig();
  52. Config& setToDefaultWiFiConfig(Config &config);
  53. Config& setToDefaultLEDConfig(Config &config);
  54. Config& setToDefaultTimerConfig(Config &config);
  55. Config& getConfig();
  56. void getConfig(JsonDocument &doc);
  57. private:
  58. Config _config;
  59. void rgbwToJson(const RGBWColor &c, JsonObject obj);
  60. void timeIntervalToJson(const TimeInterval &ti, JsonObject obj);
  61. };
  62. #endif /* CONFIGMANAGER_H_ */