Skip to content

Commit 4778377

Browse files
authored
Merge pull request #32 from nomakewan/heldpress
Add isLongPressed function
2 parents 73a0036 + 706ac17 commit 4778377

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ It returns `true` if a push button was released (switched towards the off positi
6060

6161
### `longPress()`
6262

63-
It returns `true` if a push button is pressed longer than `300ms` (by default). Note that a `longPress()` always will be preceded by `pushed()` from the first push.
63+
It returns `true` if a push button was pressed longer than `300ms` (by default). Note that a `longPress()` always will be preceded by `pushed()` from the first push.
64+
65+
### `isLongPressed()`
66+
67+
It returns `true` if the conditions for `longPress()` were true and the push button is still being held down.
6468

6569
### `doubleClick()`
6670

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on KEYWORD2
1919
pushed KEYWORD2
2020
released KEYWORD2
2121
longPress KEYWORD2
22+
isLongPressed KEYWORD2
2223
doubleClick KEYWORD2
2324
singleClick KEYWORD2
2425
setPushedCallback KEYWORD2

src/avdweb_Switch.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
********************************************************************************
9595
......................................DOUBLE CLICK..............................
9696
97-
__________ ______
97+
__________ ______
9898
debounced ________| |_______| |_____________________________
9999
100100
poll ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
@@ -264,6 +264,8 @@ bool Switch::released() { return _switched && (debounced ^ polarity); }
264264

265265
bool Switch::longPress() { return _longPress; }
266266

267+
bool Switch::isLongPressed() { return longPressDisable; }
268+
267269
bool Switch::doubleClick() { return _doubleClick; }
268270

269271
bool Switch::singleClick() { return _singleClick; }

src/avdweb_Switch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class Switch {
5555
bool pushed(); // will be refreshed by poll()
5656
bool released(); // will be refreshed by poll()
5757
bool longPress(); // will be refreshed by poll()
58+
bool isLongPressed(); // will be refreshed by poll()
5859
bool doubleClick(); // will be refreshed by poll()
5960
bool singleClick(); // will be refreshed by poll()
6061

0 commit comments

Comments
 (0)