Problems reading from keypad in c++ linux

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

Moderators: Henry, Mods

Post Reply
lorddecker
LCD?
Posts: 4
Joined: Sun Nov 25, 2001 4:00 pm
Location: athens, ga

Post by lorddecker »

I'm writing a little linux control
utility for my lcd.
I've got a a LK202-25.

I've got most of the functions already implemented. But I want to be able to read from the keypad (up,down,left,right,enter,f1,f2).

I don't really understand the poll_keyboard
feature. Could someone explain this to me?

currently I have.
char BUFF[80];
SENDCMD_NOARG('&');
read(fd,BUFF,80);
char *string;
string=strtok(BUFF,0x00);
cout <<"Buffer:"<<string<<endl;
return string;

This SHOULD return all the keypresses since the last mo_pollKeyboard.

Could someone help me out by explaining how this works, or provide me with c++ code?

thankx
-nico

lorddecker
LCD?
Posts: 4
Joined: Sun Nov 25, 2001 4:00 pm
Location: athens, ga

Post by lorddecker »

don't worry, I think I figured it out.

this is what I have.
while(a!='H'){
if(read(moC->fd,&a,1)==1){cout<<a<<endl;
}

any better way to do it with buffers?

lorddecker
LCD?
Posts: 4
Joined: Sun Nov 25, 2001 4:00 pm
Location: athens, ga

Post by lorddecker »

Ok, this is what i have, but it'll run the first command and then halt. and won't do anyting else. wierd.
I know i'm positing too mutch to my own post, but i just want to give you guys the whole picture so you can help me better! Thankx guys!


while(a!='H'){if(read(moC->fd,&a,1)==1){
if(a=='M'){
moC->mo_backlight(!backL);
backL=!backL;
}
if(a=='N'){
moC->mo_clear();
}
cout<<a<<endl;
}}//while

lorddecker
LCD?
Posts: 4
Joined: Sun Nov 25, 2001 4:00 pm
Location: athens, ga

Post by lorddecker »

i figured out that if I try to
activate the backlight whether or not I disabled the backlight, the keyboard stops responding.

any clues?

Aniso
-=Beloved by all=-
-=Beloved by all=-
Posts: 286
Joined: Tue Aug 14, 2001 6:00 pm
Location: ...I could tell you my velocity...

Post by Aniso »

Well, I am not sure I followed all of that.

First, the keypad should not stop responding, however, I am told that experiments to reproduce your symptoms have met with some success. My immediate response is "don't do that", but we are looking into it.

Are you aware that if you are using polling, the returned code will reflect whether there are more key press codes waiting? Also, if there are no key presses waiting it will return zero.

Your code will probably take the form of a switch, rather than the cascaded or sequential if statements, but generally, I see nothing wrong with what you have there.

Post Reply