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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 3
  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. uint8_t version;
  22. char ssid[32];
  23. char pass[64];
  24. bool wifiValid;
  25. LEDModes mode;
  26. uint8_t brightness;
  27. RGBWColor singleColor;
  28. RGBWColor segmentColor1;
  29. RGBWColor segmentColor2;
  30. RGBWColor segmentColor3;
  31. uint32_t rainbowDelay;
  32. uint32_t spectralStepTime;
  33. uint32_t fadingHoldTime;
  34. uint32_t fadingFadeTime;
  35. uint32_t flashOnTime;
  36. uint32_t flashOffTime;
  37. } Config;
  38. class ConfigManager {
  39. public:
  40. ConfigManager();
  41. virtual ~ConfigManager();
  42. bool loadConfig();
  43. bool saveConfig(const Config &config);
  44. void resetConfig();
  45. Config& setToDefaultConfig();
  46. Config& setToDefaultWiFiConfig(Config &config);
  47. Config& setToDefaultLEDConfig(Config &config);
  48. Config& getConfig();
  49. void getConfig(JsonDocument &doc);
  50. private:
  51. Config _config;
  52. void rgbwToJson(const RGBWColor &c, JsonObject obj);
  53. };
  54. #endif /* CONFIGMANAGER_H_ */