Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Oh, that (waiting for all fingers to be detected) does indeed change how I would approach the scenario, and blew past me in my initial reading.

That all said, even with 100ms cycles I would hardware debounce the inputs, capture the keystrokes with an ISR to set some semaphore variables, and then create a 100ms loop that checks the current value (and resets) those semaphore variables.

Eliminating switch bounce allows far more elegant software handling of the values you're reading, so Ken could turn his attention and development energy towards things like sliding time windows (100ms starting from the first keydown, for example) instead of trying to boil the ocean cancelling bounces.



Yeah, the 100ms wait after stability probably avoids any need to debounce. You need to debounce if you want to detect both keypress and keyrelease events reliably, though.

For mass-production products it's cheaper to add 100 lines of code to your firmware than to add a resistor to your PCB, much less a diode, capacitor, and two resistors, but for prototypes and low-volume designs it's less clear.

WRT ISRs, plausibly in this case the microcontroller can just poll instead of using interrupts. You probably don't mean "semaphore"; semaphores are a blocking construct, and if there's one thing you can't do in an ISR, it's block.


You're right, I should have chosen better words.

I merely meant setting a flag bit from 0 to 1, later to be picked up by your loop. Since actual semaphore was communicated with flags...

I have yet to see the perfect software debounce algorithm. I've come to believe that it is a Sisyphean task. Meanwhile, Schottky diodes are extremely well-suited to the task.

You might consider 100 lines worth of complexity to make a switch work to be free, but I won't lose any sleep believing otherwise.


Most of software is Sisyphean. 100 lines of code doesn't add any cost to your BOM, just NRE, and it's easier to simulate.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: