Shop OBEX P1 Docs P2 Docs Learn Events
Displaying variables on an LCD — Parallax Forums

Displaying variables on an LCD

Jim the HermitJim the Hermit Posts: 79
edited 2012-07-30 13:34 in General Discussion
I would like my LCD to display a variable. It's the 4x20 serial (#27979)

CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
TX_PIN = 0
BAUD = 19_200

VAR
byte aa


OBJ
LCD : "FullDuplexSerial.spin"

PUB Main
aa := 99
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
LCD.str(string("Hello, this text will wrap."))
lcd.str(string(13)) ' carriage return
lcd.str(string(aa))


The last line doesn't work, neither does "lcd.str(string aa)", "lcd.str(aa)", lcd.str aa"
Nor any other combination I could think of.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-07-27 20:02
    You can't use .str to display a number. It's for displaying strings. You use .dec or .hex depending on how you want the number to appear.

    With almost all of the Spin objects, whether in the Object Exchange or included with the Propeller Tool, each public method has a comment that describes what the method does, what parameters it requires, and what result, if any, it returns. Please look at the source code for the objects you use, particularly the comments.
  • Jim the HermitJim the Hermit Posts: 79
    edited 2012-07-29 20:17
    Thank you- You know, .dec, .hex functions doesn't appear in the LCD manual.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-07-29 21:48
    That's why you're supposed to look at the source code comments in the objects you use.
  • piguy101piguy101 Posts: 248
    edited 2012-07-30 13:34
    Don't forget to use LCD.tx to make the LCD do stuff such as form feed.
Sign In or Register to comment.