int recv_signal;
int backlight_counter;
unsigned char backlight_level;
+unsigned char pollkeybuf[33];
+
unsigned int writeword_eeprom(unsigned int p, unsigned int *sum, unsigned int word)
{
set_amlamp(i & 1);
set_powerlamp(i & 1);
i = i + 1;
- idle(65535-7128/10 + 1);
- c = readkey();
- _LOCATE(0,0);
-// if(c == charcode_null) _PUTCHAR('p');
- while(c != charcode_null) {
- _PUTCHAR(c + '0');
- c = pop_keyinfifo();
+ c = pollkeys(pollkeybuf, 30); // Poll about 600ms
+ if(c != 0) {
+ unsigned char sp;
+ _LOCATE(0,0);
+ for(sp = 0; sp < c; sp++) _PUTCHAR(pollkeybuf[sp] + '0');
+ } else {
+ _CLS();
+ _LOCATE(0,0);
+ _PUTCHAR(' ');
}
}while(1);
#else
keyin_counter = 31;
return;
}
+ keyin_fifo[keyin_nowp] = b;
keyin_nowp++;
if((keyin_nowp > 31) || (keyin_nowp < 0))keyin_nowp = 0;
- keyin_fifo[keyin_nowp] = b;
keyin_counter++;
}
keyin_counter = 0;
return charcode_null ;
}
- if(keyin_readp > 31) keyin_readp = 0;
c = keyin_fifo[keyin_readp];
+ if(keyin_readp > 31) keyin_readp = 0;
keyin_readp++;
keyin_counter--;
if(keyin_counter < 0) keyin_counter = 0;
}
/*
+ * Polling key
+ * Max = 32bytes;
+ * 0 = Timeout
+ * 1~32 = Received.
+ * if((limit * 19.6ms) elapsed), break;
+ */
+unsigned char pollkeys(unsigned char *p, unsigned int limit)
+{
+ unsigned int count = 0;
+ unsigned int lifetime = 0;
+ unsigned char c;
+ unsigned char cold;
+
+ do {
+ idle(65535 - 100 + 1); // 0.78*256 = 78ms.
+ c = readkey(); // 0.78*2*8 = 11.2ms
+ if(c != charcode_null) {
+ cold = c;
+ p[count++] = c;
+ }
+ do {
+ c = pop_keyinfifo();
+ if(c == charcode_null) break;
+ if(c != cold) {
+ p[count++] = c;
+ cold = c;
+ }
+ } while(count < 32);
+ if(limit != 0) lifetime++;
+ if(lifetime >= limit) break;
+ } while(count < 32);
+ return count;
+}
+/*
* Notes:
* Initialize sequence:
* keyin_init();
extern unsigned int subst_numeric(unsigned int start, unsigned char pos, unsigned char c);
extern void print_numeric_nosupress(unsigned int data, unsigned char digit);
extern unsigned char readkey(void);
+extern unsigned char pollkeys(unsigned char *p, unsigned int limit);
#ifdef __cplusplus
}