Button
Types
alias buttonState

The buttonState type is used by the debounce functions to store state.

alias buttonState = { actualState : pinState, lastState : pinState, lastDebounceTime : uint32 }
Members
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

Variables
state

Useful for initializing a <buttonState>, initializing the actualState to Io:low(), lastState to Io:low() && lastDebounceTime to 0

Type
buttonState
Functions
debounceDelay

Debounces the incoming Io:pinState signal by checking twice in a short period of time to make sure the pushbutton is definitely pressed.

Type Signature
(sig<pinState>, uint16, inout buttonState) -> sig<pinState>
Parameters
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

Returns

A signal that will ideally reflect the actual state of the button.

See Also

Io:risingEdge, Io:fallingEdge, Io:edge

debounce

Debounces the incoming Io:pinState signal by checking twice in 50 ms to make sure the pushbutton is definitely pressed.

Type Signature
(sig<pinState>, inout buttonState) -> sig<pinState>
Parameters
incoming : sig<pinState>

The incoming signal

buttonState : inout buttonState

Used to keep track of state between debounce calls

Returns

A signal that will ideally reflect the actual state of the button.

See Also

Io:risingEdge, Io:fallingEdge, Io:edge