Hola a todos un saludo, alguien puede ayudarme? Quiero sacar las letras de un teclado 4*4, osea cuando presiono el 2 por ejemplo que a la segunda vez me saque la a luego la b, etc, estoy tratando de hacerlo en lenguaje c que tiene la siguiente librería y no se como modificarla para que haga lo que dije anteriormente, de antemano les agradezco cualquier ayuda.
Esta es la librería
#define COL0 (1 << 0) // 1 << bit es para colocar a uno el bit especificado
#define COL1 (1 << 1)
#define COL2 (1 << 2)
#define COL3 (1 << 3)
#define ROW0 (1 << 4)
#define ROW1 (1 << 5)
#define ROW2 (1 << 6)
#define ROW3 (1 << 7)
#define ALL_COLS (COL0|COL1|COL2|COL3)
#define ALL_ROWS (ROW0|ROW1|ROW2|ROW3)
#define ALL_PINS (ALL_ROWS|ALL_COLS)
// Capa del teclado:
char const KEYS[4][4] = {{'1','2','3','A',},
{'4','5','6','B',},
{'7','8','9','C',},
{'*','0','#','D',}};
#define KBD_DEBOUNCE_FACTOR 252 // Coloque este número a un valor cercano a n/333, donde n
// es el número de veces por segundo que usted considera que
// llamará a la función kbd_getc
void kbd_init() {
#ifdef __PCM__
port_b_pullups ( true); // Si el PIC no es PCM asegurese de usar pullups externas
#endif
}
char kbd_getc( )
{
static byte kbd_call_count;
// static short int kbd_down;
//static char last_key;
static byte row;
int1 fkey;
byte kchar, kin,ult_tecla;
byte col, cont1;
ult_tecla=kchar;
kchar='\0';
if(++kbd_call_count>KBD_DEBOUNCE_FACTOR)
{
fkey = true;
for (col = 0; col < 4; col++)
{
switch (col)
{
case 0 : kbd=~COL0&ALL_PINS;
break;
case 1 : kbd=~COL1&ALL_PINS;
break;
case 2 : kbd=~COL2&ALL_PINS;
break;
case 3 : kbd=~COL3&ALL_PINS;
break;
}
delay_us(5);
//last_key = ~ROW0&ALL_ROWS;
kin = kbd&240;
if (kin != 240)
{
row = 4;
if (kin == 224)
row=0;
else if (kin == 208)
row=1;
else if (kin == 176)
row=2;
else if (kin == 112)
row=3;
if (row < 4)
kchar =KEYS[row][col];
}
cont1 = 0;
while (kin != 240 && cont1 < 70)
{
fkey = false;
delay_ms(5);
kin = kbd&240;
cont1 ++;
}
if (!fkey)
col = 3;
}
kbd_call_count=0;
kbd = ALL_COLS;
}
return(kchar);
}