JM9 XRCU Board 0.1.3a
Libraries API Reference
Loading...
Searching...
No Matches
Button Class Reference

Button Driver for XRCU. More...

#include <Buttons.h>

Public Types

enum  TransitionEdge { PRESSING , RELEASING }
 The edge of voltage level transition where a button should be deemed single clicked. More...
 

Public Member Functions

 Button (const uint32_t pin)
 Creates a new button at a certain pin.
 
 ~Button ()
 Destroys this button and release the resources it occupied.
 
void begin ()
 Activates this button.
 
void end ()
 Deactivates this button.
 
bool isClicked ()
 Checks whether this button is clicked.
 
void setSingleClickTransitionEdge (TransitionEdge edge)
 Sets the edge of voltage level transition where a button should be deemed single clicked.
 
void setPulseClickEnabled (const bool enabled)
 Sets whether pulse click is enabled.
 
void setPulseDelayStartPeriod (const unsigned long period)
 Sets the time delay between the button being "pressed and held" and the pulse click starts.
 
void setPulseClicksMinimumInterval (const unsigned long minInterval)
 Sets the minimum time separation between 2 consecutive pulse clicks.
 
void setSecureModeEnabled (const bool enabled)
 Sets whether secure mode is enabled.
 
void attachInterrupt (void(*callback)(void))
 Attaches an interrupt function to the button whenever its status is possibly changed.
 
void detachInterrupt ()
 Detaches the interrupt function from this button as set in attachInterrupt(...).
 

Static Public Member Functions

static void scheduledAllButtonsCallback ()
 The interrupt service routine to be run by JM9 XRCU System Callback at fixed intervals only.
 

Detailed Description

Button Driver for XRCU.

Author
YH Choi @ JM9

Member Enumeration Documentation

◆ TransitionEdge

The edge of voltage level transition where a button should be deemed single clicked.

Enumerator
PRESSING 

The button is deemed single clicked when the button is pressed.

RELEASING 

The button is deemed single clicked when the button is released after pressed.

Constructor & Destructor Documentation

◆ Button()

Button::Button ( const uint32_t pin)

Creates a new button at a certain pin.

Parameters
pinThe pin connected to this button.

Member Function Documentation

◆ attachInterrupt()

void Button::attachInterrupt ( void(* callback )(void))

Attaches an interrupt function to the button whenever its status is possibly changed.

Note that only 1 interrupt function could be attached to each button at a time. Attaching a new interrupt function will discard the older one.

Parameters
callbackThe function that is run when the button status is possibly changed.
See also
detachInterrupt(...)

◆ begin()

void Button::begin ( )

Activates this button.

No need to call this function if the button is one of the buttons soldered on XRCU PCB.

◆ detachInterrupt()

void Button::detachInterrupt ( )

Detaches the interrupt function from this button as set in attachInterrupt(...).

See also
attachInterrupt(...)

◆ end()

void Button::end ( )

Deactivates this button.

Only call this function on buttons that are externally connected to XRCU PCB.

◆ isClicked()

bool Button::isClicked ( )

Checks whether this button is clicked.

Returns
true if this button is deemed clicked under the current mode, false otherwise.

◆ scheduledAllButtonsCallback()

void Button::scheduledAllButtonsCallback ( )
static

The interrupt service routine to be run by JM9 XRCU System Callback at fixed intervals only.

Do not call this function in your application.

◆ setPulseClickEnabled()

void Button::setPulseClickEnabled ( const bool enabled)

Sets whether pulse click is enabled.

If pulse click is enabled, holding the button pressed will give continuous clicks.

Parameters
enabledtrue to enable pulse click, false to disable pulse click.
Warning
The behaviour is undefined if the button is pressed or released during this function call.

◆ setPulseClicksMinimumInterval()

void Button::setPulseClicksMinimumInterval ( const unsigned long minInterval)

Sets the minimum time separation between 2 consecutive pulse clicks.

Set this to 0 to disable this feature.

Parameters
minIntervalThe minimum time separation between 2 consecutive pulse clicks (in milliseconds).
Warning
The behaviour is undefined if the button is pressed or released during this function call.

◆ setPulseDelayStartPeriod()

void Button::setPulseDelayStartPeriod ( const unsigned long period)

Sets the time delay between the button being "pressed and held" and the pulse click starts.

Parameters
periodThe time delay between the button being "pressed and held" and the pulse click starts (in milliseconds).
Warning
The behaviour is undefined if the button is pressed or released during this function call.

◆ setSecureModeEnabled()

void Button::setSecureModeEnabled ( const bool enabled)

Sets whether secure mode is enabled.

Secure mode prevents user accidental misclicking other buttons by treating all buttons as not clicked when 2 or more buttons are pressed at the same time.

Parameters
enabledtrue to enable secure mode, false to disable secure mode.
Warning
The behaviour is undefined if any button is pressed or released during this function call.

◆ setSingleClickTransitionEdge()

void Button::setSingleClickTransitionEdge ( Button::TransitionEdge edge)

Sets the edge of voltage level transition where a button should be deemed single clicked.

Parameters
edgeThe edge of voltage level transition where a button should be deemed single clicked.
Warning
The behaviour is undefined if the button is pressed or released during this function call.

The documentation for this class was generated from the following files: