-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.h
120 lines (93 loc) · 2.16 KB
/
types.h
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
enum class SENSOR : uint8_t {
UNKNOWN = 0xFF,
NTC1K = 0, NTC2K, NTC5K, NTC10K, NTC20K,
PT100, PT500, PT1000,
NI100, NI500, NI1000, NI1000TK5000,
KTY1K, KTY2K,
QAC31,
};
const uint8_t lastSensor = static_cast<uint8_t>(SENSOR::QAC31);
enum class SENSOR_TYPE : uint8_t {
UNKNOWN = 0xFF,
NTC = 0, PTC,
};
enum class INPUT_TYPE : uint8_t {
UNKNOWN = 0xFF,
P1 = 0, P5, P10, N2, N10, N20,
};
const uint8_t lastInputType = static_cast<uint8_t>(INPUT_TYPE::N20);
enum class OUTPUT_TYPE : uint8_t {
UNKNOWN = 0xFF,
NTC = 0, PTC,
};
enum class CONTROL_STATUS : uint8_t {
ERROR, IS_HIGH, GOOD, IS_LOW,
};
void save(char key[], const int keySize, const String &value) {
strlcpy(key, value.c_str(), keySize);
}
struct WifiConfig {
char ssid[32];
char pass[64];
WifiConfig() {}
WifiConfig(const String &ssid, const String &pass) {
save(this->ssid, sizeof(this->ssid), ssid);
save(this->pass, sizeof(this->pass), pass);
}
};
struct AdcCal {
double slope;
double offset;
AdcCal() {}
AdcCal(const double slope, const double offset) {
this->slope = slope;
this->offset = offset;
}
};
struct Eich {
double beta;
double r0;
double t0;
Eich() {}
Eich(const double beta, const double r0, const double t0) {
this->beta = beta;
this->r0 = r0;
this->t0 = t0;
}
};
struct Linearizer {
double rp;
double rs;
Linearizer() {}
Linearizer(const double rp, const double rs) {
this->rp = rp;
this->rs = rs;
}
};
struct MQTTConfig {
char server[256];
uint16_t port;
char user[32];
char pass[64];
MQTTConfig() {}
MQTTConfig(const String &server, const String &port, const String &user, const String &pass) {
save(this->server, sizeof(this->server), server);
this->port = port.toInt();
save(this->user, sizeof(this->user), user);
save(this->pass, sizeof(this->pass), pass);
}
};
struct Config {
WifiConfig wifi;
AdcCal adccal;
SENSOR sensor;
Eich eich;
unsigned char enabled; // boolean
double noControlValue;
double controlValue;
double nightValue;
double slope;
unsigned char weekly[168]; // boolean
unsigned char nightly[168]; // boolean
MQTTConfig mqtt;
};