-
Notifications
You must be signed in to change notification settings - Fork 0
/
Output.h
67 lines (56 loc) · 1.39 KB
/
Output.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
/** External Code Import(s) **/
#include "Arduino_SensorKit.h"
/** Local Code Import(s) **/
// NoOp
/** Local Macro Import(s) **/
#include "hardware_config.h"
/** Local Macro(s) **/
// NoOp
/** Local Global Variable(s) **/
// NoOp
class Output {
private:
bool oled_;
bool serial_;
String outputText_;
public:
Output (bool oled = USE_OLED, bool serial = USE_SERIAL, int baud = SERIAL_BAUD) {
// Track what form(s) of output will be used.
oled_ = oled;
serial_ = serial;
// Setup output methods requested by caller.
if (oled_) {
Oled.begin();
// Set screen rotation.
Oled.setFlipMode(true);
// Set font.
Oled.setFont(u8x8_font_chroma48medium8_r);
}
if (serial_) {
Serial.begin(baud);
}
}
void addOutput(String msg) {
outputText_ += msg + "\n";
}
void addOutput(String title, String msg) {
outputText_ += title + msg + "\n";
}
void addOutput(String title, String msg, String units) {
outputText_ += title + msg + units + "\n";
}
void publish() {
if (oled_) {
// Set screen origen.
Oled.setCursor(0, 0);
// Publish & rest.
Oled.print(outputText_);
Oled.refreshDisplay();
}
if (serial_) {
// Publish & reset.
Serial.println(outputText_);
}
outputText_ = "";
}
};