AbleButtons
V0.4.0
Lightweight button library for Arduino.
Loading...
Searching...
No Matches
AbleButtons.h
Go to the documentation of this file.
1
/**
2
* @file AbleButtons.h The main include file for the Arduino Button library
3
* Extension (ABLE). Include this file in an Arduino program to access all the
4
* available button classes.
5
*
6
* It is recommended to then identify which button type is used with code
7
* similar to:
8
*
9
* #include <AbleButtons.h>
10
* ...
11
* using Button = AblePullupButton;
12
* using ButtonList = AblePullupButtonList;
13
* ...
14
* Button btn(BUTTON_PIN);
15
*
16
* @copyright Copyright (c) 2022 John Scott.
17
*/
18
#pragma once
19
#include "
Button.h
"
20
#include "
ButtonList.h
"
21
#include "
CallbackButton.h
"
22
23
//
24
// Pulldown buttons...
25
//
26
27
/**
28
* AblePulldownButton provides basic button is-pressed capability for buttons
29
* connected using pulldown resistor circuits. Button presses are debounced to
30
* provide a reliable push/released signal.
31
*/
32
using
AblePulldownButton
=
able::Button<able::PulldownResistorCircuit, able::DebouncedPin>
;
33
34
/**
35
* AblePulldownCallbackButton extends the basic debouced button with callbacks
36
* on pressed and on released events. When the button is pressed, a user-
37
* supplied on-pressed function can be called with the id of the button. The
38
* id can be used with the AblePulldownCallbackButtonList class to retrieve a
39
* pointer to the button generating the callback. Similarly, when the button is
40
* released, a user-supplied on-released function can be called.
41
*/
42
using
AblePulldownCallbackButton
=
able::CallbackButton<able::Button<able::PulldownResistorCircuit, able::DebouncedPin>
>;
///< Shorthand for a callback button using a pulldown resistor.
43
44
/**
45
* AblePulldownClickerButton provides additional button-click capability to the
46
* is-pressed capability of a basic button. A button click is a button-press,
47
* followed by a button-release. As with basic button capabilities, button
48
* presses are debounced to provide a reliable push/released signal.
49
*/
50
using
AblePulldownClickerButton
=
able::Button<able::PulldownResistorCircuit, able::ClickerPin>
;
51
52
/**
53
* AblePulldownCallbackClickerButton provides callback capability to a clicker
54
* button. A button click is a button-press, followed by a button-release. It
55
* also extends the button with callbacks on pressed and on released events.
56
* When the button is pressed, a user-supplied on-pressed function can be called
57
* with the id of the button. The id can be used with the
58
* AblePulldownCallbackClickerButtonList class to retrieve a pointer to the
59
* clicker button generating the callback. Similarly, when the button is
60
* released, a user-supplied on-released function can be called. As with basic
61
* button capabilities, button presses are debounced to provide a reliable push/
62
* released signal.
63
*/
64
using
AblePulldownCallbackClickerButton
=
able::CallbackButton<able::Button<able::PulldownResistorCircuit, able::ClickerPin>
>;
65
66
/**
67
* AblePulldownDirectButton provides basic button is-pressed capability for
68
* buttons connected using pulldown resistor circuits. Button presses are
69
* **not** debounced so provide potentially unreliable push/released signals
70
* when pressed or released due to contact bouncing.
71
*/
72
using
AblePulldownDirectButton
=
able::Button<able::PulldownResistorCircuit, able::Pin>
;
73
74
/**
75
* AblePulldownDoubleClickerButton provides additional double-click capability to
76
* the is-clicked capability of a clicker button. A button double-click is a
77
* second click (button-press, followed by a button-release) within the double-
78
* click time. As with other button capabilities, button presses are debounced
79
* to provide a reliable push/released signal.
80
*/
81
using
AblePulldownDoubleClickerButton
=
able::Button<able::PulldownResistorCircuit, able::DoubleClickerPin>
;
82
83
/**
84
* AblePulldownCallbackDoubleClickerButton provides additional double-click
85
* capability to the is-clicked capability of a clicker button. A button double-
86
* click is a second click (button-press, followed by a button-release) within
87
* the double-click time. As with other button capabilities, button presses are
88
* debounced to provide a reliable push/released signal.
89
*/
90
using
AblePulldownCallbackDoubleClickerButton
=
able::CallbackClickerButton<able::CallbackButton<able::Button<able::PulldownResistorCircuit, able::DoubleClickerPin>
>>;
91
92
//
93
// Pulldown button lists...
94
//
95
96
/**
97
* AblePulldownButtonList allows an array of AblePulldownButton objects to be
98
* managed together. Rather than calling begin() and handle() methods for each
99
* button, call the begin() and handle() method of the button list object, which
100
* calls the begin() and handle() methods of each button in the list.
101
*/
102
using
AblePulldownButtonList
=
able::ButtonList<AblePulldownButton>
;
103
104
/**
105
* AblePulldownButtonList allows an array of AblePulldownButton objects
106
* to be managed together. Rather than calling begin() and handle() methods for
107
* each button, call the begin() and handle() method of the button list object,
108
* which calls the begin() and handle() methods of each button in the list.
109
*/
110
using
AblePulldownButtonList
=
able::ButtonList<AblePulldownButton>
;
111
112
/**
113
* AblePulldownCallbackButtonList allows an array of AblePulldownCallbackButton
114
* objects to be managed together. Rather than calling begin() and handle()
115
* methods for each button, call the begin() and handle() method of the button
116
* list object, which calls the begin() and handle() methods of each button in
117
* the list.
118
*/
119
using
AblePulldownCallbackButtonList
=
able::ButtonList<AblePulldownCallbackButton>
;
120
121
/**
122
* AblePulldownClickerButtonList allows an array of AblePulldownClickerButton
123
* objects to be managed together. Rather than calling begin() and handle()
124
* methods for each button, call the begin() and handle() method of the button
125
* list object, which calls the begin() and handle() methods of each button in
126
* the list.
127
*/
128
using
AblePulldownClickerButtonList
=
able::ButtonList<AblePulldownClickerButton>
;
129
130
/**
131
* AblePulldownCallbackClickerButtonList allows an array of
132
* AblePulldownCallbackClickerButton objects to be managed together. Rather than
133
* calling begin() and handle() methods for each button, call the begin() and
134
* handle() method of the button list object, which calls the begin() and
135
* handle() methods of each button in the list.
136
*/
137
using
AblePulldownCallbackClickerButtonList
=
able::ButtonList<AblePulldownCallbackClickerButton>
;
138
139
/**
140
* AblePulldownDirectButtonList allows an array of AblePulldownDirectButton
141
* objects to be managed together. Rather than calling begin() and handle()
142
* methods for each button, call the begin() and handle() method of the button
143
* list object, which calls the begin() and handle() methods of each button in
144
* the list.
145
*/
146
using
AblePulldownDirectButtonList
=
able::ButtonList<AblePulldownDirectButton>
;
147
148
/**
149
* AblePulldownDoubleClickerButtonList allows an array of AblePulldownDoubleClickerButton
150
* objects to be managed together. Rather than calling begin() and handle()
151
* methods for each button, call the begin() and handle() method of the button
152
* list object, which calls the begin() and handle() methods of each button in
153
* the list.
154
*/
155
using
AblePulldownDoubleClickerButtonList
=
able::ButtonList<AblePulldownDoubleClickerButton>
;
156
157
/**
158
* AblePulldownCallbackDoubleClickerButtonList allows an array of
159
* AblePulldownCallbackDoubleClickerButton objects to be managed together. Rather
160
* than calling begin() and handle() methods for each button, call the begin()
161
* and handle() method of the button list object, which calls the begin() and
162
* handle() methods of each button in the list.
163
*/
164
using
AblePulldownCallbackDoubleClickerButtonList
=
able::ButtonList<AblePulldownCallbackDoubleClickerButton>
;
165
166
//
167
// Pull-up buttons...
168
//
169
170
/**
171
* AblePullupButton provides basic button is-pressed capability for buttons
172
* connected using pull-up resistor circuits. Button presses are debounced to
173
* provide a reliable push/released signal.
174
*/
175
using
AblePullupButton
=
able::Button<able::PullupResistorCircuit, able::DebouncedPin>
;
176
177
/**
178
* AblePullupCallbackButton extends the basic debouced button with callbacks
179
* on pressed and on released events. When the button is pressed, a user-
180
* supplied on-pressed function can be called with the id of the button. The
181
* id can be used with the AblePullupCallbackButtonList class to retrieve a
182
* pointer to the button generating the callback. Similarly, when the button is
183
* released, a user-supplied on-released function can be called.
184
*/
185
using
AblePullupCallbackButton
=
able::CallbackButton<able::Button<able::PullupResistorCircuit, able::DebouncedPin>
>;
///< Shorthand for a callback button using a pulldown resistor.
186
187
/**
188
* AblePullupClickerButton provides additional button-click capability to the
189
* is-pressed capability of a basic button. A button click is a button-press,
190
* followed by a button-release. As with basic button capabilities, button
191
* presses are debounced to provide a reliable push/released signal.
192
*/
193
using
AblePullupClickerButton
=
able::Button<able::PullupResistorCircuit, able::ClickerPin>
;
194
195
/**
196
* AblePullupCallbackClickerButton provides callback capability to a clicker
197
* button. A button click is a button-press, followed by a button-release. It
198
* also extends the button with callbacks on pressed and on released events.
199
* When the button is pressed, a user-supplied on-pressed function can be called
200
* with the id of the button. The id can be used with the
201
* AblePullupCallbackClickerButtonList class to retrieve a pointer to the
202
* clicker button generating the callback. Similarly, when the button is
203
* released, a user-supplied on-released function can be called. As with basic
204
* button capabilities, button presses are debounced to provide a reliable push/
205
* released signal.
206
*/
207
using
AblePullupCallbackClickerButton
=
able::CallbackButton<able::Button<able::PullupResistorCircuit, able::ClickerPin>
>;
///< Shorthand for clicker using pulldown resistor circuit.
208
209
/**
210
* AblePullupDirectButton provides basic button is-pressed capability for
211
* buttons connected using pull-up resistor circuits. Button presses are **not**
212
* debounced so provide potentially unreliable push/released signals when
213
* pressed or released due to contact bouncing.
214
*/
215
using
AblePullupDirectButton
=
able::Button<able::PullupResistorCircuit, able::Pin>
;
216
217
/**
218
* AblePullupDoubleClickerButton provides additional double-click capability to
219
* the is-clicked capability of a clicker button. A button double-click is a
220
* second click (button-press, followed by a button-release) within the double-
221
* click time. As with other button capabilities, button presses are debounced
222
* to provide a reliable push/released signal.
223
*/
224
using
AblePullupDoubleClickerButton
=
able::Button<able::PullupResistorCircuit, able::DoubleClickerPin>
;
225
226
/**
227
* AblePullupCallbackDoubleClickerButton provides additional double-click capability to
228
* the is-clicked capability of a clicker button. A button double-click is a
229
* second click (button-press, followed by a button-release) within the double-
230
* click time. As with other button capabilities, button presses are debounced
231
* to provide a reliable push/released signal.
232
*/
233
using
AblePullupCallbackDoubleClickerButton
=
able::CallbackClickerButton<able::CallbackButton<able::Button<able::PullupResistorCircuit, able::DoubleClickerPin>
>>;
234
235
//
236
// Pull-up button lists...
237
//
238
239
/**
240
* AblePullupButtonList allows an array of AblePullupButton objects to be
241
* managed together. Rather than calling begin() and handle() methods for each
242
* button, call the begin() and handle() method of the button list object, which
243
* calls the begin() and handle() methods of each button in the list.
244
*/
245
using
AblePullupButtonList
=
able::ButtonList<AblePullupButton>
;
///< Handler for list of AblePullupButton objects.
246
247
/**
248
* AblePullupCallbackButtonList allows an array of AblePullupCallbackButton
249
* objects to be managed together. Rather than calling begin() and handle()
250
* methods for each button, call the begin() and handle() method of the button
251
* list object, which calls the begin() and handle() methods of each button in
252
* the list.
253
*/
254
using
AblePullupCallbackButtonList
=
able::ButtonList<AblePullupCallbackButton>
;
255
256
/**
257
* AblePullupClickerButtonList allows an array of AblePullupClickerButton
258
* objects to be managed together. Rather than calling begin() and handle()
259
* methods for each button, call the begin() and handle() method of the button
260
* list object, which calls the begin() and handle() methods of each button in
261
* the list.
262
*/
263
using
AblePullupClickerButtonList
=
able::ButtonList<AblePullupClickerButton>
;
264
265
/**
266
* AblePullupCallbackClickerButtonList allows an array of
267
* AblePullupCallbackClickerButton objects to be managed together. Rather than
268
* calling begin() and handle() methods for each button, call the begin() and
269
* handle() method of the button list object, which calls the begin() and
270
* handle() methods of each button in the list.
271
*/
272
using
AblePullupCallbackClickerButtonList
=
able::ButtonList<AblePullupCallbackClickerButton>
;
///< Handler for list of AblePulldownCallbackClicker objects.
273
274
/**
275
* AblePullupDirectButtonList allows an array of AblePullupDirectButton objects
276
* to be managed together. Rather than calling begin() and handle() methods for
277
* each button, call the begin() and handle() method of the button list object,
278
* which calls the begin() and handle() methods of each button in the list.
279
*/
280
using
AblePullupDirectButtonList
=
able::ButtonList<AblePullupDirectButton>
;
281
282
/**
283
* AblePullupDoubleClickerButtonList allows an array of AblePullupDoubleClickerButton
284
* objects to be managed together. Rather than calling begin() and handle()
285
* methods for each button, call the begin() and handle() method of the button
286
* list object, which calls the begin() and handle() methods of each button in
287
* the list.
288
*/
289
using
AblePullupDoubleClickerButtonList
=
able::ButtonList<AblePullupDoubleClickerButton>
;
290
291
/**
292
* AblePullupCallbackDoubleClickerButtonList allows an array of
293
* AblePullupCallbackDoubleClickerButton objects to be managed together. Rather
294
* than calling begin() and handle() methods for each button, call the begin()
295
* and handle() method of the button list object, which calls the begin() and
296
* handle() methods of each button in the list.
297
*/
298
using
AblePullupCallbackDoubleClickerButtonList
=
able::ButtonList<AblePullupCallbackDoubleClickerButton>
;
Button.h
Definition of the core Able Button template class.
ButtonList.h
Definitions of the ButtonList templae class.
CallbackButton.h
Definitions for handling callback functions.
able::Button
Core Button class.
Definition:
Button.h:22
able::ButtonList
Template for a list of buttons of the same type.
Definition:
ButtonList.h:20
able::CallbackButton
Callback button template to call a function if the button is pressed.
Definition:
CallbackButton.h:18
able::CallbackClickerButton
Callback clicker button template to call a function if the button is pressed.
Definition:
CallbackButton.h:136
AbleButtons
src
AbleButtons.h
Generated by
1.9.5