Page 1 of 1

Posted: Mon Nov 26, 2001 10:49 pm
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

Posted: Mon Nov 26, 2001 11:05 pm
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?

Posted: Mon Nov 26, 2001 11:46 pm
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

Posted: Tue Nov 27, 2001 12:19 am
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?

Posted: Fri Nov 30, 2001 7:04 pm
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.