i have a keypad... and my code is continously scanning which buttons is pressed. whenever a button is pressed if will write into the lcd.
Code:
int keypad() {
unint pio = _lr->piodata; // _lr->piodir = 0x000107fc;
_lr->piodata = (pio | 0x000f0000) & 0xfffeffff;
udelay(100);
if (! (_lr->piodata & 0x01000000)) {
while (!(_lr->piodata & 0x01000000));
return '1';
}
if (! (_lr->piodata & 0x02000000)) {
while (!(_lr->piodata & 0x02000000));
return '2';
}
if (! (_lr->piodata & 0x04000000)) {
while (!(_lr->piodata & 0x04000000));
return '3';
...
...
...
int keypadGUI() { int key = keypad();
_lr->piodata &= (0xfff0ffff);
if (key) {
if (key == '#') {
lcdwrite8(0,0x01); mdelay(1);
showmode(*_mode);
*passwd = 0;
}
else {
uchar *ptr = passwd;
while (*ptr) ptr++;
lcdwrite8(1,key);
*ptr++ = key;
*ptr = 0;
}
...
...
...
for every key pressed, it return the value and put into a int variable, then it is write into the lcd.
i need to use the keypad to input 16 digits... and the 16 digits that are pressed, needed to be record down together..
for example, firstly i pressed "2" then i pressed "5", then "7" and so on, the digits in pressed needed to be store into some place ( required answer : 257............) together