Skip to content

Commit 6d9b0f2

Browse files
authored
Merge pull request #29 from ardlib/master
Format fix for the selected clang-format
2 parents c836ee3 + e5d1b39 commit 6d9b0f2

File tree

4 files changed

+260
-246
lines changed

4 files changed

+260
-246
lines changed

examples/SwitchCallbackExample/SwitchCallbackExample.ino

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,35 @@ const byte multiresponseButtonpin = 9;
66
Switch toggleSwitch = Switch(toggleSwitchpin);
77
Switch multiresponseButton = Switch(multiresponseButtonpin);
88

9-
void buttonCallbackFunction(void *s) {
10-
Serial.print("Button: ");
11-
Serial.println((char *)s);
9+
void buttonCallbackFunction(void* s)
10+
{
11+
Serial.print("Button: ");
12+
Serial.println((char*)s);
1213
}
1314

14-
void toggleCallbackFunction(void *s) {
15-
Serial.print("Toggle: ");
16-
Serial.println((char *)s);
15+
void toggleCallbackFunction(void* s)
16+
{
17+
Serial.print("Toggle: ");
18+
Serial.println((char*)s);
1719
}
1820

19-
void setup() {
20-
Serial.begin(9600);
21-
toggleSwitch.setPushedCallback(&toggleCallbackFunction, (void *)"turned on");
22-
toggleSwitch.setReleasedCallback(&toggleCallbackFunction,
23-
(void *)"turned off");
21+
void setup()
22+
{
23+
Serial.begin(9600);
24+
toggleSwitch.setPushedCallback(&toggleCallbackFunction, (void*)"turned on");
25+
toggleSwitch.setReleasedCallback(&toggleCallbackFunction,
26+
(void*)"turned off");
2427

25-
multiresponseButton.setLongPressCallback(&buttonCallbackFunction,
26-
(void *)"long press");
27-
multiresponseButton.setDoubleClickCallback(&buttonCallbackFunction,
28-
(void *)"double click");
29-
multiresponseButton.setSingleClickCallback(&buttonCallbackFunction,
30-
(void *)"single click");
28+
multiresponseButton.setLongPressCallback(&buttonCallbackFunction,
29+
(void*)"long press");
30+
multiresponseButton.setDoubleClickCallback(&buttonCallbackFunction,
31+
(void*)"double click");
32+
multiresponseButton.setSingleClickCallback(&buttonCallbackFunction,
33+
(void*)"single click");
3134
}
3235

33-
void loop() {
34-
toggleSwitch.poll();
35-
multiresponseButton.poll();
36+
void loop()
37+
{
38+
toggleSwitch.poll();
39+
multiresponseButton.poll();
3640
}
Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#include "avdweb_Switch.h"
22

3-
const byte pushButtonpin = 10; // downButton
4-
const byte toggleSwitchpin = 9; // upButton
3+
const byte pushButtonpin = 10; // downButton
4+
const byte toggleSwitchpin = 9; // upButton
55
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
88

99
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
1211
Switch toggleSwitch = Switch(toggleSwitchpin);
1312
Switch multiresponseButton = Switch(multiresponseButtonpin);
1413
Switch alleventsButton = Switch(alleventsButtonpin);
@@ -18,65 +17,67 @@ Switch alleventsButton = Switch(alleventsButtonpin);
1817
// pushButton1ms = Switch(pushButtonpin, INPUT_PULLUP, LOW, 1); // debounceTime
1918
// 1ms
2019

21-
void beepCallbackFunction(void *s) // optional
20+
void beepCallbackFunction(void* s) // optional
2221
{
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
2625
}
2726

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()
3434
}
3535

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");
4748

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+
}
5354

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");
6263

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.");
8283
}

0 commit comments

Comments
 (0)