Shop OBEX P1 Docs P2 Docs Learn Events
CLS for 4X20 LCD? — Parallax Forums

CLS for 4X20 LCD?

electromanjelectromanj Posts: 270
edited 2010-05-21 06:01 in Propeller 1
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))

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2010-05-20 22:13
    so what did you try?
    what is the exact type of your display?
    can you provide a datasheet?
  • electromanjelectromanj Posts: 270
    edited 2010-05-20 22:21
    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
  • electromanjelectromanj Posts: 270
    edited 2010-05-20 22:44
    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!
  • electromanjelectromanj Posts: 270
    edited 2010-05-20 22:52
    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))·····························'Clear 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."))
  • electromanjelectromanj Posts: 270
    edited 2010-05-20 23:02
    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!
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-05-21 04:19
    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
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-05-21 06:01
    @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.
Sign In or Register to comment.