-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathController.cpp
50 lines (41 loc) · 1 KB
/
Controller.cpp
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
#include "Controller.h"
Controller::Controller(): sensors(nullptr), sensorsCount(0), heater(nullptr), humidifier(nullptr), buzzer(nullptr){
}
void Controller::defineBME280Sensors(uint8_t* addressArray, String* nameArray, uint8_t sensorsCount) {
if (sensors) {
delete sensors;
}
sensorsCount = sensorsCount;
sensors = new BME280Sensor* [sensorsCount];
for (int i = 0; i < sensorsCount; i++) {
sensors[i] = new BME280Sensor(addressArray[i], nameArray[i]);
}
}
void Controller::initialiseSensors() {
for (int i = 0; i < sensorsCount; i++) {
sensors[i]->initialise();
}
}
void Controller::defineHeater(uint8_t pin) {
if (heater) {
delete heater;
}
heater = new Heater(pin);
}
void Controller::defineHumidifier(uint8_t pin) {
if (humidifier) {
delete humidifier;
}
humidifier = new Humidifier(pin);
}
void Controller::defineBuzzer(uint8_t pin) {
if (buzzer) {
delete buzzer;
}
buzzer = new Buzzer(pin);
}
void Controller::beep() {
if (buzzer) {
buzzer->beep();
}
}