| ▲ | inigyou 2 hours ago | ||||||||||||||||
They didn't say how often the reads are - 50 reads could be only 5ms. | |||||||||||||||||
| ▲ | crote an hour ago | parent | next [-] | ||||||||||||||||
In practice switch bounce often lasts tens or even hundreds of milliseconds, and you need to space out the read process to cover the entire bouncing process if you want to avoid registering fake presses. Using basic averaging means your minimum input latency is going to be ~half your bounce time - which is often way too high for it to feel like real-time input. If you want to achieve low-latency input, "act on first edge, then ignore for the switch bounce period" is a far better approach. It also conveniently solves the "press, then release within bounce period" problem where an averaging algorithm would completely ignore the button press. | |||||||||||||||||
| ▲ | mrob an hour ago | parent | prev | next [-] | ||||||||||||||||
Latency is cumulative, so avoidable latency is never acceptable. Maybe the hardware will change. Maybe somebody will run your software in an emulator. That 5ms could be enough to push the total latency into the "annoying" level. And even with no additional latency, 5ms is perceptible in some cases anyway. Microsoft Research has a video demonstration: | |||||||||||||||||
| |||||||||||||||||
| ▲ | PunchyHamster 14 minutes ago | parent | prev [-] | ||||||||||||||||
Doesn't matter, their way is terrible one that adds latency for no reason. There are 2 things here worth paying attention * first "bounce" is user action * last "bounce" is stop of user action. You can run action on first bounce then just ignore the button for whatver debounce period you deem satisfactory. But adding delay to start action is always wrong answer for debouncing. Now the harder problem is the off of the button, especially if hold is also an action but "be off for at least few ms" usually handles it well and off time is not lag user feels | |||||||||||||||||