AbleButtons V0.4.0
Lightweight button library for Arduino.
 
Loading...
Searching...
No Matches
Config.h
Go to the documentation of this file.
1/**
2 * @file Config.h Declarations to select which buttons we use. Change the
3 * circuit, callback and class values to test different classes.
4 *
5 * @copyright Copyright (c) 2022 John Scott
6 */
7#pragma once
8#include <AbleButtons.h>
9
10//
11// Change these values based on pin connections...
12//
13#define NUM_BUTTONS 2 ///< The number of buttons to connect for testing.
14#define BUTTON_A_PIN 2 ///< Connect first button between this pin and ground.
15#define BUTTON_B_PIN 3 ///< Connect second button between this pin and ground.
16
17//
18// Change these values to test different combinations...
19//
20
21/// 0 = Pulldown; 1 = Pullup
22#define TESTABLE_CIRCUIT 1
23/// 0 = No Callback; 1 = Callback.
24#define TESTABLE_CALLBACK 1
25/// 0 = DirectButton; 1 = Button; 2 = ClickerButton; 3 = DoubleClickerButton
26#define TESTABLE_CLASS 3
27
28
29//
30// Helper macros to make button identification...
31//
32
33/// Set TESTABLE_CIRCUIT to this value to test pulldown circuits.
34#define TESTABLE_PULLDOWN 0
35/// Set TESTABLE_CIRCUIT to this value to test pullup circuits.
36#define TESTABLE_PULLUP 1
37
38/// Set TESTABLE_CLASS to this value to test Able...DirectButton
39#define TESTABLE_DIRECT 0
40/// Set TESTABLE_CLASS to this value to test Able...Button
41#define TESTABLE_BUTTON 1
42/// Set TESTABLE_CLASS to this value to test Able...ClickerButton
43#define TESTABLE_CLICKER 2
44/// Set TESTABLE_CLASS to this value to test Able...DoubleClickerButton
45#define TESTABLE_DOUBLECLICKER 3
46
47
48//
49// Configure which Button and ButtonList...
50//
51#if TESTABLE_CIRCUIT == TESTABLE_PULLUP
52# if TESTABLE_CALLBACK
53# if TESTABLE_CLASS == TESTABLE_BUTTON
54# define TESTABLE_USING_BUTTON AblePullupCallbackButton
55# define TESTABLE_USING_BUTTONLIST AblePullupCallbackButtonList
56# elif TESTABLE_CLASS == TESTABLE_CLICKER
57# define TESTABLE_USING_BUTTON AblePullupCallbackClickerButton
58# define TESTABLE_USING_BUTTONLIST AblePullupCallbackClickerButtonList
59# elif TESTABLE_CLASS == TESTABLE_DOUBLECLICKER
60 /// Using Button to test
61# define TESTABLE_USING_BUTTON AblePullupCallbackDoubleClickerButton
62 /// Using ButtonList to test
63# define TESTABLE_USING_BUTTONLIST AblePullupCallbackDoubleClickerButtonList
64# else
65# define TESTABLE_USING_BUTTON Unsupported
66# define TESTABLE_USING_BUTTONLIST Unsupported
67# endif /* TESTABLE_CLASS */
68# else /* Not TESTABLE_CALLBACK */
69# if TESTABLE_CLASS == TESTABLE_DIRECT
70# define TESTABLE_USING_BUTTON AblePullupDirectButton
71# define TESTABLE_USING_BUTTONLIST AblePullupDirectButtonList
72# elif TESTABLE_CLASS == TESTABLE_BUTTON
73# define TESTABLE_USING_BUTTON AblePullupButton
74# define TESTABLE_USING_BUTTONLIST AblePullupButtonList
75# elif TESTABLE_CLASS == TESTABLE_CLICKER
76# define TESTABLE_USING_BUTTON AblePullupClickerButton
77# define TESTABLE_USING_BUTTONLIST AblePullupClickerButtonList
78# elif TESTABLE_CLASS == TESTABLE_DOUBLECLICKER
79# define TESTABLE_USING_BUTTON AblePullupDoubleClickerButton
80# define TESTABLE_USING_BUTTONLIST AblePullupDoubleClickerButtonList
81# else
82# define TESTABLE_USING_BUTTON Unsupported
83# define TESTABLE_USING_BUTTONLIST Unsupported
84# endif /* TESTABLE_CLASS */
85# endif /* TESTABLE_CALLBACK */
86#elif TESTABLE_CIRCUIT == TESTABLE_PULLDOWN
87# if TESTABLE_CALLBACK
88# if TESTABLE_CLASS == TESTABLE_BUTTON
89# define TESTABLE_USING_BUTTON AblePulldownCallbackButton
90# define TESTABLE_USING_BUTTONLIST AblePulldownCallbackButtonList
91# elif TESTABLE_CLASS == TESTABLE_CLICKER
92# define TESTABLE_USING_BUTTON AblePulldownCallbackClickerButton
93# define TESTABLE_USING_BUTTONLIST AblePulldownCallbackClickerButtonList
94# elif TESTABLE_CLASS == TESTABLE_DOUBLECLICKER
95# define TESTABLE_USING_BUTTON AblePulldownCallbackDoubleClickerButton
96# define TESTABLE_USING_BUTTONLIST AblePulldownCallbackDoubleClickerButtonList
97# else
98# define TESTABLE_USING_BUTTON Unsupported
99# define TESTABLE_USING_BUTTONLIST Unsupported
100# endif /* TESTABLE_CLASS */
101# else /* Not TESTABLE_CALLBACK */
102# if TESTABLE_CLASS == TESTABLE_DIRECT
103# define TESTABLE_USING_BUTTON AblePulldownDirectButton
104# define TESTABLE_USING_BUTTONLIST AblePulldownDirectButtonList
105# elif TESTABLE_CLASS == TESTABLE_BUTTON
106# define TESTABLE_USING_BUTTON AblePulldownButton
107# define TESTABLE_USING_BUTTONLIST AblePulldownButtonList
108# elif TESTABLE_CLASS == TESTABLE_CLICKER
109# define TESTABLE_USING_BUTTON AblePulldownClickerButton
110# define TESTABLE_USING_BUTTONLIST AblePulldownClickerButtonList
111# elif TESTABLE_CLASS == TESTABLE_DOUBLECLICKER
112# define TESTABLE_USING_BUTTON AblePulldownDoubleClickerButton
113# define TESTABLE_USING_BUTTONLIST AblePulldownDoubleClickerButtonList
114# else
115# define TESTABLE_USING_BUTTON Unsupported
116# define TESTABLE_USING_BUTTONLIST Unsupported
117# endif /* TESTABLE_CLASS */
118# endif /* TESTABLE_CALLBACK */
119#else
120# define TESTABLE_USING_BUTTON Unsupported
121# define TESTABLE_USING_BUTTONLIST Unsupported
122#endif /* TESTABLE_CIRCUIT */
123
124using Button = TESTABLE_USING_BUTTON; ///< Using the button defined by the circuit, callback and class.
125using ButtonList = TESTABLE_USING_BUTTONLIST; ///< Using the button list defined by the circuit, callback and class.
126
127//
128// Definitions of global variables...
129//
130extern Button btnA; ///< Button A
131extern Button btnB; ///< Button B
132extern Button *btns[]; ///< Array of buttons A and B
133extern ButtonList btnList; ///< Declaration of button list.
The main include file for the Arduino Button library Extension (ABLE).
Button btnA
Button A.
ButtonList btnList
Declaration of button list.
#define TESTABLE_USING_BUTTONLIST
Using ButtonList to test.
Definition: Config.h:63
Button * btns[]
Array of buttons A and B.
Button btnB
Button B.
#define TESTABLE_USING_BUTTON
Using Button to test.
Definition: Config.h:61
Core Button class.
Definition: Button.h:22
Template for a list of buttons of the same type.
Definition: ButtonList.h:20