AbleButtons V0.2.0
Lightweight button library for Arduino.
 
Loading...
Searching...
No Matches
TestAbleButton.h
Go to the documentation of this file.
1/**
2 * @file TestAbleButton.h Declarations for the TestAbleButton program. Included
3 * by all the modules to share program information.
4 *
5 * @copyright Copyright (c) 2022 John Scott
6 */
7#pragma once
8#include <AbleButtons.h>
9#include "Config.h"
10
11using Button = TESTABLE_USING_BUTTON; ///< Using the button defined by the circuit, callback and class.
12using ButtonList = TESTABLE_USING_BUTTONLIST; ///< Using the button list defined by the circuit, callback and class.
13
14#define BUTTON_A_PIN 2 ///< Connect button between this pin and ground.
15#define BUTTON_B_PIN 3 ///< Connect button using pulldown resistor circuit.
16
18 bool isPressed;
19 bool isHeld;
20 bool isIdle;
21#if TESTABLE_CLASS >= TESTABLE_CLICKER
22 bool isClicked;
23#endif
24#if TESTABLE_CLASS >= TESTABLE_DOUBLECLICKER
25 bool isDoubleClicked;
26#endif
27};
28
29//
30// Forward declarations of callback functions.
31//
32#if TESTABLE_CALLBACK
33void onEvent(Button::CALLBACK_EVENT, uint8_t);
34#endif
35void onPressed(Button *);
36void onReleased(Button *);
37void onHeld(Button *);
38void onIdle(Button *);
39
40//
41// Definitions of Button checks...
42//
43void checkButtonSetup(Button *btn);
51void displayButton(Button *btn, ButtonState &state, int index);
52
53//
54// Definitions of ButtonList checks...
55//
57void checkButtonListJustPressed(Button *btnPressed);
58void checkButtonListJustReleased(Button *btnReleased);
64
65//
66// Definitions of global variables...
67//
68extern Button btnA; ///< Button A
69extern Button btnB; ///< Button B
70extern Button *btns[]; ///< Array of buttons A and B
71extern ButtonList btnList; ///< Declaration of button list.
72extern Button *pressedBtn; ///< Button pressed event.
73extern Button *releasedBtn; ///< Button released event.
The main include file for the Arduino Button library Extension (ABLE).
Button btn(BUTTON_PIN)
The button to check.
Declarations to select which buttons we use.
#define TESTABLE_USING_BUTTONLIST
Using ButtonList to test.
Definition: Config.h:55
#define TESTABLE_USING_BUTTON
Using Button to test.
Definition: Config.h:53
void checkButtonListJustDoubleClicked(Button *btn)
Check ButtonList when button just double-clicked.
Definition: CheckList.cpp:104
void checkButtonJustClicked(Button *btn)
Check button that has just been clicked.
Definition: CheckButton.cpp:89
void checkButtonListIntegrity()
Check integrity of ButtonList invariants (always hold true).
Definition: CheckList.cpp:111
void onHeld(Button *)
Callback function for button held.
Definition: Pressed.cpp:36
Button btnA
Button A.
ButtonList btnList
Declaration of button list.
void checkButtonJustReleased(Button *btn)
Check button that has just been released.
Definition: CheckButton.cpp:41
void checkButtonJustHeld(Button *btn)
Check button that has just been held.
Definition: CheckButton.cpp:57
void onIdle(Button *)
Callback function for button idle.
Definition: Released.cpp:36
Button * releasedBtn
Button released event.
Definition: Released.cpp:11
Button * btns[]
Array of buttons A and B.
void checkButtonListJustClicked(Button *btn)
Check ButtonList when button just clicked.
Definition: CheckList.cpp:97
void checkButtonListSetup()
Check initial setup of the button list.
Definition: CheckList.cpp:12
Button btnB
Button B.
void checkButtonIntegrity(Button *btn, ButtonState &state)
Check integrity of Button invariants (always hold true).
void onEvent(Button::CALLBACK_EVENT, uint8_t)
Callback function for button events.
Definition: Callback.cpp:23
void checkButtonListJustReleased(Button *btnReleased)
Check ButtonList when button just released.
Definition: CheckList.cpp:63
void onReleased(Button *)
Callback function for button released.
Definition: Released.cpp:18
void checkButtonListJustIdle(Button *btn)
Check ButtonList when button just idle.
Definition: CheckList.cpp:90
void checkButtonJustIdle(Button *btn)
Check button that has just become idle.
Definition: CheckButton.cpp:73
void checkButtonListJustHeld(Button *btn)
Check ButtonList when button just held.
Definition: CheckList.cpp:83
void checkButtonListJustPressed(Button *btnPressed)
Check ButtonList when button just pressed.
Definition: CheckList.cpp:38
void checkButtonJustDoubleClicked(Button *btn)
Check button that has just been double-clicked.
void checkButtonJustPressed(Button *btn)
Check state of a pressed button...
Definition: CheckButton.cpp:25
Button * pressedBtn
Button pressed event.
Definition: Pressed.cpp:11
void onPressed(Button *)
Callback function for button pressed.
Definition: Pressed.cpp:18
Core Button class.
Definition: Button.h:22
Template for a list of buttons of the same type.
Definition: ButtonList.h:20