Skip to content

Commit aed6824

Browse files
authored
Merge pull request #85 from mongonta0716/master
fix pressedFor not working
2 parents d289409 + cd217c2 commit aed6824

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/utility/M5Button.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ void Button::fingerDown(Point pos /* = Point() */,
126126
_state = true;
127127
_changed = true;
128128
_pressTime = _time;
129+
_lastChange = _time;
129130
draw();
130131
}
131132
BUTTONS->fireEvent(finger, E_TOUCH, pos, pos, 0, this, nullptr);
@@ -140,6 +141,7 @@ void Button::fingerUp(uint8_t finger /* = 0 */) {
140141
// other finger not here
141142
_state = false;
142143
_changed = true;
144+
_lastChange = _time;
143145
draw();
144146
}
145147
BUTTONS->fireEvent(finger, E_RELEASE, _fromPt[finger], _toPt[finger],
@@ -235,7 +237,7 @@ bool Button::wasReleasefor(uint32_t ms) {
235237
}
236238

237239
bool Button::pressedFor(uint32_t ms) {
238-
return (_state && _time - _lastChange >= ms);
240+
return (_state && _time - _lastChange >= ms) ? 1 : 0;
239241
}
240242

241243
bool Button::pressedFor(uint32_t ms, uint32_t continuous_time) {

0 commit comments

Comments
 (0)