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
Problems reading from keypad in c++ linux
-
- LCD?
- Posts: 4
- Joined: Sun Nov 25, 2001 4:00 pm
- Location: athens, ga
-
- LCD?
- Posts: 4
- Joined: Sun Nov 25, 2001 4:00 pm
- Location: athens, ga
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
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
-
- LCD?
- Posts: 4
- Joined: Sun Nov 25, 2001 4:00 pm
- Location: athens, ga
-
- -=Beloved by all=-
- Posts: 286
- Joined: Tue Aug 14, 2001 6:00 pm
- Location: ...I could tell you my velocity...
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.
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.