|
arduino-audio-tools
|
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 |
| Action definition per pin. More... | |
Public Types | |
| enum | ActiveLogic : uint8_t { ActiveLow , ActiveHigh , ActiveChange , ActiveTouch } |
| Defines the logic for the action execution. More... | |
Public Member Functions | |
| AudioActions (bool useInterrupt=false) | |
| Default constructor. | |
| virtual | ~AudioActions () |
| deletes all actions | |
| void | add (Action &action) |
| Adds an Action. | |
| void | add (digital_pin_t pin, void(*actionOn)(bool pinStatus, digital_pin_t pin, void *ref), ActiveLogic activeLogic=ActiveLow, void *ref=nullptr) |
| Adds an action. | |
| void | add (digital_pin_t pin, void(*actionOn)(bool pinStatus, digital_pin_t pin, void *ref), void(*actionOff)(bool pinStatus, digital_pin_t pin, void *ref), ActiveLogic activeLogicPar=ActiveLow, void *ref=nullptr) |
| Adds an action. | |
| void | clear () |
| Action * | findActionById (int id) |
| Determines the action for the pin/id. | |
| Action * | findActionByPin (digital_pin_t pin) |
| 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. When interrupts are enabled, all actions are processed when a pin change is detected. | |
| void | processAllActions () |
| Execute all actions. | |
| void | setDebounceDelay (int value) |
| Defines the debounce delay. | |
| void | setEnabled (digital_pin_t pin, bool enabled) |
| enable/disable pin actions | |
| void | setPinMode (bool active) |
| setup pin mode when true | |
| void | setReadCallback (bool(*read_cb_par)(digital_pin_t, void *), void *ref=nullptr) |
| 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 *p) |
| void | setupInterrupt (digital_pin_t pin) |
| void | setupISR (digital_pin_t button) |
| Setup GPIO interrupt for a given pin. | |
| void | setupPin (digital_pin_t pin, ActiveLogic logic) |
Static Protected Member Functions | |
| static void | audioActionsISRZephyr (const struct device *dev, struct gpio_callback *cb, uint32_t pins) |
Protected Attributes | |
| Vector< Action * > | actions {0} |
| int | debounceDelayValue = 500 |
| volatile bool | interrupt_pending = false |
| bool(* | read_cb )(digital_pin_t, void *) = nullptr |
| void * | read_cb_ref = nullptr |
| int | touchLimit = 20 |
| bool | use_pin_interrupt = false |
| bool | use_pin_mode = true |
Static Protected Attributes | |
| static struct gpio_callback | button_cb_data |
| static AudioActions * | selfAudioActions = nullptr |
A simple class to assign functions to gpio pins e.g. to implement a simple navigation control or volume control with buttons.
|
inline |
Default constructor.
|
inlinevirtual |
deletes all actions
|
inline |
Adds an action.
|
inline |
Adds an action.
|
inlinestaticprotected |
|
inline |
|
inline |
|
inline |
Execute all actions if the corresponding pin is low. To minimize the runtime: With each call we process a different pin. When interrupts are enabled, all actions are processed when a pin change is detected.
|
inline |
Execute all actions.
|
inline |
enable/disable pin actions
Sets a callback function to read the pin state.
|
inlineprotected |
|
inlineprotected |
Setup GPIO interrupt for a given pin.
|
inlineprotected |
Use interrupts instead of processActions() call in loop.
|
staticprotected |
|
protected |
|
protected |
|
inlinestaticprotected |
|
protected |