File size: 808 Bytes
96a5049
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include "Arduino.h"
#include "structures.h"
#include "SD.h"
#include "ArduinoJson.h"

class SettingsManager {
private:
    SystemSettings settings;
    static const char* NAMESPACE;
    static const char* SETTINGS_KEY;
    uint32_t version;

    void setDefaults();
    bool validateSettings();

public:
    SettingsManager();
    void begin();
    bool load();
    bool save();
    void reset();
    
    SystemSettings& getSettings() { return settings; }
    void setSettings(const SystemSettings& newSettings);
    
    String exportToJson();
    bool importFromJson(const String& json);
    
    bool saveToSD(const char* filename);
    bool loadFromSD(const char* filename);
    
    uint32_t getVersion() const { return version; }
    bool isCompatibleVersion(uint32_t version) const;
};