Using 4x20 LCD for first time
Hello!
I just received the 4x20 LCD model #27979 from the parallax store and am trying to get familiar with it.
I am using the 'fullduplexserial.spin' from the example code, but having trouble placing characters where i would like to.
Here is an example of where I am having trouble. In the code below, I would like variable x to be placed at the end of the "test #:" string. But it does not clear the previous variable output before writing the next.
So my output look like this "Test #: 12345678910Complete" rather than only displaying one decimal at a time, then displaying "Complete" on a new line.
I looked through the fullduplexserial spin code and could not find a subroutine for clearing or for position.
How can I clear the screen? Can I choose coordinates for character placement?
I just received the 4x20 LCD model #27979 from the parallax store and am trying to get familiar with it.
I am using the 'fullduplexserial.spin' from the example code, but having trouble placing characters where i would like to.
Here is an example of where I am having trouble. In the code below, I would like variable x to be placed at the end of the "test #:" string. But it does not clear the previous variable output before writing the next.
So my output look like this "Test #: 12345678910Complete" rather than only displaying one decimal at a time, then displaying "Complete" on a new line.
I looked through the fullduplexserial spin code and could not find a subroutine for clearing or for position.
How can I clear the screen? Can I choose coordinates for character placement?
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
TX_PIN = 0
BAUD = 19_200
OBJ
LCD : "FullDuplexSerial.spin"
var
word x
PUB Main
LCD.start(TX_PIN, TX_PIN, %1000, 19_200)
waitcnt(clkfreq / 100 + cnt)
LCD.str(string("Test #:"))
repeat while x < 10
x := x + 1
LCD.dec(x)
waitcnt(clkfreq * 1 + cnt)
LCD.str(string("Complete"))

Comments
Whenever I try to send a DEC value, it just prints it on the screen.
How do I properly send these DEC codes?
I was trying this, which is obviously wrong:
I sincerely appreciate any help
So what it does when you send 10
it transforms the number 10 into asci-code 49 and asci-code 48
lcd.tx(49) lcd.tx(49)
For sending control-commands use the method tx
lcd.tx(10) will send just asci-code "10"
keep the questions coming
best regards
Stefan
That helped alot, I made a test program while learning.
Rolls through 5 sessions of counting to 10.. turns backlight on and plays with some of the positioning functions.
I guess the only thing I cannot figure out is exactly what DEC modes 23 & 25 are for...
description is "turn the display on, with cursor off(25=on) and character blink"... I assumed this meant anything displayed after setting that mode, would cause the characters to blink.
What I'm seeing though is just the cursor blinking.
I can only get something to blink if I do so like in the "ShowRST" subroutine.
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 TX_PIN = 0 BAUD = 19_200 OBJ LCD : "FullDuplexSerial.spin" var byte testctr byte session PUB Main LCD.start(TX_PIN, TX_PIN, %1000, 19_200) ' initialize LCD waitcnt(clkfreq / 100 + cnt) testctr := 1 'set counter to 1 instead of 0 NoCursor 'turn on display with no cursor repeat session from 1 to 5 CLS ' clear screen BKLon ' backlight on LCD.str(string("Session #:" )) LCD.dec(session) NewLine LCD.str(string("Test #:" )) repeat while testctr < 10 ' test counter back (1) LCD.dec(testctr) testctr++ waitcnt(clkfreq /2 + cnt) testctr := 0 ' reset test counter NewLine BlinkON ' makes the cursor blink is all? LCD.str(string("Session Complete")) lcd.tx(176) ' move to middle of 'Session Complete' LCD.dec(session) ' put session number in middle of words waitcnt(clkfreq * 3 + cnt) NoCursor ' back to no cursor mode if session < 5 ' do not display 'restarting' after 5th session ShowRST ' display blinking 'restarting' message CLS LCD.str(string("TEST DONE - OFF IN 3")) waitcnt(clkfreq * 3 + cnt) BKLoff ' backlight off LCDoff ' display off PUB Newline LCD.tx(13) pub NextLine LCD.tx(10) PUB CLS LCD.tx(12) PUB Back (n) repeat n LCD.tx(8) PUB BKLon LCD.tx(17) PUB BKLoff LCD.tx(18) PUB BlinkON LCD.tx(23) PUB Default LCD.tx(24) PUB NoCursor LCD.tx(22) PUB LCDoff LCD.tx(21) PUB ShowRST repeat 3 cls waitcnt(clkfreq / 2 + cnt) LCD.tx(153) ' move to position 2 x 5 LCD.str(string("Restarting")) Waitcnt(clkfreq / 2 + cnt)