Society of Robots - Robot Forum

Software => Software => Topic started by: spizzak on July 27, 2009, 08:53:51 AM

Title: LCD commands
Post by: spizzak on July 27, 2009, 08:53:51 AM
I've got my LCD to display some text through rprintf commands, but text wrapping seems to be setup for a 16x2 so I need to change that, but I cant figure out how to send the "special carracter" 124 or 0x7c to the LCD in order to change it or to do anything else for example clear screen.

Can anyone help me out with how to send special commands. This is the LCD:

http://www.sparkfun.com/commerce/product_info.php?products_id=462 (http://www.sparkfun.com/commerce/product_info.php?products_id=462)

Thanks!
Title: Re: LCD commands
Post by: Webbot on July 27, 2009, 02:07:19 PM
Just use

rprintfChar(0x7c);

or

rprintfChar(124);

So to set the Backlight to 40% on then you need to send: 0x7c followed by 140
ie
rprintfChar(0x7c); rprintfChar(140);

Title: Re: LCD commands
Post by: spizzak on July 28, 2009, 09:07:46 AM
That doesn't seem to be working.. its just printing jibberish to my LCD. Any ideas?
Title: Re: LCD commands
Post by: Webbot on July 28, 2009, 11:32:32 AM
Have you tried hooking up the UART to HyperTerminal to see what is being sent? Or even better - download and use Realterm as that is much better at displaying 'non ascii' characters.

I presume that you have set the UART to 9600 baud, no parity, 1 stop and 8 data bits. The reason I say that is that commands starting with 124 are also used to modify the baud rate. So if the top bit of the second byte (140) is being stripped out somehow then it will get converted to 12 which will then change the baud rate instead - and thus you get garbage from then on.


Title: Re: LCD commands
Post by: spizzak on July 28, 2009, 12:40:24 PM
The problem seems to be that once I send the special character I cant do anything with it until it is reset. I was able to use it to set the screen size to 20x4 from 16x2 by doing:

rprintfChar(124);
rprintfChar(3);

then I had to reboot it and do

rprintfChar(124);
rprintfChar(5);

but when I try to clear the screen using

rprintfChar(124);
rprintfChar(0x01);

it doesn't clear it, it just seems to freeze the screen and not let me write to it until it is rebooted.