https://github.com/pfeerick/debug-helper
https://github.com/pfeerick/debug-helper
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/pfeerick/debug-helper
- Owner: pfeerick
- License: mit
- Created: 2023-07-22T10:21:19.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2026-05-18T00:46:36.000Z (26 days ago)
- Last Synced: 2026-05-18T02:41:59.065Z (26 days ago)
- Language: C
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DebugHelper
Zero-overhead conditional debug macros for Arduino, ESP8266, and ESP32.
When `DEBUG` is not enabled, every macro expands to `void(0)` — the compiler eliminates all debug code entirely, adding nothing to flash or RAM.
## Installation
**PlatformIO** — add to `platformio.ini`:
```ini
lib_deps =
https://github.com/pfeerick/debug-helper.git
```
**Arduino IDE** — install via Library Manager (search for `DebugHelper`) or download the ZIP and use Sketch → Include Library → Add .ZIP Library.
## Usage
Define `DEBUG` and `DEBUG_OI` **before** including the header:
```cpp
#define DEBUG true // remove or set to false to strip all debug code
#define DEBUG_OI Serial // any Stream-compatible object (Serial, Serial1, etc.)
#include
```
### Macros
| Macro | Description |
|---|---|
| `DebugBegin(baud)` | Initialize the debug output stream |
| `DebugPrint(...)` | `print()` passthrough |
| `DebugPrintln(...)` | `println()` passthrough |
| `DebugPrintf(...)` | `printf()` passthrough |
| `DebugWrite(...)` | `write()` passthrough |
| `DebugFlush(...)` | `flush()` passthrough |
| `DebugInfo()` | Print platform info block (see below) |
### DebugInfo() output
`DebugInfo()` prints a formatted block to the debug stream. The content is platform-specific:
- **ESP8266** — core/SDK/boot version, chip ID, CPU frequency, flash details, sketch size & MD5, heap free & fragmentation
- **ESP32** — IDF version, chip model/revision/cores, CPU frequency, flash size, sketch size & MD5, heap free/min/max-alloc
- **Generic Arduino** — build date and time only
### Disabling debug
Set `DEBUG` to `false` or remove the define entirely. All macros expand to `void(0)` and the compiler generates no debug code.
## License
MIT