Control Surface  1.1.1
MIDI Control Surface library for Arduino
Debug.ino

Debug

This examples shows how use the debug macros for printing different kinds of debugging information

Boards:
AVR, AVR USB, Nano 33, Due, Teensy 3.x, ESP8266, ESP32

Behavior

This is the result of `DEBUG`
[/home/pieter/GitHub/Arduino-Debugging/Example/Example.ino:12]: This is the result of `DEBUGREF`
[void loop() @ line 13]: This is the result of `DEBUGFN`
[0:2:11.085]: This is the result of `DEBUGTIME`
a = 1, b = 2, c = 3
log10(1000) - 2 = 1.00
millis() = 131085
Serial.read() = -1
[int someFunction(int) @ line 26]: parameter = 42
See also
Debug for instructions on how to add an option in the Arduino IDE to easily enable and disable debugging.

Written by PieterP, 2018-07-31
https://github.com/tttapa/Arduino-Helpers

void setup() {
Serial.begin(115200);
while (!Serial)
;
}
void loop() {
DEBUG("This is the result of `DEBUG`");
DEBUGREF("This is the result of `DEBUGREF`");
DEBUGFN("This is the result of `DEBUGFN`");
DEBUGTIME("This is the result of `DEBUGTIME`");
int a = 1, b = 2, c = 3;
DEBUGVAL(a, b, c);
DEBUGVAL(log10(1000) - 2);
DEBUGVAL(millis());
DEBUGVAL(Serial.read());
someFunction(42);
DEBUG("");
delay(5000);
}
int someFunction(int parameter) {
DEBUGFN(NAMEDVALUE(parameter));
return parameter;
}
NAMEDVALUE
#define NAMEDVALUE(x)
Macro for printing an expression as a string, followed by its value.
Definition: Debug.hpp:69
DEBUGREF
#define DEBUGREF(x)
Print an expression and its location (file and line number) to the debug output if debugging is enabl...
Definition: Debug.hpp:84
DEBUGTIME
#define DEBUGTIME(x)
Print an expression and the time since startup to the debug output if debugging is enabled.
Definition: Debug.hpp:104
DEBUGVAL
#define DEBUGVAL(...)
Print multiple expressions and their values to the debug output if debugging is enabled.
Definition: Debug.hpp:151
DEBUGFN
#define DEBUGFN(x)
Print an expression and its function (function name and line number) to the debug output if debugging...
Definition: Debug.hpp:93
Arduino_Helpers.h
Dummy header file for Arduino builder. You have to add this file first, so the other headers are in t...
Debug.hpp
DEBUG
#define DEBUG(x)
Print an expression to the debug output if debugging is enabled.
Definition: Debug.hpp:75