-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.cpp
78 lines (67 loc) · 1.23 KB
/
debug.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
#include "application.h"
#include "module.h"
#include <string>
using std::string;
void addPin(int pin, string *str);
void debug(string *str) {
(*str) += "\n\r";
Serial.print(str->c_str());
}
void debugButton(int pin) {
string s;
switch(pin) {
case D3:
s = "D3";
break;
case D4:
s = "D4";
break;
case D5:
s = "D5";
break;
case D6:
s = "D6";
break;
case D7:
s = "D7";
break;
}
s = s + " button pressed";
debug(&s);
}
void debugArray(int *list, int length) {
string str;
char buffer[10];
itoa(length, buffer, 10);
string l(buffer);
str = "Count: " + l + " List of presses: ";
for (int i = 0; i < length; i++) {
addPin(*list, &str);
str += ", ";
list++;
}
debug(&str);
}
void addPin(int pin, string *str) {
string s;
switch(pin) {
case D3:
s = "D3";
break;
case D4:
s = "D4";
break;
case D5:
s = "D5";
break;
case D6:
s = "D6";
break;
case D7:
s = "D7";
break;
default:
s = "unknown";
}
(*str) += s;
}