-
Notifications
You must be signed in to change notification settings - Fork 0
/
SmartBbq.cpp
103 lines (85 loc) · 2.79 KB
/
SmartBbq.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
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
// SmartBbq - SmartBBQ Controller
#include "SmartBbq.h"
SmartBbq::SmartBbq(uint8_t probePin1
, uint8_t probePin2
, uint8_t probePin3
, uint8_t ledPin1
, uint8_t ledPin2
, uint8_t ledPin3
, uint8_t fanPin1) {
// setup probe indicators(LEDs) and add them to pointer array
//SmartProbe(uint8_t probePin, uint8_t ledPin, ThermistorProbe::ProbeType probeType = ThermistorProbe::ProbeType::ET732, float tempAlarm = 140.0);
_smartProbes[0] = new SmartProbe(probePin1, ledPin1);
_smartProbes[1] = new SmartProbe(probePin2, ledPin2);
_smartProbes[2] = new SmartProbe(probePin3, ledPin3);
// setup ThermistorProbe
_thermistorProbe = new ThermistorProbe(10000.0, 4095);
// set default active probe
_active = 0;
_smartProbes[_active]->activate();
}
SmartBbq::~SmartBbq() {
// deallocate memory
if (_smartProbes) {
delete[] _smartProbes;
}
if (_thermistorProbe) {
delete _thermistorProbe;
}
}
uint8_t SmartBbq::getActiveProbe(){
return _active;
}
// cycles through probes
void SmartBbq::select() {
// turn off old active led
_smartProbes[_active]->deactivate();
// if active probe is last one set back to first, otherwise increment
if(_active == (PROBENUM - 1)) {
_active = 0;
} else {
++_active;
}
// turn on new active led
_smartProbes[_active]->activate();
}
// increases set temp
void SmartBbq::up() {
_smartProbes[_active]->setAlarmTemp(_smartProbes[_active]->getAlarmTemp() + 1);
}
// decreases set temp
void SmartBbq::down() {
_smartProbes[_active]->setAlarmTemp(_smartProbes[_active]->getAlarmTemp() - 1);
}
// returns the active probes temp
float SmartBbq::getActiveTemp() {
return getProbeTemp(_active);
}
// returns the active alarm
float SmartBbq::getActiveAlarm() {
return getProbeAlarm(_active);
}
// returns probe temp
float SmartBbq::getProbeTemp(int probeIndex) {
if(probeIndex > -1 || probeIndex < PROBENUM) {
return _thermistorProbe->getTempF(_smartProbes[probeIndex]->getPin(), _smartProbes[probeIndex]->getProbeType());
} else {
return _thermistorProbe->getTempF(_smartProbes[_active]->getPin(), _smartProbes[_active]->getProbeType());
}
}
// returns probe alarm
float SmartBbq::getProbeAlarm(int probeIndex) {
if(probeIndex > -1 || probeIndex < PROBENUM) {
return _smartProbes[probeIndex]->getAlarmTemp();
} else {
return _smartProbes[_active]->getAlarmTemp();
}
}
// returns probe alarm enable
bool SmartBbq::getProbeAlarmE(int probeIndex) {
if(probeIndex > -1 || probeIndex < PROBENUM) {
return _smartProbes[probeIndex]->getAlarmEnable();
} else {
return _smartProbes[_active]->getAlarmEnable();
}
}