-
Notifications
You must be signed in to change notification settings - Fork 4
/
SerialDrawer.cpp
executable file
·68 lines (55 loc) · 1.73 KB
/
SerialDrawer.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
#include <Arduino.h>
#include "SerialDrawer.h"
void SerialDrawer::drawMenu(Menu* menu) {
Serial.print(F("Menu: "));
Serial.println(menu->getText());
ListEntry* e = menu->getCollection();
if(!e)
Serial.println(F(" No sub-items"));
else
while(e) {
if(e->item == menu->getSelectedItem())
Serial.print(F(" ->"));
else
Serial.print(F(" "));
if (e->item->isTextFlash()) {
const FlashString* text = reinterpret_cast<const FlashString*>(e->item->getText());
Serial.print(text);
} else {
const char* text = e->item->getText();
Serial.print(text);
}
if(e->item->getSecondaryText()) {
Serial.print(F(" | "));
Serial.print(e->item->getSecondaryText());
}
Serial.println();
e = e->next;
}
}
/*void SerialDrawer::drawAction(Action* action) {
Serial.print(F("Action: "));
Serial.println(action->getText());
}*/
void SerialDrawer::drawSelector(NumericSelector* selector) {
Serial.print(F("Selector: "));
Serial.print(selector->getText());
Serial.print(F(" <"));
Serial.print(selector->getValue());
Serial.println(F(">"));
}
void SerialDrawer::draw(MenuItem* item) {
if(!item) return;
switch(item->getTypeId()) {
case 'm':
drawMenu((Menu*)item);
break;
/*case 'a':
drawAction((Action*)item);
break;
*/
case 's':
drawSelector((NumericSelector*)item);
break;
}
}