Hey there!
While working on a project of mine I found a neat little snippet online that helps to debug variables over serial.
It includes:
-the time it happened
-the function name
-the line number
-the variable name
-the variable value
All automatically!
Maybe this is useful for other people too, so I'm leaving it here.
Here it is:
Here is an example of how I use it:
and here is the generated serial output:
Have fun!
While working on a project of mine I found a neat little snippet online that helps to debug variables over serial.
It includes:
-the time it happened
-the function name
-the line number
-the variable name
-the variable value
All automatically!
Maybe this is useful for other people too, so I'm leaving it here.
Here it is:
Code:
#ifndef DEBUGUTILS_H
#define DEBUGUTILS_H
#include <WProgram.h>
#ifdef DEBUG
#define DEBUG_PRINT(arg) \
Serial.print(millis()); \
Serial.print(": "); \
Serial.print(__PRETTY_FUNCTION__); \
Serial.print(' '); \
Serial.print(__LINE__); \
Serial.print(' '); \
Serial.print(#arg); \
Serial.print(" = "); \
Serial.println(arg);
#else
#define DEBUG_PRINT(arg)
#endif
#endif
Here is an example of how I use it:
Code:
DEBUG_PRINT1(AudioMemoryUsage());
DEBUG_PRINT1(AudioMemoryUsageMax());
DEBUG_PRINT1(AudioProcessorUsage());
DEBUG_PRINT1(AudioProcessorUsageMax());
and here is the generated serial output:
Code:
160261: void loop() 92 AudioMemoryUsage() = 3
160261: void loop() 93 AudioMemoryUsageMax() = 7
160261: void loop() 94 AudioProcessorUsage() = 17
160261: void loop() 95 AudioProcessorUsageMax() = 19
Have fun!