Skip to content

Commit 2c292c4

Browse files
authored
corrected mismatched tab/space indentation
1 parent 1f6f4ad commit 2c292c4

File tree

1 file changed

+63
-67
lines changed

1 file changed

+63
-67
lines changed

src/ButtonEvents.cpp

+63-67
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55
ButtonEvents::ButtonEvents() {
66
debouncedButton.interval(DEFAULT_DEBOUNCE_MS);
77
doubleTapTime_ms = DEFAULT_DOUBLETAP_MS;
8-
holdTime_ms = DEFAULT_HOLD_MS;
8+
holdTime_ms = DEFAULT_HOLD_MS;
99
isActiveLow = DEFAULT_ACTIVE_LOW;
10-
pressTime_ms = 0; // initialize button timestamps and states...
11-
releaseTime_ms = 0;
12-
buttonState = idle;
13-
buttonEvent = none;
10+
pressTime_ms = 0; // initialize button timestamps and states...
11+
releaseTime_ms = 0;
12+
buttonState = idle;
13+
buttonEvent = none;
1414
}
1515

1616
// passthru to Bounce2 attach() method
1717
void ButtonEvents::attach(int pin) {
18-
debouncedButton.attach(pin);
18+
debouncedButton.attach(pin);
1919
}
2020

2121
// passthru to Bounce2 attach() overload
2222
void ButtonEvents::attach(int pin, int mode) {
23-
debouncedButton.attach(pin, mode);
23+
debouncedButton.attach(pin, mode);
2424
}
2525

2626
// set button mode to active high
@@ -69,66 +69,62 @@ bool ButtonEvents::buttonReleased() {
6969

7070
// calls the Bounce2 update() method, then runs button event detection logic
7171
bool ButtonEvents::update() {
72-
bool passthruState = debouncedButton.update(); // update debounced button state
73-
74-
if (buttonPressed()) {
75-
76-
// if the button was previously idle, store the press time and update the button state
77-
if (buttonState == idle) {
78-
pressTime_ms = millis();
79-
buttonState = pressed;
80-
}
81-
82-
// if the button was in a released state (waiting for a double tap), update the button
83-
// state and indicate that a double tap event occurred
84-
else if (buttonState == released) {
85-
buttonState = idle;
86-
buttonEvent = doubleTap;
87-
return true;
88-
}
89-
}
90-
91-
else if (buttonReleased()) {
92-
93-
// if the button was in a pressed state, store the release time and update the button state
94-
if (buttonState == pressed) {
95-
releaseTime_ms = millis();
96-
buttonState = released;
97-
}
98-
}
99-
100-
// if the button is currently in a pressed state...
101-
if (buttonState == pressed) {
102-
103-
// if the specified hold time has been reached or passed, update the button state and
104-
// indicate that a hold event occurred
105-
if ((millis() - pressTime_ms) >= holdTime_ms) {
106-
buttonState = idle;
107-
buttonEvent = hold;
108-
return true;
109-
}
110-
}
111-
112-
// if the button is currently in a released state...
113-
else if (buttonState == released) {
114-
115-
// if the specified double tap time has been reached or passed, update the button state
116-
// and indicate that a (single) tap event occurred
117-
if ((millis() - releaseTime_ms) >= doubleTapTime_ms) {
118-
buttonState = idle;
119-
buttonEvent = tap;
120-
return true;
121-
}
122-
}
123-
124-
// if we get to this point, indicate that no button event occurred in this cycle
125-
buttonEvent = none;
126-
return passthruState;
72+
bool passthruState = debouncedButton.update(); // update debounced button state
73+
74+
if (buttonPressed()) {
75+
// if the button was previously idle, store the press time and update the button state
76+
if (buttonState == idle) {
77+
pressTime_ms = millis();
78+
buttonState = pressed;
79+
}
80+
81+
// if the button was in a released state (waiting for a double tap), update the button
82+
// state and indicate that a double tap event occurred
83+
else if (buttonState == released) {
84+
buttonState = idle;
85+
buttonEvent = doubleTap;
86+
return true;
87+
}
88+
}
89+
90+
else if (buttonReleased()) {
91+
// if the button was in a pressed state, store the release time and update the button state
92+
if (buttonState == pressed) {
93+
releaseTime_ms = millis();
94+
buttonState = released;
95+
}
96+
}
97+
98+
// if the button is currently in a pressed state...
99+
if (buttonState == pressed) {
100+
// if the specified hold time has been reached or passed, update the button state and
101+
// indicate that a hold event occurred
102+
if ((millis() - pressTime_ms) >= holdTime_ms) {
103+
buttonState = idle;
104+
buttonEvent = hold;
105+
return true;
106+
}
107+
}
108+
109+
// if the button is currently in a released state...
110+
else if (buttonState == released) {
111+
// if the specified double tap time has been reached or passed, update the button state
112+
// and indicate that a (single) tap event occurred
113+
if ((millis() - releaseTime_ms) >= doubleTapTime_ms) {
114+
buttonState = idle;
115+
buttonEvent = tap;
116+
return true;
117+
}
118+
}
119+
120+
// if we get to this point, indicate that no button event occurred in this cycle
121+
buttonEvent = none;
122+
return passthruState;
127123
}
128124

129125
// returns the last triggered event
130126
ButtonEvent ButtonEvents::event() {
131-
return buttonEvent;
127+
return buttonEvent;
132128
}
133129

134130
// returns true if button was tapped
@@ -148,15 +144,15 @@ bool ButtonEvents::held() {
148144

149145
// passthru to Bounce2 read() method
150146
bool ButtonEvents::read() {
151-
return debouncedButton.read();
147+
return debouncedButton.read();
152148
}
153149

154150
// passthru to Bounce2 fell() method
155151
bool ButtonEvents::fell() {
156-
return debouncedButton.fell();
152+
return debouncedButton.fell();
157153
}
158154

159155
// passthru to Bounce2 rose() method
160156
bool ButtonEvents::rose() {
161-
return debouncedButton.rose();
162-
}
157+
return debouncedButton.rose();
158+
}

0 commit comments

Comments
 (0)