@@ -46,7 +46,7 @@ class OneButton
46
46
* @param activeLow Set to true when the input level is LOW when the button is pressed, Default is true.
47
47
* @param pullupActive Activate the internal pullup when available. Default is true.
48
48
*/
49
- OneButton (const int pin, const boolean activeLow = true , const bool pullupActive = true );
49
+ explicit OneButton (const int pin, const boolean activeLow = true , const bool pullupActive = true );
50
50
51
51
// ----- Set runtime parameters -----
52
52
@@ -149,12 +149,12 @@ class OneButton
149
149
150
150
151
151
private:
152
- int _pin; // hardware pin number.
152
+ int _pin = 0 ; // hardware pin number.
153
153
unsigned int _debounceTicks = 50 ; // number of ticks for debounce times.
154
154
unsigned int _clickTicks = 400 ; // number of msecs before a click is detected.
155
155
unsigned int _pressTicks = 800 ; // number of msecs before a long button press is detected
156
156
157
- int _buttonPressed;
157
+ int _buttonPressed = 0 ;
158
158
159
159
// These variables will hold functions acting as event source.
160
160
callbackFunction _clickFunc = NULL ;
@@ -175,7 +175,7 @@ class OneButton
175
175
176
176
callbackFunction _longPressStopFunc = NULL ;
177
177
parameterizedCallbackFunction _paramLongPressStopFunc = NULL ;
178
- void *_longPressStopFuncParam;
178
+ void *_longPressStopFuncParam = NULL ;
179
179
180
180
callbackFunction _duringLongPressFunc = NULL ;
181
181
parameterizedCallbackFunction _paramDuringLongPressFunc = NULL ;
@@ -204,9 +204,9 @@ class OneButton
204
204
stateMachine_t _state = OCS_INIT;
205
205
stateMachine_t _lastState = OCS_INIT; // used for debouncing
206
206
207
- unsigned long _startTime; // start of current input change to checking debouncing
208
- int _nClicks; // count the number of clicks with this variable
209
- int _maxClicks = 1 ; // max number (1, 2, multi=3) of clicks of interest by registration of event functions.
207
+ unsigned long _startTime = 0 ; // start of current input change to checking debouncing
208
+ int _nClicks = 0 ; // count the number of clicks with this variable
209
+ int _maxClicks = 1 ; // max number (1, 2, multi=3) of clicks of interest by registration of event functions.
210
210
};
211
211
212
212
#endif
0 commit comments