Edit: updated with simple proof of concept
I’m experimenting with a state machine interface design on the POD (libDaisy) and running into some weird behavior. Maybe I’m missing something obvious and/or just need to dig more into the docs. A second pair of eyes, with experience, may help. I have tried the Switch, LED, and, Encoder sample programs without issue. Maybe I’m running into a timing issue?
The purpose of this program:
- At startup, state is INIT and led should be light white.
- On button press, LED to light red, state is PRESSED
3a. If button released, wait for timeout, then reset LED to light white, state to INIT
3b. If button held longer than 2 seconds, LED to bright red, state to HELD
- If button released, wait for timeout, then reset LED to light white, state to INIT
The current code is at https://github.com/angrycloud/Switch-States/blob/main/Tape.cpp
What I’m seeing during testing:
- led lit to light white after delay, expected
- short press clears led, back to white after delay
- after held press, led resets to white again, subsequent press is bright red.
I’ve tried processing the HID controls in the audio callback as well as the main loop but I can’t get anything consistent. Any suggestion or examples?