You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arduino switch and button library for SPST, SPDT or SP3T contacts. Simple to use, provides debouncing, deglitching and uses very little memory. Status indicates one-shot transitions (depicting direction) and current position status.
7
+
Arduino switch and button library for SPST, SPDT or SP3T contacts. Simple to use, provides debouncing, deglitching and uses very little memory. Captures one-shot transitions (depicting direction) and current position status.
8
8
9
9
#### Features
10
10
11
11
- Performs both debouncing and deglitching.
12
12
- External pull-up resistors not required.
13
13
- Very simple to use.
14
-
-Very low memory use.
14
+
-Ultra low memory use (14 bytes per button).
15
15
16
16
## Using Toggle
17
17
@@ -36,30 +36,30 @@ sw1.poll();
36
36
sw2.poll();
37
37
```
38
38
39
-
###### The switch status options when using 1 input pin:
39
+
###### The switch functions when using 1 input pin:
40
40
41
41
```c++
42
-
sw.isON;
43
-
sw.isOFF;
44
-
sw.ONtoOFF;
45
-
sw.OFFtoON;
42
+
boolisOFF();
43
+
boolisON();
44
+
boolOFFtoON();
45
+
boolONtoOFF();
46
46
```
47
47
48
-
The switch has 2 positions referred to as OFF (input is high) and ON (input is low). The first 2 status options will continuously return true if the switch is at that current position. The last 2 status options return true (once only) if the switch has just transitioned to the checked position. This is very handy to execute code based on direction of switched operation or for any one-shot processing of code.
48
+
The switch has 2 positions referred to as OFF (input is high) and ON (input is low). The first 2 functions will continuously return true if the switch is at that current position. The last 2 functions return true (once only) if the switch has just transitioned to the checked position. This is very handy to execute code based on direction of switched operation or for any one-shot processing of code.
49
49
50
-
###### The switch status options when using 2 input pins:
50
+
###### The switch functions when using 2 input pins:
51
51
52
52
```c++
53
-
sw.isUP;
54
-
sw.isMID;
55
-
sw.isDN;
56
-
sw.UPtoMID;
57
-
sw.MIDtoDN;
58
-
sw.DNtoMID;
59
-
sw.MIDtoUP;
53
+
boolisUP();
54
+
boolisMID();
55
+
boolisDN();
56
+
boolUPtoMID();
57
+
boolMIDtoDN();
58
+
boolDNtoMID();
59
+
boolMIDtoUP();
60
60
```
61
61
62
-
The switch has 3 positions referred to as UP, MID (center) and DN (down). The first 3 status options will continuously return true if the switch is at that position. The last 4 status options return true (once only) if the switch has just transitioned to that position. This is very handy to execute code based on direction of switched operation or for any one-shot processing of code.
62
+
The switch has 3 positions referred to as UP, MID (center) and DN (down). The first 3 functions will continuously return true if the switch is at that position. The last 4 functions return true (once only) if the switch has just transitioned to that position. This is very handy to execute code based on direction of switched operation or for any one-shot processing of code.
63
63
64
64
#### Example Sketch
65
65
@@ -155,7 +155,18 @@ Using the input pullups provides a high 20K-50K impedance that makes the signals
155
155
156
156
#### Debouncing
157
157
158
-
Debouncing requires the shift register to be completely filled with 1's or 0's to signify a stable state. This occurs 80ms after the last transition. Contact closure will be detected after at least 10ms have elapsed (de-glitch period). Contact release is detected in at least 80ms.
158
+
Debouncing requires the shift register to be completely filled with 1's or 0's to signify a stable state. This occurs 80ms after the last transition. Contact closure will be detected after at least 10ms have elapsed (de-glitch period). Contact release is detected in at least 80ms.
159
+
160
+
#### Memory Comparison on Leonardo with 2 buttons attached :
Copy file name to clipboardExpand all lines: library.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
{
2
2
"name": "Toggle",
3
-
"version": "2.0.0",
4
-
"description": "Arduino switch and button library for SPST, SPDT or SP3T contacts. Simple to use, provides debouncing, deglitching and uses very little memory. Status indicates one-shot transitions (depicting direction) and current position status.",
3
+
"version": "2.1.0",
4
+
"description": "Arduino switch and button library for SPST, SPDT or SP3T contacts. Simple to use, provides debouncing, deglitching and uses very little memory. Captures one-shot transitions (depicting direction) and current position status.",
sentence=Arduino switch and button library for SPST, SPDT or SP3T contacts. Simple to use, provides debouncing, deglitching and uses very little memory.
6
-
paragraph=Status indicates one-shot transitions (depicting direction) and current position status.
6
+
paragraph=Captures one-shot transitions (depicting direction) and current position status.
0 commit comments