HTEB1
User manual
keyReadIndex++;
if (keyReadIndex >= cKeyBufSize) keyReadIndex = 0; return KeyCode;
}
u8 buffer[17] = " KeyCode : 0000 \0"; | // msg buffer |
//convert int to
{
u8 *data, c;
data = &buffer[14]; |
|
| // last digit = start address |
while (code) |
|
|
|
{ |
|
|
|
*data = '0'; |
| // default = '0' | |
c = code & 0x000f; |
| // check digit | |
if (c) |
|
| // if > 0 chk for value |
{ |
|
|
|
if (c < 10) *data = '0'+c; | // 0..9 | ||
else *data = |
| // a..f | |
} |
|
|
|
|
| // next digit | |
code >>= 4; |
|
|
|
} |
|
|
|
LCDWriteLine(1,buffer); |
| // show result | |
} |
|
|
|
void KeyTest(void) |
|
|
|
{ |
|
|
|
u8 c; |
|
|
|
u16 KeyCode; |
|
|
|
PMR1 = cKEYCLK; | // P16 | ||
PMR1 &= ~cKEYDATA; | // P17 |
| |
IEGR1 &= ~0x04; |
| // IRQ_2 on falling edge | |
IENR1 = 0x04; |
| // enable IRQ_2 | |
set_interrupt_mask(0); | // enable all interrupts | ||
LCDWriteLine(0, |
| ||
LCDWriteLine(1, "press any key..."); |
| ||
while (1) |
|
|
|
{ |
|
|
|
if (kbhit()) | // if new key ... | ||
{ |
|
|
|
KeyCode = GetKey(); | // get codes | ||
ShowCode(KeyCode); | // display code | ||
} |
|
|
|
} |
|
|
|
} |
|
|
|
void main(void) |
|
|
|
{ |
|
|
|
LCDInit(); | // init ports and LCD | ||
KeyTest(); | // go to keyboard test | ||
} |
|
|
|
|
|
|
|
Issue 0.2 | Page 47 | 07/2002 |