Removed _lastTime private variable, was not used.
This commit is contained in:
@@ -43,7 +43,6 @@ Button::Button(uint8_t pin, uint8_t puEnable, uint8_t invert, uint32_t dbTime)
|
||||
_time = millis();
|
||||
_lastState = _state;
|
||||
_changed = 0;
|
||||
_lastTime = _time;
|
||||
_lastChange = _time;
|
||||
}
|
||||
|
||||
@@ -60,13 +59,11 @@ uint8_t Button::read(void)
|
||||
pinVal = digitalRead(_pin);
|
||||
if (_invert != 0) pinVal = !pinVal;
|
||||
if (ms - _lastChange < _dbTime) {
|
||||
_lastTime = _time;
|
||||
_time = ms;
|
||||
_changed = 0;
|
||||
return _state;
|
||||
}
|
||||
else {
|
||||
_lastTime = _time;
|
||||
_lastState = _state;
|
||||
_state = pinVal;
|
||||
_time = ms;
|
||||
|
||||
1
Button.h
1
Button.h
@@ -36,7 +36,6 @@ class Button
|
||||
uint8_t _lastState; //previous button state
|
||||
uint8_t _changed; //state changed since last read
|
||||
uint32_t _time; //time of current state (all times are in ms)
|
||||
uint32_t _lastTime; //time of previous state
|
||||
uint32_t _lastChange; //time of last state change
|
||||
uint32_t _dbTime; //debounce time
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user