arduino-audio-tools
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
AudioActions Class Reference

A simple class to assign functions to gpio pins e.g. to implement a simple navigation control or volume control with buttons. More...

#include <AudioActions.h>

Classes

struct  Action
 

Public Types

enum  ActiveLogic : uint8_t { ActiveLow , ActiveHigh , ActiveChange , ActiveTouch }
 

Public Member Functions

 AudioActions (bool useInterrupt=false)
 Default constructor.
 
virtual ~AudioActions ()
 deletes all actions
 
void add (Action &action)
 Adds an Action.
 
void add (int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogic=ActiveLow, void *ref=nullptr)
 Adds an action.
 
void add (int pin, void(*actionOn)(bool pinStatus, int pin, void *ref), void(*actionOff)(bool pinStatus, int pin, void *ref), ActiveLogic activeLogicPar=ActiveLow, void *ref=nullptr)
 Adds an action.
 
void clear ()
 
ActionfindAction (int id)
 Determines the action for the pin/id.
 
int findActionIdx (int id)
 Determines the action for the pin/id.
 
void processActions ()
 Execute all actions if the corresponding pin is low To minimize the runtime: With each call we process a different pin.
 
void processAllActions ()
 Execute all actions.
 
void setDebounceDelay (int value)
 Defines the debounce delay.
 
void setEnabled (int pin, bool enabled)
 enable/disable pin actions
 
void setPinMode (bool active)
 setup pin mode when true
 
void setReadCallback (std::function< bool(int)> read_cb_par)
 Sets a callback function to read the pin state.
 
void setTouchLimit (int value)
 Defines the touch limit (Default 20)
 
void setUsePinInterrupt (bool active)
 Use interrupts instead of processActions() call in loop.
 

Protected Member Functions

void insertAction (Action &action)
 
void setupPin (int pin, ActiveLogic logic)
 

Static Protected Member Functions

static void audioActionsISR ()
 

Protected Attributes

Vector< Action * > actions {0}
 
int debounceDelayValue = 500
 
std::function< bool(int)> read_cb = nullptr
 
int touchLimit = 20
 
bool use_pin_interrupt = false
 
bool use_pin_mode = true
 

Detailed Description

A simple class to assign functions to gpio pins e.g. to implement a simple navigation control or volume control with buttons.

Member Enumeration Documentation

◆ ActiveLogic

Enumerator
ActiveLow 
ActiveHigh 
ActiveChange 
ActiveTouch 

Constructor & Destructor Documentation

◆ AudioActions()

AudioActions ( bool  useInterrupt = false)
inline

Default constructor.

◆ ~AudioActions()

virtual ~AudioActions ( )
inlinevirtual

deletes all actions

Member Function Documentation

◆ add() [1/3]

void add ( Action action)
inline

Adds an Action.

◆ add() [2/3]

void add ( int  pin,
void(*)(bool pinStatus, int pin, void *ref)  actionOn,
ActiveLogic  activeLogic = ActiveLow,
void ref = nullptr 
)
inline

Adds an action.

◆ add() [3/3]

void add ( int  pin,
void(*)(bool pinStatus, int pin, void *ref)  actionOn,
void(*)(bool pinStatus, int pin, void *ref)  actionOff,
ActiveLogic  activeLogicPar = ActiveLow,
void ref = nullptr 
)
inline

Adds an action.

◆ audioActionsISR()

static void audioActionsISR ( )
inlinestaticprotected

◆ clear()

void clear ( )
inline

◆ findAction()

Action * findAction ( int  id)
inline

Determines the action for the pin/id.

◆ findActionIdx()

int findActionIdx ( int  id)
inline

Determines the action for the pin/id.

◆ insertAction()

void insertAction ( Action action)
inlineprotected

◆ processActions()

void processActions ( )
inline

Execute all actions if the corresponding pin is low To minimize the runtime: With each call we process a different pin.

◆ processAllActions()

void processAllActions ( )
inline

Execute all actions.

◆ setDebounceDelay()

void setDebounceDelay ( int  value)
inline

Defines the debounce delay.

◆ setEnabled()

void setEnabled ( int  pin,
bool  enabled 
)
inline

enable/disable pin actions

◆ setPinMode()

void setPinMode ( bool  active)
inline

setup pin mode when true

◆ setReadCallback()

void setReadCallback ( std::function< bool(int)>  read_cb_par)
inline

Sets a callback function to read the pin state.

◆ setTouchLimit()

void setTouchLimit ( int  value)
inline

Defines the touch limit (Default 20)

◆ setupPin()

void setupPin ( int  pin,
ActiveLogic  logic 
)
inlineprotected

◆ setUsePinInterrupt()

void setUsePinInterrupt ( bool  active)
inline

Use interrupts instead of processActions() call in loop.

Member Data Documentation

◆ actions

Vector<Action*> actions {0}
protected

◆ debounceDelayValue

int debounceDelayValue = 500
protected

◆ read_cb

std::function<bool(int)> read_cb = nullptr
protected

◆ touchLimit

int touchLimit = 20
protected

◆ use_pin_interrupt

bool use_pin_interrupt = false
protected

◆ use_pin_mode

bool use_pin_mode = true
protected

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