@@ -62,44 +62,44 @@ OneButton::OneButton(const int pin, const boolean activeLow, const bool pullupAc
62
62
void OneButton::setDebounceTicks (const unsigned int ms)
63
63
{
64
64
_debounce_ms = ms;
65
- }
65
+ } // setDebounceTicks
66
66
67
67
68
68
// explicitly set the number of millisec that have to pass by before a click is detected.
69
69
void OneButton::setClickTicks (const unsigned int ms)
70
70
{
71
71
_click_ms = ms;
72
- }
72
+ } // setClickTicks
73
73
74
74
75
75
// explicitly set the number of millisec that have to pass by before a long button press is detected.
76
76
void OneButton::setPressTicks (const unsigned int ms)
77
77
{
78
78
_press_ms = ms;
79
- }
79
+ } // setPressTicks
80
80
81
81
82
82
// save function for click event
83
83
void OneButton::attachClick (callbackFunction newFunction)
84
84
{
85
85
_clickFunc = newFunction;
86
- }
86
+ } // attachClick
87
87
88
88
89
89
// save function for parameterized click event
90
90
void OneButton::attachClick (parameterizedCallbackFunction newFunction, void *parameter)
91
91
{
92
92
_paramClickFunc = newFunction;
93
93
_clickFuncParam = parameter;
94
- }
94
+ } // attachClick
95
95
96
96
97
97
// save function for doubleClick event
98
98
void OneButton::attachDoubleClick (callbackFunction newFunction)
99
99
{
100
100
_doubleClickFunc = newFunction;
101
101
_maxClicks = max (_maxClicks, 2 );
102
- }
102
+ } // attachDoubleClick
103
103
104
104
105
105
// save function for parameterized doubleClick event
@@ -108,15 +108,15 @@ void OneButton::attachDoubleClick(parameterizedCallbackFunction newFunction, voi
108
108
_paramDoubleClickFunc = newFunction;
109
109
_doubleClickFuncParam = parameter;
110
110
_maxClicks = max (_maxClicks, 2 );
111
- }
111
+ } // attachDoubleClick
112
112
113
113
114
114
// save function for multiClick event
115
115
void OneButton::attachMultiClick (callbackFunction newFunction)
116
116
{
117
117
_multiClickFunc = newFunction;
118
118
_maxClicks = max (_maxClicks, 100 );
119
- }
119
+ } // attachMultiClick
120
120
121
121
122
122
// save function for parameterized MultiClick event
@@ -125,52 +125,52 @@ void OneButton::attachMultiClick(parameterizedCallbackFunction newFunction, void
125
125
_paramMultiClickFunc = newFunction;
126
126
_multiClickFuncParam = parameter;
127
127
_maxClicks = max (_maxClicks, 100 );
128
- }
128
+ } // attachMultiClick
129
129
130
130
131
131
// save function for longPressStart event
132
132
void OneButton::attachLongPressStart (callbackFunction newFunction)
133
133
{
134
134
_longPressStartFunc = newFunction;
135
- }
135
+ } // attachLongPressStart
136
136
137
137
138
138
// save function for parameterized longPressStart event
139
139
void OneButton::attachLongPressStart (parameterizedCallbackFunction newFunction, void *parameter)
140
140
{
141
141
_paramLongPressStartFunc = newFunction;
142
142
_longPressStartFuncParam = parameter;
143
- }
143
+ } // attachLongPressStart
144
144
145
145
146
146
// save function for longPressStop event
147
147
void OneButton::attachLongPressStop (callbackFunction newFunction)
148
148
{
149
149
_longPressStopFunc = newFunction;
150
- }
150
+ } // attachLongPressStop
151
151
152
152
153
153
// save function for parameterized longPressStop event
154
154
void OneButton::attachLongPressStop (parameterizedCallbackFunction newFunction, void *parameter)
155
155
{
156
156
_paramLongPressStopFunc = newFunction;
157
157
_longPressStopFuncParam = parameter;
158
- }
158
+ } // attachLongPressStop
159
159
160
160
161
161
// save function for during longPress event
162
162
void OneButton::attachDuringLongPress (callbackFunction newFunction)
163
163
{
164
164
_duringLongPressFunc = newFunction;
165
- }
165
+ } // attachDuringLongPress
166
166
167
167
168
168
// save function for parameterized during longPress event
169
169
void OneButton::attachDuringLongPress (parameterizedCallbackFunction newFunction, void *parameter)
170
170
{
171
171
_paramDuringLongPressFunc = newFunction;
172
172
_duringLongPressFuncParam = parameter;
173
- }
173
+ } // attachDuringLongPress
174
174
175
175
176
176
void OneButton::reset (void )
@@ -189,8 +189,9 @@ int OneButton::getNumberClicks(void)
189
189
190
190
191
191
/* *
192
- * @brief Check input of the configured pin, debounce input pin level and then advance the finite state
193
- * machine (FSM).
192
+ * @brief Check input of the configured pin,
193
+ * debounce input pin level and then
194
+ * advance the finite state machine (FSM).
194
195
*/
195
196
void OneButton::tick (void )
196
197
{
@@ -206,7 +207,7 @@ void OneButton::tick(void)
206
207
_lastDebounceTime = now;
207
208
}
208
209
}
209
- }
210
+ } // tick()
210
211
211
212
212
213
/* *
@@ -215,7 +216,7 @@ void OneButton::tick(void)
215
216
void OneButton::_newState (stateMachine_t nextState)
216
217
{
217
218
_state = nextState;
218
- }
219
+ } // _newState()
219
220
220
221
221
222
/* *
@@ -233,7 +234,7 @@ void OneButton::tick(bool activeLevel)
233
234
_newState (OneButton::OCS_DOWN);
234
235
_startTime = now; // remember starting time
235
236
_nClicks = 0 ;
236
- }
237
+ } // if
237
238
break ;
238
239
239
240
case OneButton::OCS_DOWN:
@@ -247,7 +248,7 @@ void OneButton::tick(bool activeLevel)
247
248
if (_longPressStartFunc) _longPressStartFunc ();
248
249
if (_paramLongPressStartFunc) _paramLongPressStartFunc (_longPressStartFuncParam);
249
250
_newState (OneButton::OCS_PRESS);
250
- }
251
+ } // if
251
252
break ;
252
253
253
254
case OneButton::OCS_UP:
@@ -283,10 +284,10 @@ void OneButton::tick(bool activeLevel)
283
284
// this was a multi click sequence.
284
285
if (_multiClickFunc) _multiClickFunc ();
285
286
if (_paramMultiClickFunc) _paramMultiClickFunc (_multiClickFuncParam);
286
- }
287
+ } // if
287
288
288
289
reset ();
289
- }
290
+ } // if
290
291
break ;
291
292
292
293
case OneButton::OCS_PRESS:
@@ -300,7 +301,7 @@ void OneButton::tick(bool activeLevel)
300
301
// still the button is pressed
301
302
if (_duringLongPressFunc) _duringLongPressFunc ();
302
303
if (_paramDuringLongPressFunc) _paramDuringLongPressFunc (_duringLongPressFuncParam);
303
- }
304
+ } // if
304
305
break ;
305
306
306
307
case OneButton::OCS_PRESSEND:
@@ -315,6 +316,9 @@ void OneButton::tick(bool activeLevel)
315
316
// unknown state detected -> reset state machine
316
317
_newState (OneButton::OCS_INIT);
317
318
break ;
318
- }
319
+ } // if
319
320
320
321
} // OneButton.tick()
322
+
323
+
324
+ // end.
0 commit comments