Skip to content

Commit 11ecfc5

Browse files
author
doncov.eugene
committed
keyStream usable for bouncing buttons
1 parent b8ec349 commit 11ecfc5

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/keyStream.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ struct keyMap {
1919
int8_t code;
2020
};
2121

22+
23+
#ifndef BOUNCE_TICK
24+
#define BOUNCE_TICK 30
25+
#endif
26+
2227
//if you hold/repeat a key for this ammount of time we will consider it an escape
2328
#ifndef ESCAPE_TIME
2429
#define ESCAPE_TIME 1500
@@ -38,7 +43,14 @@ class keyLook:public Stream {
3843
if (lastkey==-1) {
3944
lastkey=ch;
4045
pressMills=millis();
41-
} else if (ESCAPE_TIME&&millis()-pressMills>ESCAPE_TIME) return 1;
46+
}
47+
else if (ch == -1 && millis()-pressMills < BOUNCE_TICK)
48+
{
49+
lastkey = -1; //released = it's bounce. reset lastkey
50+
return 0;
51+
}
52+
else if (ESCAPE_TIME&&millis()-pressMills>ESCAPE_TIME) return 1;
53+
4254
if (ch==lastkey) return 0;
4355
return 1;
4456
/*int cnt=0;

0 commit comments

Comments
 (0)