/
readme.txt
221 lines (126 loc) · 7.99 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
This is an example C++ library for Arduino 0018+, by Carlyn Maw
Installation
--------------------------------------------------------------------------------
To install this library, just place this entire folder as a subfolder in your
~/Documents/Arduino/libraries folder for mac My Documents\Arduino\libraries\ for a
PC.
When installed, this library should look like:
Arduino/libraries/Button (this library's folder)
Arduino/libraries/Button/Button.cpp (the library implementation file)
Arduino/libraries/Button/Button.h (the library description file)
Arduino/libraries/Button/keywords.txt (the syntax coloring file)
Arduino/libraries/Button/examples (the examples in the "open" menu)
Arduino/libraries/Button/readme.txt (this file)
Building
--------------------------------------------------------------------------------
After this library is installed, you just have to start the Arduino application.
You may see a few warning messages as it's built.
To use this library in a sketch, go to the Sketch | Import Library menu and
select dLED. This will add a corresponding line to the top of your sketch:
#include <Button.h>
To stop using this library, delete that line from your sketch.
Geeky information:
After a successful build of this library, a new file named "Button.o" will appear
in "Arduino/libraries/Button". This file is the built/compiled library
code.
If you choose to modify the code for this library (i.e. "Button.cpp" or "Button.h"),
then you must first 'unbuild' this library by deleting the "Button.o" file. The
new "Button.o" with your code will appear after the next press of "verify"
Public Functions
--------------------------------------------------------------------------------
Button myInstance = Button(int pinNumber);
Button myInstance = Button(int pinNumber, bool pressedState);
myInstance = some name
pinNumber = some int representing what pin the LED is attached to
pressedState = is the button HIGH or LOW when pressed?
BEHAVIOR: creates instance of a Button
Button myInstance = Button(int pinNumber, bool pressedState, unsigned char *myRegister);
myInstance = some name
pinNumber = some int representing what bit the button information is on
pressedState = is the button HIGH or LOW when pressed?
*myRegister = the byte containing the button information passed by reference ( &byteName )
BEHAVIOR: creates instance of a Button
myInstance.version();
BEHAVIOR: returns a char* of the version
myInstance.getRegisterValue();
BEHAVIOR: returns a unsigned byte value representing the current value of *myRegister
myInstance.listen();
BEHAVIOR: Does all the work of the function, actually tracks the behavior. Should be called
at the top of the main loop.
myInstance.isReleased();
myInstance.isReleased(bool refreshPinData);
refreshPinData = value should be set to one if and only if there has been A SIGNIFICANT DELAY
between calling this function and the last time listen was called. Forces a new listen.
BEHAVIOR: returns true if the debounced value for button is unpressed.
myInstance.isPressed();
myInstance.isPressed(bool refreshPinData);
refreshPinData = value should be set to one if and only if there has been A SIGNIFICANT DELAY
between calling this function and the last time listen was called. Forces a new listen.
BEHAVIOR: returns true if the debounced value for button is pressed.
myInstance.onChange();
myInstance.onChange(bool refreshPinData);
refreshPinData = value should be set to one if and _only if_ there has been A SIGNIFICANT DELAY
between calling this function and the last time listen was called. Forces a new listen.
BEHAVIOR: returns true if the debounced value for button has changed.
myInstance.onPress();
myInstance.onPress(bool refreshPinData);
refreshPinData = value should be set to one if and _only if_ there has been A SIGNIFICANT DELAY
between calling this function and the last time listen was called. Forces a new listen.
BEHAVIOR: returns true if the debounced value for button has changed from released to pressed
myInstance.onRelease();
myInstance.onRelease(bool refreshPinData);
refreshPinData = value should be set to one if and _only if_ there has been A SIGNIFICANT DELAY
between calling this function and the last time listen was called. Forces a new listen.
BEHAVIOR: returns true if the debounced value for button has changed from pressed to released
myInstance.getDebounceDelay();
BEHAVIOR: returns the int vale of the current debounce delay. default is 30 millis.
myInstance.setDebounceDelay(unsigned int newDebounceDelay);
newDebounceDelay = some int for the new value of the debounce delay
BEHAVIOR: updates the debounce delay to be the value of newDebounceDelay in millis
myInstance.clearDebounceDelay();
BEHAVIOR: updates the debounce delay to be the value of 0. As if there was no debounce.
myInstance.onDoubleClick();
myInstance.onDoubleClick(bool refreshPinData);
refreshPinData = value should be set to one if and _only if_ there has been A SIGNIFICANT DELAY
between calling this function and the last time listen was called. Forces a new listen.
BEHAVIOR: returns true if the debounced value for button has changed from pressed to released
twice in an amount of time determined by _doubleClickDelay
myInstance.getDoubleClickDelay();
BEHAVIOR: returns the unsigned int vale of the current debounce delay. default is 30 millis.
myInstance.setDoubleClickDelay(unsigned int myDelay);
myDelay = some unisgned int for the new value of the double click detection window
BEHAVIOR: updates the double click detection window value to that of myDelay in millis
myInstance.onPressAsToggle();
myInstance.onPressAsToggle(bool refreshPinData);
refreshPinData = value should be set to one if and _only if_ there has been A SIGNIFICANT DELAY
between calling this function and the last time listen was called. Forces a new listen.
BEHAVIOR: alternates returning true and false every time the button detects an onPress event
myInstance.onReleaseAsToggle();
myInstance.onReleaseAsToggle(bool refreshPinData);
refreshPinData = value should be set to one if and _only if_ there has been A SIGNIFICANT DELAY
between calling this function and the last time listen was called. Forces a new listen.
BEHAVIOR: alternates returning true and false every time the button detects an onRelease event
myInstance.isHold();
myInstance.isHold(bool refreshPinData);
refreshPinData = value should be set to one if and _only if_ there has been A SIGNIFICANT DELAY
between calling this function and the last time listen was called. Forces a new listen.
BEHAVIOR: returns true if the button has been held for a period of time as set by the _holdDelay
myInstance.getHoldDelay();
BEHAVIOR: returns the unsigned int value of the current _holdDelay. default is 1500 millis.
myInstance.setHoldDelay(unsigned int myDelay);
myDelay = some unisgned int for the new value of the double click detection window
BEHAVIOR: updates the value of the current _holdDelay.
myInstance.getPressCount();
BEHAVIOR: returns the unsigned int value of the number of button presses.
myInstance.clearPressCount();
BEHAVIOR: resets the value returned by getPressCount() to 0
myInstance.getReleaseCount();
BEHAVIOR: returns the unsigned int value of the number of button releases.
myInstance.clearReleaseCount();
BEHAVIOR: resets the value returned by getReleaseCount() to 0
myInstance.isNthPress(unsigned int moduloByMe);
moduloByMe = some number that is important to you
BEHAVIOR: returns true after every Nth onPress (as determined by moduloByMe) until next onPress
myInstance.isNthRelease(unsigned int moduloByMe);
moduloByMe = some number that is important to you
BEHAVIOR: returns true after every Nth onRelease (as determined by moduloByMe) until next onRelease