JuanPTM / debugUtils

Arduino debug library, based on preprocessing macros.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DebugUtils Build Status

Description

DebugUtils is a macro file to simplify the arduino debug code, that way you can simply enable/disable the serial output of your sketch with a define.


Instalation

Drop the folder "DebugUtils/DebugUtils.h" under the next directory.

path-to-arduino/libraries/DebugUtils/DebugUtils.h

Usage

Verbose mode.

#define DEBUG 3
#include "DebugUtils.h"

void setup() {
  Serial.begin(9600);
  DEBUG_PRINT(millis());
  DEBUG_PRINTLN(millis());
}

void loop() {
  DEBUG_PRINT("debug sin Salto linea || ");
  DEBUG_PRINTLN(millis());
  DEBUG_VERBOSE("hola");
  delay(1000);
}

In this mode we will have an output like this:

Verbose Output

We can see that in this mode, the debug print the next information for all of the DEBUG_XXXX(msg) used:

millis(): function filePath:Line MsgOnThePrintMethod

Print with verbose warning enable Mode.

#define DEBUG 2
#include "DebugUtils.h"

void setup() {
  Serial.begin(9600);
  DEBUG_PRINT(millis());
  DEBUG_PRINTLN(millis());
}

void loop() {
  DEBUG_PRINT("debug sin Salto linea || ");
  DEBUG_PRINTLN(millis());
  DEBUG_VERBOSE("hola");
  delay(1000);
}

In this mode we will have an output like this:

Print Mode Output

We can see that in this mode, we have the DEBUG_PRINT(msg) and DEBUG_PRINTLN(msg) which only differ on the new line after the message. In this mode the DEBUG_VERBOSE(msg) will change to the next message:

Not showing verbose mode on line: Line due to not verbose configured.

Simple print mode.

#define DEBUG 1
#include "DebugUtils.h"

void setup() {
  Serial.begin(9600);
  DEBUG_PRINT(millis());
  DEBUG_PRINTLN(millis());
}

void loop() {
  DEBUG_PRINT("debug sin Salto linea || ");
  DEBUG_PRINTLN(millis());
  DEBUG_VERBOSE("hola");
  delay(1000);
}

In this mode we will have an output like this:

No image available right now

We can see that in this mode, we have the DEBUG_PRINT(msg) and DEBUG_PRINTLN(msg) which only differ on the new line after the message. In this mode the DEBUG_VERBOSE(msg) will not show any message.


Quiet Mode.

#define DEBUG 0
#include "DebugUtils.h"

void setup() {
  Serial.begin(9600);
  DEBUG_PRINT(millis());
  DEBUG_PRINTLN(millis());
}

void loop() {
  DEBUG_PRINT("debug sin Salto linea || ");
  DEBUG_PRINTLN(millis());
  DEBUG_VERBOSE("hola");
  delay(1000);
}

In this mode we will have an output like this:

Disable Print Mode Output

In this mode, our program won't write anything of our DEBUG_XXXX(msg) on the console, but we still can print with the Serial methods.


Contact

Feel free to contact if you have any doubt.


Thanks

All information come from:


About

Arduino debug library, based on preprocessing macros.

License:GNU General Public License v3.0


Languages

Language:C++ 100.0%