Polling Keyboard

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

Moderators: Henry, Mods

Post Reply
Chamma
LCD?
Posts: 3
Joined: Mon Sep 23, 2002 6:00 pm
Contact:

Post by Chamma »

I have a VK204-25 and im writing a app under linux in c++.

I have a keypad attached (which works, i have tested it in other progs) but i cannot seem figure out how to get input using c++.

I have read the post that discusses it but had no luck in implamenting the methods that were discussed.

The settings i have are

Block Cursor Off
Auto Line Wrap Off
Auto Scroll Off
Auto transmit key Off
Auto repeat off

I am using write() to send commands/text to the lcd screen and this is all working fine.

This is what i have tried so far, lcd_command is a function which sends the command prefix and whatever command specified with the parameter, fdDisplay is what is returned when i do my open command
fdDisplay = open("/dev/ttyS0", O_RDWR | O_NOCTTY );

//Set up the timeout (only waits a sec)
tv.tv_sec = 1;
tv.tv_usec = 0;

FD_ZERO(&fd);
FD_SET( fdDisplay, &fd );

lcd_sendcommand(38); //Poll the keypad
retval = select(1, &fd, NULL, NULL, &tv);
//If we have something (which we never do) read it in

if(retval){
read(fdDisplay, &buf, 1);
cout << "Pressed : " << buf << "n";
}

Any help would be appriciated. Please feel free to comment on the state of my code and how i could improve it, i haven't done any c++ for a couple of years and am re-familierizing myself with it :-)

Thanks

Cip

Also, i cant spell! So please ignore any spelwing mistarkes :-p

<font size=-1>[ This Message was edited by: Chamma on 2002-09-27 18:38 ]</font>
tarou
LCD!
Posts: 14
Joined: Sun Oct 13, 2002 9:14 pm

Post by tarou »

I was trying to almost samething on Windows. My LCD is GLK12232-25-SM, so it may different, but try to read longer than 1 byte. In my case, I read everything from read queue and could find pressed key code at the end of the bytes. I found this when I am tracing the port data.
Post Reply