Page 1 of 1

LK202-25 LCDd keypad test mode

Posted: Wed May 14, 2008 11:30 am
by tom.garratt
Hi,

Trying to get the above device to work in linux and when i run LCDd in keypad test mode I receive the following:

MtxOrb: Received character

Posted: Wed May 14, 2008 1:16 pm
by Ray
Not quite sure there is a question in your post but I gave it a try to reproduce what you are getting anyway.

When you enable the keypad test mode it will spit back messages such as

Code: Select all

MtxOrb: Received character A
MtxOrb: Press another key of your device
MtxOrb: Received character E
MtxOrb: Press another key of your device
MtxOrb: Received character D
MtxOrb: Press another key of your device
Are you getting different results?

?

Posted: Wed May 14, 2008 2:18 pm
by tom.garratt
it would appear i'm having truble

Code: Select all

MtxOrb: Received character

Posted: Wed May 14, 2008 2:22 pm
by Ray
I see you are struggling to get your complete post on, the forum seems to dislike any unicode character you have in your post and cuts off at the character it dislikes, just remove the character and you'll be fine.

Posted: Wed May 14, 2008 2:25 pm
by tom.garratt
Ray wrote:I see you are struggling to get your complete post on, the forum seems to dislike any unicode character you have in your post and cuts off at the character it dislikes, just remove the character and you'll be fine.
In deed. I've posted the output at http://pastebin.com/m900d40

Posted: Wed May 14, 2008 2:40 pm
by Raquel
Hi Tom,

I am going to assume here that you have PCB Rev 3.0 for the LK202-25.

It looks like the keypad values are all jumbled up.
Please try sending this command:
254 / 213 / 255 / <49 more of 255> ...
Use 50 x 255's.
This command assigns the values of the keypad keys; putting 255 as parameters makes the LK202-25 do a default 'A', 'B', 'C', 'D' .. values.

Best Regards,

how

Posted: Wed May 14, 2008 2:45 pm
by tom.garratt
and how do i send those command. I assume I can not simply use LCDd and echo the command to the display using pearl?

Posted: Wed May 14, 2008 2:48 pm
by Ray
If you have no means of sending that on your own, easiest thing to do is probably take the hello world application from our linux app note and replace the welcome message with

Code: Select all

unsigned char WelcomeMessage[] = 
{254,213,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255};

Posted: Thu May 15, 2008 1:49 am
by tom.garratt
Ray wrote:If you have no means of sending that on your own, easiest thing to do is probably take the hello world application from our linux app note and replace the welcome message with

Code: Select all

unsigned char WelcomeMessage[] = 
{254,213,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255};
Worked like a treat. now only if I could find a "hello world" example of reading key pressess in c++

Posted: Thu May 15, 2008 7:18 am
by Ray
Thats not much more difficult, add this snippet of code after sending the welcome message

Code: Select all

	unsigned char input;
	while (true)
	{
	   read(lcd,&input,1);
	   printf("You pressed %c\n",input);
	}

Thanks

Posted: Fri May 16, 2008 4:35 am
by tom.garratt
Ray wrote:Thats not much more difficult, add this snippet of code after sending the welcome message

Code: Select all

	unsigned char input;
	while (true)
	{
	   read(lcd,&input,1);
	   printf("You pressed %c\n",input);
	}
Thanks you guys, you all have been most helpful. I have one question.....



if i use something like :

Code: Select all

unsigned char input;
	unsigned char clearkey[] = {254,69}; 
	while (true) 
	{
		read(lcd,&input,1);
		//printf("You pressed %c\n",input);
		if (input =='L')
		{	
			printf("Connection Status");
			write(lcd,clearkey,sizeof(clearkey));
			printf("You pressed %c\n",input);
		}
	}
My c++ program reads the input (L/Enter) and goes to the if statement prints out the "Connection Status You Pressed L", but the thing is when the program finishes printing to screen it loops and picks up the L/Enter key again and reprints the message. I though by using "clearkey" it would clear the key buffer. Does that make sense?

Posted: Fri May 16, 2008 10:11 am
by Ray
My bad, the sample program opens the serial port in non blocked mode, so the read call will not block until you press a key but return immediately even when there's no data available.

So depending a bit on what you want you can either remove the O_NONBLOCK from the opening flags to make the read block until you press a key.

Or don't remove the flag and check the return value of the read function like this

Code: Select all

   unsigned char input; 
   while (true) 
   { 
      if (read(lcd,&input,1)==1)
      {
        if (input =='L') 
        {    
           printf("Connection Status"); 
           printf("You pressed %c\n",input); 
        } 
      }
   } 
however do realize it will run the code in your while loop an insane ammount of times so you probably want to put a delay in there so it won't soak up 100% cpu time while waiting for a keypress.

Also there is no need to clear the key unless you are in polled mode which is not the case by default.