3 ms·
I've been using the perhaps-too-simple: - Button triggers interrupt - Interrupt starts a timer - Next time interrupt fires, take no action if the timer i
by the__alchemist 2y ago
I've been using the perhaps-too-simple:
- Button triggers interrupt
- Interrupt starts a timer
- Next time interrupt fires, take no action if the timer is running. (Or use a state variable of some sort)
Of note, this won't work well if the bounce interval is close to the expected actuation speed, or if the timeout interval isn't near this region.
- knodi123 2y ago> this won't work well if the bounce interval is close to the expected actuation speed lol, or you could do what my TV does- say "to hell with user experience" and use an interrupt timer anyway. If I hold down my volume-up button (The physical one on the TV!), I get a quick and fluid increase. But if I hammer the button 4 times per second, the volume still only goes up 1 ticke per second.
- nomel 2y agoLoosely related, my HiSense TV has a wifi remote that apparently sends separate key up and down events to the TV. If the wifi happens to go down while you're holding the volume up button, it never sees the "key up" so will just hold whatever button indefinitely, including the volume button, which is how I discovered it.
- nomel 2y agoThis is functionally identical to the capacitive approach. Pressing the button charges the cap whose voltage decays when released (starts the timer). If the button is pressed before it decays below the "release" threshold (timer expires), the cap is recharged (timer restarted).