LK202-25 Keypad read over i2c
LK202-25 Keypad read over i2c
Hi,
i have a peck of trouble to get the correct Data over i2c which i read from keypad at LK202-25.
I atteched a 3x4 matrix Keypad to LK202-25. I tested the keypad with the Display Tuner and all works fine. After the first test was ok. I tried to writing and reading to the LK202-25 over i2c.
The follow settings are made before i test the i2c functionality:
1. i2c LK202-25 basic address was set to 0x50
2. auto transmit key presses was set to off so that a keypress would be put to the internal key buffer. (works fine over rs232 and poll mode)
After, all settings was made i wrote a character to the module and thereafter i sent a command (backlight off) to the module. All this works fine. But now to my problem the read process of the keypad over i2c.
I tried to read the data of a key press over i2c. Also i sent i2c_read(...) to address 0x51 and my i2c master
i have a peck of trouble to get the correct Data over i2c which i read from keypad at LK202-25.
I atteched a 3x4 matrix Keypad to LK202-25. I tested the keypad with the Display Tuner and all works fine. After the first test was ok. I tried to writing and reading to the LK202-25 over i2c.
The follow settings are made before i test the i2c functionality:
1. i2c LK202-25 basic address was set to 0x50
2. auto transmit key presses was set to off so that a keypress would be put to the internal key buffer. (works fine over rs232 and poll mode)
After, all settings was made i wrote a character to the module and thereafter i sent a command (backlight off) to the module. All this works fine. But now to my problem the read process of the keypad over i2c.
I tried to read the data of a key press over i2c. Also i sent i2c_read(...) to address 0x51 and my i2c master
Hi fitzi,
Thanks for posting at the forums.
Please refer to section 4.3 of the manual found at https://www.matrixorbital.com/files/LK202-25.pdf for a better explanation of the occurances.
If you have any further questions, please feel free to ask.
Best Regards,
Thanks for posting at the forums.
Please refer to section 4.3 of the manual found at https://www.matrixorbital.com/files/LK202-25.pdf for a better explanation of the occurances.
If you have any further questions, please feel free to ask.
Best Regards,
the problem is:
I press different Buttons at the keypad and get at determined keys the same data back from module.
see above
////key 2 pressed
//data = 0x21
////key 3 pressed
//data = 0x21 //it is the same as key 2
a push to key 2 or key 3 deliver the same data (I can not differ in my program, which key was pressed)
i hope it is clearer now
greeting
Michael
I press different Buttons at the keypad and get at determined keys the same data back from module.
see above
////key 2 pressed
//data = 0x21
////key 3 pressed
//data = 0x21 //it is the same as key 2
a push to key 2 or key 3 deliver the same data (I can not differ in my program, which key was pressed)
i hope it is clearer now
greeting
Michael
My test programm has follow operational sequence.
snippets of my programm
best regards
Michael
snippets of my programm
Code: Select all
#define LK202_I2CADDR 0x50
//init
i2c_init();
//set AutoTransmitKey to off
char cmd[2] = {0xFE, 0x4F};
//generate start condition, send data, generate stop condition
i2c_write(LK202_I2CADDR, cmd, 2);
//Data buffer
char b[8];
//read 100 times
for(int i=0; i<100; i++) {
i2c_read(LK202_I2CADDR | 0x01, b, 1);
printf("Data read from %X: %X", LK202_I2CADDR | 0x01, b[0] )
Sleep(1500);
}//endfor
Michael
#define LK202_I2CADDR 0x50
//init_i2c..
//AutoTransmitKey off..
{//loop
==============================
//My Poll command
char cmd[] = {0xFE, 0x26};
i2c_write(LK202_I2CADDR, cmd, 2);
===========================
..
..
//Read Data
//print Data
}
Best Regards
Michael
PS: It's non differentiated with or without polling command
//init_i2c..
//AutoTransmitKey off..
{//loop
==============================
//My Poll command
char cmd[] = {0xFE, 0x26};
i2c_write(LK202_I2CADDR, cmd, 2);
===========================
..
..
//Read Data
//print Data
}
Best Regards
Michael
PS: It's non differentiated with or without polling command