Wemos D1 Mini Frimware zur Steuerung einer RGBW-LED-Lampe
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 5
  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. bool on;
  26. TimeInterval timeInterval1;
  27. TimeInterval timeInterval2;
  28. } Timer;
  29. typedef struct __attribute__((packed)) {
  30. uint8_t version;
  31. char ssid[32];
  32. char pass[64];
  33. bool wifiValid;
  34. LEDModes mode;
  35. uint8_t brightness;
  36. RGBWColor singleColor;
  37. RGBWColor segmentColor1;
  38. RGBWColor segmentColor2;
  39. RGBWColor segmentColor3;
  40. uint32_t rainbowDelay;
  41. uint32_t spectralStepTime;
  42. uint32_t fadingHoldTime;
  43. uint32_t fadingFadeTime;
  44. uint32_t flashOnTime;
  45. uint32_t flashOffTime;
  46. Timer timer;
  47. } Config;
  48. class ConfigManager {
  49. public:
  50. ConfigManager();
  51. virtual ~ConfigManager();
  52. bool loadConfig();
  53. bool saveConfig(const Config &config);
  54. void resetConfig();
  55. Config& setToDefaultConfig();
  56. Config& setToDefaultWiFiConfig(Config &config);
  57. Config& setToDefaultLEDConfig(Config &config);
  58. Config& setToDefaultTimerConfig(Config &config);
  59. Config& getConfig();
  60. void getConfig(JsonDocument &doc);
  61. private:
  62. Config _config;
  63. void rgbwToJson(const RGBWColor &c, JsonObject obj);
  64. void timeIntervalToJson(const TimeInterval &ti, JsonObject obj);
  65. };
  66. #endif /* CONFIGMANAGER_H_ */