1
1
#include " avdweb_Switch.h"
2
2
3
- const byte pushButtonpin = 10 ; // downButton
4
- const byte toggleSwitchpin = 9 ; // upButton
3
+ const byte pushButtonpin = 10 ; // downButton
4
+ const byte toggleSwitchpin = 9 ; // upButton
5
5
const byte multiresponseButtonpin = 4 ; // selectButton
6
- const byte alleventsButtonpin = 7 ; // weldButton
7
- const byte buzzerPin = 3 ; // for beep when a switch is pressed
6
+ const byte alleventsButtonpin = 7 ; // weldButton
7
+ const byte buzzerPin = 3 ; // for beep when a switch is pressed
8
8
9
9
int i;
10
- Switch pushButton =
11
- Switch (pushButtonpin); // button to GND, use internal 20K pullup resistor
10
+ Switch pushButton = Switch(pushButtonpin); // button to GND, use internal 20K pullup resistor
12
11
Switch toggleSwitch = Switch(toggleSwitchpin);
13
12
Switch multiresponseButton = Switch(multiresponseButtonpin);
14
13
Switch alleventsButton = Switch(alleventsButtonpin);
@@ -18,65 +17,67 @@ Switch alleventsButton = Switch(alleventsButtonpin);
18
17
// pushButton1ms = Switch(pushButtonpin, INPUT_PULLUP, LOW, 1); // debounceTime
19
18
// 1ms
20
19
21
- void beepCallbackFunction (void * s) // optional
20
+ void beepCallbackFunction (void * s) // optional
22
21
{
23
- tone (3 , 2400 , 5 ); // is non-blocking
24
- // Serial.print("BeepCallback: "); Serial.println((char*)s);
25
- (void )s; // Fix Unused warning
22
+ tone (3 , 2400 , 5 ); // is non-blocking
23
+ // Serial.print("BeepCallback: "); Serial.println((char*)s);
24
+ (void )s; // Fix Unused warning
26
25
}
27
26
28
- void setup () {
29
- Serial.begin (115200 );
30
- toggleSwitch.setBeepAllCallback (
31
- &beepCallbackFunction /* , "Beep done"*/ ); // needed only for one switch
32
- // because of static
33
- // multiresponseButton.doubleClickPeriod=0; disable doubleClick()
27
+ void setup ()
28
+ {
29
+ Serial.begin (115200 );
30
+ toggleSwitch.setBeepAllCallback (
31
+ &beepCallbackFunction /* , "Beep done"*/ ); // needed only for one switch
32
+ // because of static
33
+ // multiresponseButton.doubleClickPeriod=0; disable doubleClick()
34
34
}
35
35
36
- void loop () { // pushButton simple events
37
- pushButton.poll ();
38
- if (pushButton.switched ())
39
- Serial.print (" pushButton switched " );
40
- if (pushButton.pushed ()) {
41
- Serial.print (" pushButton pushed " );
42
- Serial.print (++i);
43
- Serial.println (" times" );
44
- }
45
- if (pushButton.released ())
46
- Serial.println (" pushButton released" );
36
+ void loop ()
37
+ { // pushButton simple events
38
+ pushButton.poll ();
39
+ if (pushButton.switched ())
40
+ Serial.print (" pushButton switched " );
41
+ if (pushButton.pushed ()) {
42
+ Serial.print (" pushButton pushed " );
43
+ Serial.print (++i);
44
+ Serial.println (" times" );
45
+ }
46
+ if (pushButton.released ())
47
+ Serial.println (" pushButton released" );
47
48
48
- // toggleSwitch report status only when changed
49
- if (toggleSwitch.poll ()) {
50
- Serial.print (" toggleSwitch status changed to " );
51
- Serial.println (toggleSwitch.on ());
52
- }
49
+ // toggleSwitch report status only when changed
50
+ if (toggleSwitch.poll ()) {
51
+ Serial.print (" toggleSwitch status changed to " );
52
+ Serial.println (toggleSwitch.on ());
53
+ }
53
54
54
- // multiresponseButton complex events
55
- multiresponseButton.poll ();
56
- if (multiresponseButton.longPress ())
57
- Serial.println (" multiresponseButton longPress" );
58
- if (multiresponseButton.doubleClick ())
59
- Serial.println (" multiresponseButton doubleClick" );
60
- if (multiresponseButton.singleClick ())
61
- Serial.println (" multiresponseButton singleClick" );
55
+ // multiresponseButton complex events
56
+ multiresponseButton.poll ();
57
+ if (multiresponseButton.longPress ())
58
+ Serial.println (" multiresponseButton longPress" );
59
+ if (multiresponseButton.doubleClick ())
60
+ Serial.println (" multiresponseButton doubleClick" );
61
+ if (multiresponseButton.singleClick ())
62
+ Serial.println (" multiresponseButton singleClick" );
62
63
63
- // alleventsButton complex events
64
- alleventsButton.poll ();
65
- if (alleventsButton.switched ()) {
66
- Serial.println (" all_e_B switched." );
67
- Serial.print (" all_e_B status to " );
68
- Serial.print (alleventsButton.on ());
69
- Serial.println (" ." );
70
- }
71
- if (alleventsButton.pushed ()) {
72
- Serial.println (" all_e_B pushed." );
73
- }
74
- if (alleventsButton.released ())
75
- Serial.println (" all_e_B released." );
76
- if (alleventsButton.longPress ())
77
- Serial.println (" ==> all_e_B longPress." );
78
- if (alleventsButton.doubleClick ())
79
- Serial.println (" ==> all_e_B doubleClick." );
80
- if (alleventsButton.singleClick ())
81
- Serial.println (" ==> all_e_B singleClick." );
64
+ // alleventsButton complex events
65
+ alleventsButton.poll ();
66
+ if (alleventsButton.switched ()) {
67
+ Serial.println (" all_e_B switched." );
68
+ Serial.print (" all_e_B status to " );
69
+ Serial.print (alleventsButton.on ());
70
+ Serial.println (" ." );
71
+ }
72
+ if (alleventsButton.pushed ()) {
73
+ Serial.println (" all_e_B pushed." );
74
+ }
75
+ if (alleventsButton.released ())
76
+ Serial.println (" all_e_B released." );
77
+ if (alleventsButton.longPress ())
78
+ Serial.println (" ==> all_e_B longPress." );
79
+ if (alleventsButton.doubleClick ())
80
+ Serial.println (" ==> all_e_B doubleClick." );
81
+ if (alleventsButton.singleClick ())
82
+ Serial.println (" ==> all_e_B singleClick." );
82
83
}
0 commit comments