DebugUtils is a macro file to simplify the arduino debug code, that way you can simply enable/disable the serial output of your sketch with a define.
Drop the folder "DebugUtils/DebugUtils.h" under the next directory.
path-to-arduino/libraries/DebugUtils/DebugUtils.h
Verbose mode.
#define DEBUG 3
#include "DebugUtils.h"
void setup() {
Serial.begin(9600);
DEBUG_PRINT(millis());
DEBUG_PRINTLN(millis());
}
void loop() {
DEBUG_PRINT("debug sin Salto linea || ");
DEBUG_PRINTLN(millis());
DEBUG_VERBOSE("hola");
delay(1000);
}
In this mode we will have an output like this:
We can see that in this mode, the debug print the next information for all of the DEBUG_XXXX(msg) used:
millis(): function filePath:Line MsgOnThePrintMethod
Print with verbose warning enable Mode.
#define DEBUG 2
#include "DebugUtils.h"
void setup() {
Serial.begin(9600);
DEBUG_PRINT(millis());
DEBUG_PRINTLN(millis());
}
void loop() {
DEBUG_PRINT("debug sin Salto linea || ");
DEBUG_PRINTLN(millis());
DEBUG_VERBOSE("hola");
delay(1000);
}
In this mode we will have an output like this:
We can see that in this mode, we have the DEBUG_PRINT(msg) and DEBUG_PRINTLN(msg) which only differ on the new line after the message. In this mode the DEBUG_VERBOSE(msg) will change to the next message:
Not showing verbose mode on line: Line due to not verbose configured.
Simple print mode.
#define DEBUG 1
#include "DebugUtils.h"
void setup() {
Serial.begin(9600);
DEBUG_PRINT(millis());
DEBUG_PRINTLN(millis());
}
void loop() {
DEBUG_PRINT("debug sin Salto linea || ");
DEBUG_PRINTLN(millis());
DEBUG_VERBOSE("hola");
delay(1000);
}
In this mode we will have an output like this:
No image available right now
We can see that in this mode, we have the DEBUG_PRINT(msg) and DEBUG_PRINTLN(msg) which only differ on the new line after the message. In this mode the DEBUG_VERBOSE(msg) will not show any message.
Quiet Mode.
#define DEBUG 0
#include "DebugUtils.h"
void setup() {
Serial.begin(9600);
DEBUG_PRINT(millis());
DEBUG_PRINTLN(millis());
}
void loop() {
DEBUG_PRINT("debug sin Salto linea || ");
DEBUG_PRINTLN(millis());
DEBUG_VERBOSE("hola");
delay(1000);
}
In this mode we will have an output like this:
In this mode, our program won't write anything of our DEBUG_XXXX(msg) on the console, but we still can print with the Serial methods.
Feel free to contact if you have any doubt.
All information come from: