Class daisy::Switch¶
#include <switch.h>
Public Types¶
Type | Name |
---|---|
enum | Polarity |
enum | Type |
Public Functions¶
Type | Name |
---|---|
void | Debounce () |
bool | FallingEdge () const |
void | Init (Pin pin, float update_rate, Type t, Polarity pol, GPIO::Pull pu=GPIO::Pull::PULLUP) |
void | Init (Pin pin, float update_rate=0.f) |
bool | Pressed () const |
bool | RawState () |
bool | RisingEdge () const |
void | SetUpdateRate (float update_rate) |
Switch () |
|
float | TimeHeldMs () const |
~Switch () |
Detailed Description¶
Generic Class for handling momentary/latching switches Inspired/influenced by Mutable Instruments (pichenettes) Switch classes
Author:
Stephen Hensley
Date:
December 2019
Public Types Documentation¶
enum Polarity¶
Specifies whether the pressed is HIGH or LOW.
enum Type¶
Specifies the expected behavior of the switch
Public Functions Documentation¶
function Debounce¶
Called at update_rate to debounce and handle timing for the switch. In order for events not to be missed, its important that the Edge/Pressed checks be made at the same rate as the debounce function is being called.
function FallingEdge¶
Returns:
true if the button was just released
function Init [½]¶
void daisy::Switch::Init (
Pin pin,
float update_rate,
Type t,
Polarity pol,
GPIO::Pull pu=GPIO::Pull::PULLUP
)
Initializes the switch object with a given port/pin combo.
Parameters:
pin
port/pin object to tell the switch which hardware pin to use.update_rate
Does nothing. Backwards compatibility until next breaking update.t
switch type Default: TYPE_MOMENTARYpol
switch polarity Default: POLARITY_INVERTEDpu
switch pull up/down Default: PULL_UP
function Init [2/2]¶
Simplified Init.
Parameters:
pin
port/pin object to tell the switch which hardware pin to use.update_rate
Left for backwards compatibility until next breaking change.
function Pressed¶
Returns:
true if the button is held down (or if the toggle is on)
function RawState¶
Returns:
true if the button is held down, without debouncing
function RisingEdge¶
Returns:
true if a button was just pressed.
function SetUpdateRate¶
Left for backwards compatability until next breaking change
Parameters:
update_rate
Doesn't do anything
function Switch¶
function TimeHeldMs¶
Returns:
the time in milliseconds that the button has been held (or toggle has been on)
function ~Switch¶
The documentation for this class was generated from the following file external-docs/libDaisy/src/hid/switch.h