File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff 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,8 +43,17 @@ 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 (ch != -1 && millis ()-pressMills > BOUNCE_TICK) return 1 ;
53+ else if (ESCAPE_TIME&&millis ()-pressMills>ESCAPE_TIME) return 1 ;
54+
4255 if (ch==lastkey) return 0 ;
56+
4357 return 1 ;
4458 /* int cnt=0;
4559 for(int n=0;n<N;n++) {
You can’t perform that action at this time.
0 commit comments