Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Macros

Detailed Description

Macros for printing debug information that can be easily enabled or disabled.

See also
Debug for instructions on how to add an option in the Arduino IDE to easily enable and disable debugging.
+ Collaboration diagram for Debug:

Macros

#define NAMEDVALUE(x)   F(DEBUG_STR(x) " = ") << x
 Macro for printing an expression as a string, followed by its value.
 
#define DEBUG(x)
 Print an expression to the debug output if debugging is enabled.
 
#define DEBUGREF(x)
 Print an expression and its location (file and line number) to the debug output if debugging is enabled.
 
#define DEBUGFN(x)
 Print an expression and its function (function name and line number) to the debug output if debugging is enabled.
 
#define DEBUGTIME(x)
 Print an expression and the time since startup to the debug output if debugging is enabled.
 
#define DEBUGVAL(...)   DEBUGVALN(COUNT(__VA_ARGS__))(__VA_ARGS__)
 Print multiple expressions and their values to the debug output if debugging is enabled.
 

Macro Definition Documentation

◆ NAMEDVALUE

#define NAMEDVALUE ( x)    F(DEBUG_STR(x) " = ") << x

Macro for printing an expression as a string, followed by its value.

The expression string is saved in PROGMEM using the F(...) macro.

Examples
Debug.ino.

Definition at line 89 of file Debug.hpp.

◆ DEBUG

#define DEBUG ( x)
Value:
do { \
DEBUG_LOCK_MUTEX \
DEBUG_OUT << x << DEBUG_ENDL; \
} while (0)
#define DEBUG_ENDL
Definition Debug.hpp:52

Print an expression to the debug output if debugging is enabled.

Examples
Debug.ino.

Definition at line 95 of file Debug.hpp.

◆ DEBUGREF

#define DEBUGREF ( x)
Value:
do { \
DEBUG_LOCK_MUTEX \
DEBUG_OUT << F(DEBUG_LOCATION) << x << DEBUG_ENDL; \
} while (0)
#define DEBUG_LOCATION
Definition Debug.hpp:66

Print an expression and its location (file and line number) to the debug output if debugging is enabled.

The location is saved in PROGMEM using the F(...) macro.

Examples
Debug.ino.

Definition at line 105 of file Debug.hpp.

◆ DEBUGFN

#define DEBUGFN ( x)
Value:
do { \
DEBUG_LOCK_MUTEX \
DEBUG_OUT << DEBUG_FUNC_LOCATION << x << DEBUG_ENDL; \
} while (0)
#define DEBUG_FUNC_LOCATION
Definition Debug.hpp:64

Print an expression and its function (function name and line number) to the debug output if debugging is enabled.

The function name is saved in RAM.

Examples
Debug.ino.

Definition at line 115 of file Debug.hpp.

◆ DEBUGTIME

#define DEBUGTIME ( x)
Value:
do { \
DEBUG_LOCK_MUTEX \
unsigned long t = millis(); \
unsigned long h = t / (60UL * 60 * 1000); \
unsigned long m = (t / (60UL * 1000)) % 60; \
unsigned long s = (t / (1000UL)) % 60; \
unsigned long ms = t % 1000; \
const char *ms_zeros = ms > 99 ? "" : (ms > 9 ? "0" : "00"); \
DEBUG_OUT << '[' << h << ':' << m << ':' << s << '.' << ms_zeros << ms \
<< "]:\t" << x << DEBUG_ENDL; \
} while (0)
#define DEBUG_OUT
The debug output.

Print an expression and the time since startup to the debug output if debugging is enabled.

Format: [hours:minutes:seconds.milliseconds]

Examples
Debug.ino.

Definition at line 127 of file Debug.hpp.

◆ DEBUGVAL

#define DEBUGVAL ( ...)    DEBUGVALN(COUNT(__VA_ARGS__))(__VA_ARGS__)

Print multiple expressions and their values to the debug output if debugging is enabled.

For example, DEBUGVAL(1 + 1, digitalRead(2)) could print 1 + 1 = 2, digitalRead(2) = 0. A maximum of 10 expressions is supported. The expression strings are saved in PROGMEM using the F(...) macro.

Examples
Debug.ino.

Definition at line 175 of file Debug.hpp.