Control Surface  1.1.1
MIDI Control Surface library for Arduino
Macros

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

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

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.

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

◆ DEBUG

#define DEBUG (   x)
Value:
do { \
DEBUG_OUT << x << DEBUG_ENDL; \
} while (0)

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

Examples
Debug.ino.

Definition at line 75 of file Debug.hpp.

◆ DEBUGREF

#define DEBUGREF (   x)
Value:
do { \
DEBUG_OUT << F(DEBUG_LOCATION) << x << DEBUG_ENDL; \
} while (0)

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

◆ DEBUGFN

#define DEBUGFN (   x)
Value:
do { \
DEBUG_OUT << DEBUG_FUNC_LOCATION << x << DEBUG_ENDL; \
} while (0)

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

◆ DEBUGTIME

#define DEBUGTIME (   x)
Value:
do { \
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 104 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 151 of file Debug.hpp.

DEBUG_LOCATION
#define DEBUG_LOCATION
Definition: Debug.hpp:62
DEBUG_ENDL
#define DEBUG_ENDL
Definition: Debug.hpp:48
DEBUG_FUNC_LOCATION
#define DEBUG_FUNC_LOCATION
Definition: Debug.hpp:60
MIDI_Notes::F
constexpr int8_t F
Definition: Notes.hpp:23