-
Notifications
You must be signed in to change notification settings - Fork 0
/
Debugger.h
89 lines (70 loc) · 2.23 KB
/
Debugger.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef Debugger_h
/*
* Simple debugging class:
*
* #include "Debugger.h"
*
* Debugger debugger
* ...
*
* debugger.setDebug(Debugger.QUIET); // turn off any output
*
* debugger.println(Debugger.INFO, "Info String");
*
* 2022/05/21 - Florian Amthor, Axel Amthor
*
*/
#define Debugger_h
class Debugger {
public:
enum debugLevel {QUIET = 0, INFO = 1, DEBUG = 2, TRACE = 3};
void setDebug(debugLevel level);
void print(debugLevel level, String line);
void println(debugLevel level, String line);
void print(debugLevel level, int line);
void println(debugLevel level, int line);
void print(debugLevel level, unsigned long line);
void println(debugLevel level, unsigned long line);
void print(debugLevel level, float line);
void println(debugLevel level, float line);
void print(debugLevel level, char line);
void println(debugLevel level, char line);
private:
debugLevel debug;
};
void Debugger::setDebug(debugLevel level) {
debug = level;
if ( level > QUIET )
Serial.begin(115200);
}
void Debugger::println(debugLevel level, String line) {
if ( level > QUIET && level <= debug ) Serial.println(line);
}
void Debugger::print(debugLevel level, String line) {
if ( level > QUIET && level <= debug ) Serial.print(line);
}
void Debugger::println(debugLevel level, int line) {
if ( level > QUIET && level <= debug ) Serial.println(line);
}
void Debugger::print(debugLevel level, int line) {
if ( level > QUIET && level <= debug ) Serial.print(line);
}
void Debugger::println(debugLevel level, float line) {
if ( level > QUIET && level <= debug ) Serial.println(line);
}
void Debugger::print(debugLevel level, float line) {
if ( level > QUIET && level <= debug ) Serial.print(line);
}
void Debugger::println(debugLevel level, unsigned long line) {
if ( level > QUIET && level <= debug ) Serial.println(line);
}
void Debugger::print(debugLevel level, unsigned long line) {
if ( level > QUIET && level <= debug ) Serial.print(line);
}
void Debugger::println(debugLevel level, char line) {
if ( level > QUIET && level <= debug ) Serial.println(line);
}
void Debugger::print(debugLevel level, char line) {
if ( level > QUIET && level <= debug ) Serial.print(line);
}
#endif