Control Surface master MIDI Control Surface library for Arduino

## Detailed Description

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

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. More...

#define DEBUG(x)
Print an expression to the debug output if debugging is enabled. More...

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

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

#define DEBUGTIME(x)
Print an expression and the time since startup to the debug output if debugging is enabled. More...

#define DEBUGVAL(...)   DEBUGVALN(COUNT(__VA_ARGS__))(__VA_ARGS__)
Print multiple expressions and their values to the debug output if debugging is enabled. More...

## ◆ 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 92 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:55

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

Examples
Debug.ino.

Definition at line 98 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:69

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 108 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:67

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 118 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)

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 130 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 178 of file Debug.hpp.