Shop OBEX P1 Docs P2 Docs Learn Events
Weired results with Serial_Lcd — Parallax Forums

Weired results with Serial_Lcd

marzec309marzec309 Posts: 146
edited 2009-04-19 01:45 in Propeller 1
OK, I'm stumped. I just got my First propeller today and I'm slowly grasping the propeller language. But when I try to link to a Parallax 4x20 serial lcd, using the Serial_LCD Object from the Object Exchange, I get weird results. Text doesn't show up as expected. Well here's the simple test code I'm try to use.

CON
  _CLKMODE = XTAL1 + PLL16X
  _XINFREQ = 5_000_000

OBJ
  LCD           : "Serial_Lcd"

PUB main
  WAITCNT(clkfreq / 10 + cnt)
  LCD.init(9,9600,4)
  LCD.cursor(1)
  LCD.cls
  LCD.backLight(true)
  LCD.str(str1)
  waitcnt(clkfreq * 5 + cnt)

DAT
        str1 byte "Proto Prop Rocks",13,0





The display seems to respond to function commands. But, the text never shows up in the right place. Its shifted off the left egde when it actualy shows up and isn't Smile.

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-04-16 05:15
    Hello Marzec,

    you have to call the command LCD.str like this

      LCD.str(@str1)
    
    



    the "@" in this use is called the adress-operator

    If you get strange results from something it's always worth a look into the definition of the code

    the method str in the file serial_Lcd.spin

    PUB str(strAddr)
    
    '' Transmit z-string at strAddr
    
      serial.str(strAddr)
    
    



    "strAdr means string ADRESS (=location in memory where the string is stored)

    to narrow down problems like this

    try variations like this

    PUB main
      WAITCNT(clkfreq / 10 + cnt)
      LCD.init(9,9600,4)
      LCD.cursor(1)
      LCD.cls
      LCD.backLight(true)
      LCD.putc("T")
      LCD.putc("e")
      LCD.putc("s")
      LCD.putc("t")
      waitcnt(clkfreq * 5 + cnt)
    
    
    



    or

    PUB main
      WAITCNT(clkfreq / 10 + cnt)
      LCD.init(9,9600,4)
      LCD.cursor(1)
      LCD.cls
      LCD.backLight(true)
      LCD.str(string("Hello World"))
      waitcnt(clkfreq * 5 + cnt)
    
    
    




    best regards

    Stefan
  • marzec309marzec309 Posts: 146
    edited 2009-04-19 01:45
    Thanks, sometimes I amaze myself. I looked up the definition a few times, just never caught the @ designator.
Sign In or Register to comment.