LK-204-25 LCD question
I am using the LK-204-25 4x20 Display from From Parallax with SX28 SX/B. I am able to
write to the display just fine with the sub routine code from the help file. My problem is
when ever I insert a Character it moves the character that was in the original position
to the right ... Example:
Set Display :
········ Col1 Col2 Col3 Col4 Col5 Col6
Row1···· M··· I···· K···· E···· Y··"BLANK"
Row2
Row3
Row4
When I try to CHANGE the character in Col1 Row1 it moves everything to the right.
I put lowercase "m" into Col1 Row1 it looks like this :
·········Col1 Col2 Col3 Col4 Col5 Col6
Row1·····m··· M····I···· K···· E ···· Y
Row2
Row3
Row4
I just want it to replace the character ond not move everything.
I have tried to set AutoScroll and AutoLinr wrap ON and OFF all combinations
and it does not work.
Any help would be appreciated.
Thanks
mikey
write to the display just fine with the sub routine code from the help file. My problem is
when ever I insert a Character it moves the character that was in the original position
to the right ... Example:
Set Display :
········ Col1 Col2 Col3 Col4 Col5 Col6
Row1···· M··· I···· K···· E···· Y··"BLANK"
Row2
Row3
Row4
When I try to CHANGE the character in Col1 Row1 it moves everything to the right.
I put lowercase "m" into Col1 Row1 it looks like this :
·········Col1 Col2 Col3 Col4 Col5 Col6
Row1·····m··· M····I···· K···· E ···· Y
Row2
Row3
Row4
I just want it to replace the character ond not move everything.
I have tried to set AutoScroll and AutoLinr wrap ON and OFF all combinations
and it does not work.
Any help would be appreciated.
Thanks
mikey
Comments
Moving the Cursor
When you send a character to the Serial LCD, it always displays at the current cursor position. There are a few different ways to move the cursor on the Serial LCD display. After each character you send, the cursor automatically moves over one position. Along with this, there is a standard set of cursor move commands including Backspace, Carriage Return, and Line Feed.·
The Backspace/Left command (Dec 8) moves the cursor one place to the left and the Right command (Dec 9) moves the cursor one place to the right. These can be useful for moving the cursor around to overwrite existing text. These commands wrap to the next line of the display, if necessary. The Line Feed command (Dec 10) moves the cursor to the next line of the display without changing the horizontal position of the cursor. The Carriage Return command (Dec 13) also moves the cursor to the next line, but it moves the cursor to the leftmost position on that line as well. The Form Feed command (Dec 12) clears the entire display and moves the cursor to the leftmost position on line 0, just like when you first turn on the display. You will need to pause for 5mS in your code after sending the Form Feed command, to give the Serial LCD time to clear the display. Except for Form Feed, none of these move commands affects the characters on the display.
the empty Squares. Once I removef the SUB I was able to over right and COl
or ROW without using a backspace. I just set it to the Col Row and inserted a Character
and it Writes over it without shifting everything over.
Thanks
again
mikey
' =========================================================================
'
'·· File...... SERIAL_LCD_DEMO-V2.SXB
'·· Purpose... Demonstrates the Parallax Serial LCD with SX/B
'·· Author.... (c) Parallax, Inc. -- All Rights Reserved
'·· E-mail.... support@parallax.inc
'·· Started...
'·· Updated... 13 NOV 2005
'
' =========================================================================
'
' Program Description
'
'
' Device Settings
'
'DEVICE········· SX28, OSCXT2, TURBO, STACKX, OPTIONX
'FREQ··········· 4_000_000
DEVICE········ SX28, OSCHS3, TURBO, STACKX, OPTIONX
FREQ·········· 50_000_000
'
' IO Pins
'
LcdTx··VAR·RA.2···' LCD serial connection
'
' Constants
'
LcdBaud··CON·"T19200"··' or T2400, or T9600
LcdBkSpc······· CON···· $08············ ·' move cursor left
LcdRt·········· CON···· $09············ ·' move cursor right
LcdLF·········· CON···· $0A············ ·' move cursor down 1 line
LcdCls········· CON···· $0C············ ·' clear LCD (need 5 ms delay)
LcdCR·········· CON···· $0D············ ·' move pos 0 of next line
LcdBLon········ CON···· $11············ ·' backlight on
LcdBLoff······· CON···· $12············ ·' backlight off
LcdOff········· CON···· $15············ ·' LCD off
LcdOn1········· CON···· $16············ ·' LCD on; no crsr, no blink
LcdOn2········· CON···· $17············ ·' LCD on; no crsr, blink on
LcdOn3········· CON···· $18············ ·' LCD on; crsr on, no blink
LcdOn4········· CON···· $19············ ·' LCD on; crsr on, blink on
LcdLine1······· CON···· $80············ ·' move to line 1, column 0
LcdLine2······· CON···· $94············ ·' move to line 2, column 0
LcdCC0········· CON···· $F8············ ·' define custom char 0
LcdCC1········· CON···· $F9············ ·' define custom char 1
LcdCC2········· CON···· $FA············ ·' define custom char 2
LcdCC3········· CON···· $FB············ ·' define custom char 3
LcdCC4········· CON···· $FC············ ·' define custom char 4
LcdCC5········· CON···· $FD············ ·' define custom char 5
LcdCC6········· CON···· $FE············ ·' define custom char 6
LcdCC7········· CON···· $FF············ ·' define custom char 7
LcdCol1··CON·$1
LcdCol2··CON·$2
LcdCol3··CON···· $3
LcdCol4··CON·$4
LcdCol5··CON···· $5
LcdRow1··CON···· $1
LcdRow2··CON···· $2
LcdRow3··CON···· $3
LcdRow4··CON···· $4
LcdCMDSet······ CON·$FE
LcdColRowCmd··· CON···· $47
LcdNOAutoScrl·CON···· $52·
'
' Variables
'
idx1··········· VAR···· Byte···' loop control
idx2··········· VAR···· Byte
char··········· VAR···· Byte
newChar········ VAR···· Byte
pos··VAR·Byte···' position
temp1··VAR·Byte···' subroutine work vars
temp2··VAR·Byte
temp3··VAR·Byte
temp4··VAR·Byte
temp5··VAR·Byte
ADValue··VAR·Word
TestValueLF·VAR···· Byte···' FailHI= $1, PASS= $2, FailLo= $3
TestValueRF·VAR···· Byte···' FailHI= $1, PASS= $2, FailLo= $3
TestValueWR·VAR···· Byte···' FailHI= $1, PASS= $2, FailLo= $3
RowValue·VAR·Byte···'Select ROW can be use for ALL Test Status
' =========================================================================
· PROGRAM Start
' =========================================================================
'
' Subroutine Declarations
'
WAIT_MS··SUB·1, 2···' delay in milliseconds
LCD_OUT··SUB·1, 2···' byte or string to LCD
LCD_SET········ SUB···· 1
'
' Program Code
'
Start:
· PLP_A = %0001·····' pull up unused pins
· PLP_B = %00000000
· PLP_C = %00000000
· HIGH LcdTx
· WAIT_MS 100·····' let LCD initialize
·
Main:
· TestValueLF = $1
· 'LCD_OUT LcdCMDSet····' $FE (254)
· 'LCD_OUT $44·········· ' $52
· 'LCD_OUT LcdCMDSet····' $FE (254)
· 'LCD_OUT $52·········· ' $52
· 'LCD_OUT LcdBLon····' backlight on
· LCD_OUT LcdOn1····' no cursor or blink
· LCD_OUT LcdCls····' clear the LCD
· LCD_SET 1
· WAIT_MS 10
·
· LCD_OUT LcdCMDSet······ ···' Set Cursor position Command 1st Byte
· LCD_OUT LcdColRowCmd························· ' Set Cursor position Command 2nd Byte
· LCD_OUT LcdCol5····' Column 5·········
· LCD_OUT LcdRow1····' Row··· 1
· LCD_OUT "Fail HIGH"····' Value To Put In Cursor position
· LCD_OUT LcdCMDSet····' Set Cursor position Command 1st Byte
· LCD_OUT LcdColRowCmd························· ' Set Cursor position Command 2nd Byte
· LCD_OUT LcdCol5····' Column 5·········
· LCD_OUT LcdRow2····' Row··· 2
· LCD_OUT "PASS"····' Value To Put In Cursor position
· LCD_OUT LcdCMDSet····' Set Cursor position Command 1st Byte
· LCD_OUT LcdColRowCmd························· ' Set Cursor position Command 2nd Byte
· LCD_OUT LcdCol5····' Column 5·········
· LCD_OUT LcdRow3····' Row··· 3
· LCD_OUT "Fail LOW"····' Value To Put In Cursor position
······' Draws the "empty outlined squares" to the screen
· If TestValueLF = $1 Then···' $1 =· FAIL HI
···· LCD_OUT LcdCMDSet· ···' $FE (254)
···· LCD_OUT $51
···· LCD_OUT LcdCMDSet· ···' $FE (254)
···· LCD_OUT LcdColRowCmd······················ ' Set Cursor position Command 2nd Byte
···· LCD_OUT LcdCoL2
···· LCD_OUT LcdRow1
···· LCD_OUT $FF
·····
ELSE···
· ENDIF
·
·
·
' Scroll "chomper" animation across LCD line 2
' Flash LCD backlight (works only with backlit model)
'Flash:
'· FOR idx1 = 1 TO 4
'··· LCD_OUT LcdBLon
'··· WAIT_MS 250, 3
'··· LCD_OUT LcdBLoff
'··· WAIT_MS 250
'· NEXT
'· GOTO Main
'
' Subroutine Code
'
LCD_SET:
· LCD_OUT $DB·····'$DB sets outlined box pattern
· LCD_OUT $DB·····' ---
· LCD_OUT $DB···················
· LCD_OUT LcdLF
· Pause 10
· LCD_OUT $DB
· LCD_OUT $DB
· LCD_OUT $DB
· LCD_OUT LcdLF
· Pause 10·····' Line Feed/New Line
· LCD_OUT $DB
· LCD_OUT $DB
· LCD_OUT $DB
· Pause 10
· RETURN
' Use: WAIT_MS milliseconds {, multiplier }
' -- multiplier is optional
WAIT_MS:
· temp1 = __PARAM1····························· ' get milliseconds
· IF __PARAMCNT = 1 THEN······················· ' if no multiplier
··· temp2 = 1·································· '·· set to 1
· ELSE········································· ' else
··· temp2 = __PARAM2··························· '·· get multiplier
· ENDIF
· IF temp1 > 0 THEN···························· ' no delay if either 0
··· IF temp2 > 0 THEN
····· PAUSE temp1 * temp2······················ ' do the delay
··· ENDIF
· ENDIF
· RETURN
'
' Use: LCD_OUT [noparse][[/noparse] aByte | string | label ]
' -- "aByte" is single-byte constant or variable
' -- "string" is an embedded literal string
' -- "label" is DATA statement label for stored z-String
LCD_OUT:
· temp1 = __PARAM1····' byte or offset
· IF __PARAMCNT = 2 THEN···' string specified
··· temp2 = __PARAM2····' yes, save base
··· DO
····· READ temp2 + temp1, temp3············ ·' read a character
····· IF temp3 = 0 THEN EXIT················ ·' if 0, string complete
····· SEROUT LcdTx, LcdBaud, temp3········· ·' send the byte
····· INC temp1···························· ·' point to next character
····· temp2 = temp2 + Z···················· ·' update base on overflow
··· LOOP
· ELSE
··· SEROUT LcdTx, LcdBaud, temp1··' transmit to LCD
· ENDIF
· RETURN
'
' Use: LCD_CCHAR CharDef
' -- loads custom character definition into serial LCD
' -- "CharDef" is DATA table that holds character number and definition
'··· bytes
' =========================================================================
' Program Data
' =========================================================================