diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..687f872 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vscode/ + diff --git a/README.md b/README.md index bd8dcd6..23ea200 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Example: ```C++ int i = 1; float pi = 3.1459; -Debug.print(DBG_VERBOSE, "i = %d, pi = %f", i, pi); +DEBUG_VERBOSE("i = %d, pi = %f", i, pi); ``` **Note**: The output of floating point numbers (`%f`) does NOT work on [ArduinoCore-avr](https://github.com/arduino/ArduinoCore-avr). @@ -43,7 +43,7 @@ Parameter debug_level in order of lowest to highest priority are : `DBG_NONE`, ` Return type: void. Example: -``` +```C++ Debug.setDebugLevel(DBG_VERBOSE); ``` ### Debug.setDebugOutputStream(Stream * stream) : @@ -52,7 +52,7 @@ By default, Output Stream is Serial. In advanced cases other objects could be ot Return type: void. Example: -``` +```C++ SoftwareSerial mySerial(10, 11); // RX, TX Debug.setDebugOutputStream(&mySerial); ``` @@ -63,9 +63,9 @@ By default, printing timestamp is off, unless turned on using this function call Return type: void. Example: -``` +```C++ Debug.timestampOn(); -Debug.print(DBG_VERBOSE, "i = %d", i); //Output looks like : [ 21007 ] i = 21 +DBG_VERBOSE("i = %d", i); //Output looks like : [ 21007 ] i = 21 ``` ### Debug.timestampOff() : @@ -74,9 +74,9 @@ Calling this function switches off the timestamp in the `Debug.print()` function Return type: void. Example: -``` +```C++ Debug.timestampOff(); -Debug.print(DBG_VERBOSE, "i = %d", i); //Output looks like : i = 21 +DEBUG_VERBOSE("i = %d", i); //Output looks like : i = 21 ``` ### Debug.newlineOn() : @@ -85,7 +85,7 @@ By default, a newline is sent Return type: void. Example: -``` +```C++ Debug.newlineOn(); ``` @@ -95,7 +95,7 @@ By default a newline is sent. Call this to shut that functionality off. Return type: void. Example: -``` +```C++ Debug.timestampOff(); ``` @@ -106,8 +106,8 @@ This function prints the message if parameter `debug_level` in the `Debug.print( Return type: void. Example: -``` +```C++ Debug.setDebugLevel(DBG_VERBOSE); int i = 0; -Debug.print(DBG_VERBOSE, "DBG_VERBOSE i = %d", i); +DEBUG_VERBOSE("DBG_VERBOSE i = %d", i); ``` diff --git a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino index 5837b52..dbc704c 100644 --- a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino +++ b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino @@ -24,7 +24,7 @@ void setup() { int i = 0; void loop() { - Debug.print(DBG_VERBOSE, "i = %d", i); + DEBUG_VERBOSE("i = %d", i); i++; delay(1000); } diff --git a/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino b/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino index ddfedfe..1806e90 100644 --- a/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino +++ b/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino @@ -8,7 +8,7 @@ void setup() { int i = 0; void loop() { - Debug.print(DBG_INFO, "i = %d", i); + DEBUG_INFO("i = %d", i); i++; delay(1000); } diff --git a/keywords.txt b/keywords.txt index e5c2020..d175771 100644 --- a/keywords.txt +++ b/keywords.txt @@ -17,6 +17,11 @@ setDebugOutputStream KEYWORD2 timestampOn KEYWORD2 timestampOff KEYWORD2 print KEYWORD2 +DEBUG_ERROR KEYWORD2 +DEBUG_WARNING KEYWORD2 +DEBUG_INFO KEYWORD2 +DEBUG_DEBUG KEYWORD2 +DEBUG_VERBOSE KEYWORD2 ####################################### # Constants (LITERAL1) diff --git a/src/Arduino_DebugUtils.h b/src/Arduino_DebugUtils.h index 335f1c5..73e6287 100644 --- a/src/Arduino_DebugUtils.h +++ b/src/Arduino_DebugUtils.h @@ -93,4 +93,28 @@ class Arduino_DebugUtils { extern Arduino_DebugUtils Debug; +/************************************************************************************** + * DEFINE + **************************************************************************************/ + +#ifndef DEBUG_ERROR +# define DEBUG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__) +#endif + +#ifndef DEBUG_WARNING +# define DEBUG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__) +#endif + +#ifndef DEBUG_INFO +# define DEBUG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__) +#endif + +#ifndef DEBUG_DEBUG +# define DEBUG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__) +#endif + +#ifndef DEBUG_VERBOSE +# define DEBUG_VERBOSE(fmt, ...) Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__) +#endif + #endif /* ARDUINO_DEBUG_UTILS_H_ */