Skip to content

Commit

Permalink
Merge pull request #85 from mongonta0716/master
Browse files Browse the repository at this point in the history
fix pressedFor not working
  • Loading branch information
Tinyu-Zhao authored Jan 17, 2022
2 parents d289409 + cd217c2 commit aed6824
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utility/M5Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ void Button::fingerDown(Point pos /* = Point() */,
_state = true;
_changed = true;
_pressTime = _time;
_lastChange = _time;
draw();
}
BUTTONS->fireEvent(finger, E_TOUCH, pos, pos, 0, this, nullptr);
Expand All @@ -140,6 +141,7 @@ void Button::fingerUp(uint8_t finger /* = 0 */) {
// other finger not here
_state = false;
_changed = true;
_lastChange = _time;
draw();
}
BUTTONS->fireEvent(finger, E_RELEASE, _fromPt[finger], _toPt[finger],
Expand Down Expand Up @@ -235,7 +237,7 @@ bool Button::wasReleasefor(uint32_t ms) {
}

bool Button::pressedFor(uint32_t ms) {
return (_state && _time - _lastChange >= ms);
return (_state && _time - _lastChange >= ms) ? 1 : 0;
}

bool Button::pressedFor(uint32_t ms, uint32_t continuous_time) {
Expand Down

0 comments on commit aed6824

Please sign in to comment.