Repository navigation
Expand file tree
/
Copy pathConfig.h
More file actions
103 lines (77 loc) · 2.2 KB
/
Copy pathConfig.h
File metadata and controls
103 lines (77 loc) · 2.2 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef Config_h
#define Config_h
#include <Arduino.h>
#include <EEPROM.h>
#include "Common.h"
struct bag_t {
char deviceName[ALEXA_NAME_LENGTH];
uint8_t mode;
bool encoderInverted;
uint8_t encoderSensitivity;
uint8_t wifiCheckInterval;
bool automaticUpdates;
bool initialState;
uint8_t initialBrightness;
};
// Class to hold configuration settings
class Config{
public:
Config():
_state(INITIAL_STATE),
_brightness(INITIAL_BRIGHTNESS)
{}
void begin();
void onLightChanged(void(*lightCallback)(void));
void onSettingsChanged(void(*settingsCallback)(void));
void onEncoderInverted(void(*invertEncoderCallback)(void));
bool load();
bool save();
char* getDeviceName();
void setDeviceName(char* name);
uint8_t getDeviceNameLength();
operation_t getMode();
void setMode(operation_t mode);
void toggleMode();
bool getState();
void setState(bool state);
void toggleState();
uint8_t getBrightness();
void setBrightness(uint8_t brightness);
bool getEncoderInverted();
void setEncoderInverted(bool inverted);
uint8_t getEncoderSensitivity();
void setEncoderSensitivity(uint8_t sensitivity);
uint8_t getWifiCheckInterval();
void setWifiCheckInterval(uint8_t interval);
bool getAutomaticUpdates();
void setAutomaticUpdates(bool updates);
updateStatus_t getUpdateStatus();
bool getIsUpdating();
void setUpdateStatusIdle();
void setUpdateStatusNoUpdates();
void setUpdateStatusLocalUpdate();
void setUpdateStatusRemoteUpdate();
void setUpdateStatusFailed(String message);
void setUpdateStatusOK();
String getUpdateMessage();
void updateLight();
void updateSettings();
bool getRebootSystem();
void setRebootSystem();
void systemUpdated();
private:
operation_t _mode;
uint8_t _state;
uint8_t _brightness;
bag_t _bag;
bool _updateSystem;
bool _rebootSystem;
updateStatus_t _updateStatus;
String _updateMessage;
void (*_updateLightCallback)(void) = NULL;
void (*_updateSettingsCallback)(void) = NULL;
void (*_invertEncoderCallback)(void) = NULL;
void _outputSettings();
void _initialisePreviousState();
};
#endif