PicoLowLevel
Loading...
Searching...
No Matches
Debug.h
Go to the documentation of this file.
1#ifndef DEBUG_H
2#define DEBUG_H
3
4#include <Arduino.h>
5#include "Debug.h"
6
7enum class Levels{
9};
10
20public:
21 SerialDebug(HardwareSerial* serial = &Serial) : serial(serial), ended(true), level(Levels::DEBUG) {}
22
23 void print(String st, Levels level);
24 void println(String st, Levels level);
25 void print(String st);
26 void println(String st);
27
28 // generic functions, accepting all parameters accepted by String
29 template<class T>
30 void print(T any, Levels level) {print(String(any), level);}
31 template<class T>
32 void println(T any, Levels level) {println(String(any), level);}
33 template<class T>
34 void print(T any) {print(String(any));}
35 template<class T>
36 void println(T any) {println(String(any));}
37
38 void delayd(int t);
39 void setLevel(Levels lvl);
40 void setSerial(HardwareSerial* serial);
41private:
42 HardwareSerial* serial;
43 String getLevel(Levels level);
44 bool ended;
45 Levels level;
46};
47
48// making the default instance extern so any class can use it
49extern SerialDebug Debug;
50
51#endif
SerialDebug Debug
Definition Debug.cpp:78
Levels
Definition Debug.h:7
Debug class that allows a finer control over serial debug.
Definition Debug.h:19
void println(String st, Levels level)
Sends a line to the serial port with a debug level, only if it is lower than the setted one.
Definition Debug.cpp:25
void print(T any, Levels level)
Definition Debug.h:30
void print(String st, Levels level)
Sends a string to the Serial port with a debug level, only if it is lower than the setted one.
Definition Debug.cpp:9
void print(T any)
Definition Debug.h:34
void delayd(int t)
Delay used only in debug.
Definition Debug.cpp:51
void println(T any, Levels level)
Definition Debug.h:32
void setSerial(HardwareSerial *serial)
void setLevel(Levels lvl)
Sets the level to be used for the debug.
Definition Debug.cpp:59
SerialDebug(HardwareSerial *serial=&Serial)
Definition Debug.h:21
void println(T any)
Definition Debug.h:36