Button

Summary
Button
Types
buttonStateThe buttonState type is used by the debounce functions to store state.
Functions
stateReturns a new buttonState, initializing the actualState to Io:low(), lastState to Io:low() and lastDebounceTime to 0
debounceDelayDebounces the incoming Io:pinState signal by checking twice in a short period of time to make sure the pushbutton is definitely pressed.
debounceDebounces the incoming Io:pinState signal by checking twice in 50 ms to make sure the pushbutton is definitely pressed.

Types

buttonState

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

buttonState

Members

actualState : Io:pinStateThe actual state of the button
lastState : Io:pinStateThe last state of the button (on the previous update)
lastDebounceTime : uint32The last debounce time

Functions

state

Returns a new buttonState, initializing the actualState to Io:low(), lastState to Io:low() and lastDebounceTime to 0

Type Signature

() -> buttonState ref

Returns

A new buttonState

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, buttonState ref) -> sig<pinState>

Parameters

incoming : sig<pinState>The incoming signal
delay : uint16The amount of time to wait in milliseconds before checking the pushbutton again
buttonState : buttonState refUsed 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>, buttonState ref) -> sig<pinState>

Parameters

incoming : sig<pinState>The incoming signal
buttonState : buttonState refUsed 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

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