rppal
rppal copied to clipboard
Many edge detection "interrupts" but level remains the same
I was debugging some weirdness in my app ("piggui") and added some logging (println!()) to when it detects edges on inputs.
input.set_async_interrupt(Trigger::Both, move |level| {
callback(bcm_pin_number, level == Level::High)
})
I'm using it with a pretty crappy button, that I imagine it has quite a bit of HW bounce in it. So I imagined a flurry of high/low/high/low level changes in short succession.
When testing however:
- Sometimes it works "cleanly".
- Other times I get a bunch of level changes that report the same level, something like:
- low
- low
- high
- 25 lows in succession
- high etc.
So, while I expected "bounce" I didn't expect the interrupt to report multiple level changes in short succession with the same level being reported twice in a row.
- Is that related to how the HW works (e.g. HW detects an edge, and by the time the level is read, it's back to where it was?)?
- Is there anything that should be done in rppal about that?
- Or should I just implement my own filter to detect edges in the reported level?
Thanks for clarifying what best to do.