I’m reminded by the mention of byte-instead-of-bit and resetting after time of an algorithm for switch debouncing I heard about:
Keep a state of some number of bits (the word size of the microcontroller you’re implementing it on, say), which are regular samples of the state of the switch (that is, state ← (state << 1) | (current_input ? 1 : 0)). Then consider the switch to be logically pressed if any of the bits are 1 (that is, the entire state is not zero) or perhaps if all of them are (whatever fits the application better). This produces a minimum pulse width of sample rate × number of state bits; it’s just a nicely simple way of filtering the digital signal using CPU primitives.
Or, as as David pointed out, treat it as a bozo byte.
I’m reminded by the mention of byte-instead-of-bit and resetting after time of an algorithm for switch debouncing I heard about:
Keep a state of some number of bits (the word size of the microcontroller you’re implementing it on, say), which are regular samples of the state of the switch (that is,
state ← (state << 1) | (current_input ? 1 : 0)
). Then consider the switch to be logically pressed if any of the bits are 1 (that is, the entire state is not zero) or perhaps if all of them are (whatever fits the application better). This produces a minimum pulse width of sample rate × number of state bits; it’s just a nicely simple way of filtering the digital signal using CPU primitives.