-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.cpp
52 lines (46 loc) · 1.04 KB
/
Logger.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
#include "Logger.h"
Logger* Logger::computerInstance = NULL;
Logger* Logger::onboardInstance = NULL;
Logger* Logger::xbeeInstance = NULL;
Logger::Logger(HardwareSerial& _output, bool _enabled)
: output(_output)
, enabled(_enabled)
{
// No initialization required
}
Logger& Logger::readComputerInstance() {
if(!computerInstance) {
Serial.begin(115200);
computerInstance = new Logger(Serial, true);
}
return *computerInstance;
}
Logger& Computer() {
return Logger::readComputerInstance();
}
Logger& Logger::readOnboardInstance() {
if(!onboardInstance) {
Serial1.begin(115200);
onboardInstance = new Logger(Serial1, true);
}
return *onboardInstance;
}
Logger& Onboard() {
return Logger::readOnboardInstance();
}
Logger& Logger::readXbeeInstance() {
if(!xbeeInstance) {
Serial2.begin(57600);
xbeeInstance = new Logger(Serial2, true);
}
return *xbeeInstance;
}
Logger& Xbee() {
return Logger::readXbeeInstance();
}
void Logger::enable() {
enabled = true;
}
void Logger::disable() {
enabled = false;
}