The buttonState type is used by the debounce functions to store state.
alias buttonState = { actualState : pinState, lastState : pinState, lastDebounceTime : uint32 }
actualState : Io:pinState | The actual state of the button |
lastState : Io:pinState | The last state of the button (on the previous update) |
lastDebounceTime : uint32 | The last debounce time |
Useful for initializing a <buttonState>, initializing the actualState to Io:low(), lastState to Io:low() && lastDebounceTime to 0
buttonState
Debounces the incoming Io:pinState signal by checking twice in a short period of time to make sure the pushbutton is definitely pressed.
(sig<pinState>, uint16, inout buttonState) -> sig<pinState>
incoming : sig<pinState> | The incoming signal |
delay : uint16 | The amount of time to wait in milliseconds before checking the pushbutton again |
buttonState : inout buttonState | Used to keep track of state between debounce calls |
A signal that will ideally reflect the actual state of the button.
Io:risingEdge, Io:fallingEdge, Io:edge
Debounces the incoming Io:pinState signal by checking twice in 50 ms to make sure the pushbutton is definitely pressed.
(sig<pinState>, inout buttonState) -> sig<pinState>
incoming : sig<pinState> | The incoming signal |
buttonState : inout buttonState | Used to keep track of state between debounce calls |
A signal that will ideally reflect the actual state of the button.
Io:risingEdge, Io:fallingEdge, Io:edge