I have a problem clearing the keypad buffer

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
Elle
LCD?
Posts: 6
Joined: Fri Aug 13, 2010 3:55 pm

I have a problem clearing the keypad buffer

Post by Elle »

I am trying to use the LK204-7t-1U-USB LCD and it looks that I am not able to clear the keypad buffer with oxfe 0x45 command I wonder if this is known issue and if it is do you have a solution for that.

Raquel
Matrix Orbital
Matrix Orbital
Posts: 796
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

Hello,

Thank you for posting on the forum.

Your command is correct; I will check this out with a current LK204-7T-1U-USB (firmware v5.0) display and let you know.

Update:
I tested the command on a current display and it works fine.
Can you please tell me what you observe the display is doing; and perhaps what you intend to do with the command?
Raquel Malinis
Design and Development
Matrix Orbital

Elle
LCD?
Posts: 6
Joined: Fri Aug 13, 2010 3:55 pm

Post by Elle »

I am using this LCD in an embedded design using micro and my goal is to read entered key once and run some commands and clear the buffer for the next run of the loop but it seems even after clearing the buffer I still read some key from keypad so it goes into repetitive loop. I wonder if there is any setting for the keypad that I am missing in my code
my code looks like this


printf("%c",0xFE);//There is a LCD check to see if key is pressed
WaitMilliseconds(10);
printf("%c",0x26);
WaitMilliseconds(10);

scanf("%c",&KeyPressed);

if ((KeyPressed==0x48)) //down arrow decrease it
{
if ((Contrast+ConSteps)<=0xff)
{
Contrast=Contrast+ConSteps;
printf("%c",0xFE);
WaitMilliseconds(10);
printf("%c",0x91);
WaitMilliseconds(10);
printf("%c",Contrast);
}


printf("%c",0xFE); //Clear the keypad buffer
WaitMilliseconds(10);
printf("%c",0x45);
WaitMilliseconds(10);
}

Raquel
Matrix Orbital
Matrix Orbital
Posts: 796
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

my goal is to read entered key once and run some commands and clear the buffer for the next run of the loop
If you do this, KeyPressed will remain to be whatever it was last read.
So you need to be sending the 0xFE 0x26 Poll keypress command again and KeyPressed should then be 0x00 value. Ie. make sure that
printf("%c",0xFE);//There is a LCD check to see if key is pressed
WaitMilliseconds(10);
printf("%c",0x26);
WaitMilliseconds(10);
is included in the loop.
Raquel Malinis
Design and Development
Matrix Orbital

Elle
LCD?
Posts: 6
Joined: Fri Aug 13, 2010 3:55 pm

Post by Elle »

Well that is right but this was only part of my code so the whole code is part of bigger code which reads the key everytime, the thing is without resetting the LCD it doesn't clear buffer so even after using that command still reads back the same key

Raquel
Matrix Orbital
Matrix Orbital
Posts: 796
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

I see that command 0xFE 0x45 is only being sent when Keypressed is 0x48, maybe you want to change that to send 0xFE 0x45 outside that if (Keypressed== 0x48) and send it when Keypressed is not 0x00?
Raquel Malinis
Design and Development
Matrix Orbital

Elle
LCD?
Posts: 6
Joined: Fri Aug 13, 2010 3:55 pm

Post by Elle »

Thanks Raqual,
I have tried that, no difference I wonder if there is anything else involve in clearing the buffer like insufficient delays, as the rest of the command works perfectly.

Raquel
Matrix Orbital
Matrix Orbital
Posts: 796
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

Can you please try sending the Set Auto Repeat Off command (0xFE 0x60) at the beginning of the code? This will make sure that any key up or prolonged presses will not be reported.

Also, the delay idea is good although I am not aware of the need. But it sure won't hurt (for now) to add in a delay just after sending the 0xFE 0x45 command. Try 10ms (this is long but we want to see the effect of the delay).

Let me know how it turns out.
Raquel Malinis
Design and Development
Matrix Orbital

Elle
LCD?
Posts: 6
Joined: Fri Aug 13, 2010 3:55 pm

Post by Elle »

Thanks,
I think that has solved my problem.

Raquel
Matrix Orbital
Matrix Orbital
Posts: 796
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

Hi Elle,
Was it the delay or was it the command 0xFE 0x60 that helped?
Raquel Malinis
Design and Development
Matrix Orbital

Elle
LCD?
Posts: 6
Joined: Fri Aug 13, 2010 3:55 pm

Post by Elle »

it was the command I didn't add delay and I overwrite keypressed at the beginning of each loop.

Post Reply