AbleButtons V0.2.0
Lightweight button library for Arduino.
 
Loading...
Searching...
No Matches
Pressed.cpp
Go to the documentation of this file.
1/**
2 * @file Pressed.cpp Definition of the on-pressed callback function. This
3 * function performs some assertions on the state of the button list and the
4 * individual button pressed when a button is pressed.
5 *
6 * @copyright Copyright (c) 2022 John Scott
7 */
8#include "TestAbleButton.h"
9#include "Utils.h"
10
11Button *pressedBtn; ///< Button just pressed.
12
13/**
14 * Callback function for button pressed.
15 *
16 * @param btn The button generaing the event.
17 */
19 checkButtonListIntegrity();
20
21 if(btn) {
23 checkButtonListJustPressed(btn);
24
26 } else {
27 assert(btn != 0);
28 }
29}
30
31/**
32 * Callback function for button held.
33 *
34 * @param btn The button generaing the event.
35 */
37 checkButtonListIntegrity();
38 if(btn) {
40 checkButtonListJustHeld(btn);
41 } else {
42 assert(btn != 0);
43 }
44}
Button btn(BUTTON_PIN)
The button to check.
void checkButtonJustHeld(Button *btn)
Check button that has just been held.
Definition: CheckButton.cpp:57
void checkButtonJustPressed(Button *btn)
Check state of a pressed button...
Definition: CheckButton.cpp:25
void onHeld(Button *btn)
Callback function for button held.
Definition: Pressed.cpp:36
void onPressed(Button *btn)
Callback function for button pressed.
Definition: Pressed.cpp:18
Button * pressedBtn
Button just pressed.
Definition: Pressed.cpp:11
Declarations for the TestAbleButton program.
Utility function declarations.
#define assert(e)
Macro to assert using FlashStringHelper to reduce memory usage.
Definition: Utils.h:30
Core Button class.
Definition: Button.h:22