Add getInputWaitRepeat, to support key repeat
This commit is contained in:
parent
f57e0a9e90
commit
691fa7d09b
|
@ -152,6 +152,7 @@ char isNight(void);
|
||||||
uint8_t getInput(void);
|
uint8_t getInput(void);
|
||||||
uint8_t getInputRaw(void);
|
uint8_t getInputRaw(void);
|
||||||
uint8_t getInputWait(void);
|
uint8_t getInputWait(void);
|
||||||
|
uint8_t getInputWaitRepeat(void);
|
||||||
uint8_t getInputWaitTimeout(int timeout);
|
uint8_t getInputWaitTimeout(int timeout);
|
||||||
void getInputWaitRelease(void);
|
void getInputWaitRelease(void);
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,39 @@ uint8_t getInputWaitTimeout(int timeout) {
|
||||||
return key;
|
return key;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint8_t getInputWaitRepeat(void) {
|
||||||
|
static uint8_t oldkey=BTN_NONE;
|
||||||
|
static int repeatctr=0;
|
||||||
|
uint8_t key=getInputRaw();
|
||||||
|
|
||||||
|
if (key != BTN_NONE && key==oldkey){
|
||||||
|
int dtime;
|
||||||
|
if(!repeatctr)
|
||||||
|
dtime=600;
|
||||||
|
else if(repeatctr<5)
|
||||||
|
dtime=250;
|
||||||
|
else if(repeatctr<30)
|
||||||
|
dtime=150;
|
||||||
|
else
|
||||||
|
dtime=80;
|
||||||
|
repeatctr++;
|
||||||
|
int end=_timectr+(dtime/SYSTICKSPEED);
|
||||||
|
while(_timectr<end && key==getInputRaw())
|
||||||
|
work_queue();
|
||||||
|
key=getInputRaw();
|
||||||
|
if (key==oldkey)
|
||||||
|
return key;
|
||||||
|
};
|
||||||
|
|
||||||
|
repeatctr=0;
|
||||||
|
while ((key=getInputRaw())==BTN_NONE){
|
||||||
|
work_queue();
|
||||||
|
};
|
||||||
|
delayms_queue(10); /* Delay a little more to debounce */
|
||||||
|
oldkey=key;
|
||||||
|
return key;
|
||||||
|
};
|
||||||
|
|
||||||
void getInputWaitRelease(void) {
|
void getInputWaitRelease(void) {
|
||||||
while (getInputRaw()!=BTN_NONE)
|
while (getInputRaw()!=BTN_NONE)
|
||||||
work_queue();
|
work_queue();
|
||||||
|
|
Loading…
Reference in New Issue