LK202-25 LCDd keypad test mode

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

Moderators: Henry, Mods

Post Reply
tom.garratt
LCD?
Posts: 6
Joined: Wed May 14, 2008 11:24 am

LK202-25 LCDd keypad test mode

Post 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
Ray
Matrix Orbital
Matrix Orbital
Posts: 745
Joined: Thu Dec 13, 2001 4:00 pm
Location: Earth.... I think..
Contact:

Post 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?
tom.garratt
LCD?
Posts: 6
Joined: Wed May 14, 2008 11:24 am

?

Post by tom.garratt »

it would appear i'm having truble

Code: Select all

MtxOrb: Received character
Last edited by tom.garratt on Wed May 14, 2008 2:22 pm, edited 1 time in total.
Ray
Matrix Orbital
Matrix Orbital
Posts: 745
Joined: Thu Dec 13, 2001 4:00 pm
Location: Earth.... I think..
Contact:

Post 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.
tom.garratt
LCD?
Posts: 6
Joined: Wed May 14, 2008 11:24 am

Post 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
Raquel
Matrix Orbital
Matrix Orbital
Posts: 834
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post 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,
Raquel Malinis
Design and Development
Matrix Orbital
tom.garratt
LCD?
Posts: 6
Joined: Wed May 14, 2008 11:24 am

how

Post 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?
Ray
Matrix Orbital
Matrix Orbital
Posts: 745
Joined: Thu Dec 13, 2001 4:00 pm
Location: Earth.... I think..
Contact:

Post 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};
tom.garratt
LCD?
Posts: 6
Joined: Wed May 14, 2008 11:24 am

Post 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++
Ray
Matrix Orbital
Matrix Orbital
Posts: 745
Joined: Thu Dec 13, 2001 4:00 pm
Location: Earth.... I think..
Contact:

Post 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);
	}
tom.garratt
LCD?
Posts: 6
Joined: Wed May 14, 2008 11:24 am

Thanks

Post 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?
Ray
Matrix Orbital
Matrix Orbital
Posts: 745
Joined: Thu Dec 13, 2001 4:00 pm
Location: Earth.... I think..
Contact:

Post 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.
Post Reply