Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions DEBUG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PinChangeInterrupt library debug

This library already supports a local debug macro in `PinChangeInterruptSettings.h`:

- `__PCINT_DEBUG__` (default 0) controls `PCINT_DEBUG_PRINT(...)` which prints
with `Serial.println(F("..."))` when enabled.

Examples to enable:
- platformio.ini (per-environment):

[env:program_DiamexISP]
build_flags = -D__PCINT_DEBUG__=1

- Or define before including the library headers:

#define __PCINT_DEBUG__ 1
#include <PinChangeInterrupt.h>

Notes:
- Debug prints use `F("string")` to keep strings in flash (saves RAM).
- When disabled, `PCINT_DEBUG_PRINT(...)` expands to nothing.
29 changes: 23 additions & 6 deletions src/PinChangeInterruptSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ THE SOFTWARE.
// include guard
#pragma once

// Per-library debug control for PinChangeInterrupt.
// Set __PCINT_DEBUG__ to 1 to enable lightweight debug prints for this library.
// We use PCINT_DEBUG_PRINT(...) so other libraries are unaffected.
#ifndef __PCINT_DEBUG__
#define __PCINT_DEBUG__ 0
#endif

#if __PCINT_DEBUG__
#ifdef ARDUINO
#define PCINT_DEBUG_PRINT(...) Serial.println(F(__VA_ARGS__))
#else
#define PCINT_DEBUG_PRINT(...)
#endif
#else
#define PCINT_DEBUG_PRINT(...)
#endif

//================================================================================
// General Settings
//================================================================================
Expand Down Expand Up @@ -120,12 +137,12 @@ PCINT_CALLBACK(3, 19); /* Pin Interrupt 1 */
#endif

// deactivate crystal and reset pins by default
#if defined(PCINT_ENABLE_PCINT6)
#undef PCINT_ENABLE_PCINT6 // crystal
#endif
#if defined(PCINT_ENABLE_PCINT7)
#undef PCINT_ENABLE_PCINT7 // crystal
#endif
// #if defined(PCINT_ENABLE_PCINT6)
// #undef PCINT_ENABLE_PCINT6 // crystal
// #endif
// #if defined(PCINT_ENABLE_PCINT7)
// #undef PCINT_ENABLE_PCINT7 // crystal
// #endif
#if defined(PCINT_ENABLE_PCINT14)
#undef PCINT_ENABLE_PCINT14 // reset
#endif
Expand Down