A lightweight library to control a shift register IC for generating debug signals ("pings") in multithreaded and multitasking microcontroller applications (Arduino-compatible).
shiftDebug provides a simple way to visualize the activity of individual threads or tasks using an external shift register. This is especially useful for debugging and analyzing concurrent operations, e.g., with a logic analyzer or oscilloscope.
- Control up to 16 outputs via SPI or
shiftOut. - Direct port manipulation for maximum speed.
- Visualize thread/task activity in real-time.
- Option to aggregate thread activity on channel 0.
- Simple API:
sendThreadStartSignal,sendThreadStopSignal,getStates. - Example sketches for a quick start.
Copy threadDebugShifter.h and threadDebugShifter.cpp into your project, or integrate as an Arduino library.
#include <threadDebugShifter.h>Initialization:
#define THREAD_DEBUG_LATCH_PIN A4
ThreadDebugShifter tD(THREAD_DEBUG_LATCH_PIN);
void setup() {
tD.begin();
tD.disableSumThreadActivityOnCh0(); // Optional
Serial.begin(115200);
}Signaling thread activity:
tD.sendThreadStartSignal(threadID); // e.g., tD.sendThreadStartSignal(1);
tD.sendThreadStopSignal(threadID); // e.g., tD.sendThreadStopSignal(1);Example:
See /examples/basicExample/basicExample.ino and /examples/serialParallelOut/serialParallelOut.ino for complete demo sketches.
ThreadDebugShifter(uint8_t latchPin)void begin()void sendThreadStartSignal(uint8_t threadID)void sendThreadStopSignal(uint8_t threadID)void disableDebugging()void enableSumThreadActivityOnCh0()void disableSumThreadActivityOnCh0()uint16_t getStates()
- Microcontroller with SPI support (e.g., Arduino, Feather)
- External shift register (e.g., 74HC595)
- Debugging via logic analyzer, oscilloscope, etc.
Author: JustSomeRandomDIYGuy
License: MIT License
Questions or suggestions?
Open an issue or submit a pull request!