PDA

View Full Version : CLS for 4X20 LCD?



electromanj
05-21-2010, 05:26 AM
Hello all.

I am having a little trouble getting the screen to clear on my 4 x 20 LCD. I've tryed a few things but no luck. Thanks for any help!
CON
и _clkmode = xtal1 + pll16xииииииииииииииииииииииииииии ' use crystal x 16
и _xinfreq = 5_000_000иииииииииииииииииииииииииииииииии ' 5 MHz cyrstal (sys clock = 80 MHz)
и TX_PINиииииии = 24
и BAUDиииииииии = 19_200
и cr = 13
иииииииииииииииииии
OBJ
и LCDииииииииии : "FullDuplexSerialplus.spin"

PUB Main
и LCD.start(TX_PIN, TX_PIN, %1000, 19_200)
и waitcnt(clkfreq / 100 + cnt)иииииииииииииии ' Pause for FullDuplexSerial.spin to initialize
ииLCD.str(string("Hello, this text will wrap.",16))

StefanL38
05-21-2010, 06:13 AM
so what did you try?
what is the exact type of your display?
can you provide a datasheet?

electromanj
05-21-2010, 06:21 AM
Hello,
The display is a 4x20 backlit from parallax.
I tried to add a ,16 after the text. If I add a ,13 after the text i do get a carrige return.
Thanks

electromanj
05-21-2010, 06:44 AM
I found the problem. I should of used a 12 instead of a 16. Or maybe I should have read the LCD documentation again instead of guessing!
Thanks!

electromanj
05-21-2010, 06:52 AM
Here's what I have now in case it helps somebody else.

CON
и _clkmode = xtal1 + pll16xииииииииииииииииииииииииииии ' use crystal x 16
и _xinfreq = 5_000_000иииииииииииииииииииииииииииииииии ' 5 MHz cyrstal (sys clock = 80 MHz)

и TX_PINиииииии = 24
и BAUDиииииииии = 19_200
и cr = 13
иииииииииииииииииии
OBJ

и LCDииииииииии : "FullDuplexSerialplus.spin"


PUB Main

и LCD.start(TX_PIN, TX_PIN, %1000, 19_200)
и waitcnt(clkfreq / 100 + cnt)иииииииииииииии ' Pause for FullDuplexSerial.spin to initialize
и
и lcd.str(string(12))иииииииииииииииииииииииииииии'C lear screen return to top
и waitcnt(clkfreq*1+cnt)
и lcd.str(string(17))ииииииииииииииииииииииииииии 'turn on backlight
и waitcnt(clkfreq*1+cnt)
и lcd.str(string(168))иииииииииииииииииииииииииииии' go to rowи3 column 1
и LCD.str(string("Hello, this text will wrap."))

electromanj
05-21-2010, 07:02 AM
Sorry to drag this out,but attached is aи chart I made a while back that helps me to layout my display text. It has all the positions of the cursor dec numbers so you can draw it out on paper. It opens with express schematic, free download from expresspcb.com. Hope this helps someone!

JonnyMac
05-21-2010, 12:19 PM
There's an object in the Samples library called Serial_Lcd that has what you're looking for. There's no need to use a cog with FDS for the Parallax Serial LCD as you can send bytes at 19.2k (max baud) in Spin.и The object contains constant for common processes like CLS.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

MagIO2
05-21-2010, 02:01 PM
@electromanj:
Just one more word about your code ...
Instead of lcd.str( string(168) ) for sending single bytes, you should use the tx function:
lcd.tx( 168 )

It's just a small difference, but if you use this a lot ...

string() occupies one byte for the byte you want to send plus one byte for the string-end byte, which is a $00.
And it will be slightly slower, as lcd.str will run a loop to copy the string to the transfer-buffer. Even if it's only one iteration when sending one byte I'd guess that it takes double time until it returns to the caller.