Inserting more than one Special Characters (LCD)
gc3076
Posts: 44
I am trying to create a graphic on my 2x16 serial LCD. I have figured out how to insert one special character but now am wondering how to add a second character to get the result I am looking for.
LcdCC0, $02,$06,$0E,$1F,$0E,$06,$02,$00· ·(<- arrow head)
LcdCC1 $00,$00,$00,$1F,$00,$00,$00,$00·· ·(--- continued arrowhead)
How do I add the second special character to the code so that the graphic looks like a arrowhead ?
My code for the arrowhead is below:
' special characters
' {$STAMP BS2}
' {$PBASIC 2.5}
LcdPin········ PIN···· 14
'
[noparse][[/noparse] Constants ]
LcdBaud········ CON···· 84
LcdCls········· CON···· $0C
LcdCC0········· CON···· $F8
LcdBaudMode···· CON···· 84
AdcBaudMode···· CON···· 84
LcdStart······ CON···· 22
LcdOn········· CON···· 17
Line0········· CON···· 128
Line1········· CON···· 148
T9600········· CON···· 84
'
[noparse][[/noparse] Variables ]
idx1·········· VAR···· Byte
char1·········· VAR···· Byte
'
[noparse][[/noparse] EEPROM Data ]
CC0············ DATA··· LcdCC0, $02,$06,$0E,$1F,$0E,$06,$02,$00
'
[noparse][[/noparse] Initialization ]
PAUSE 500
SEROUT LcdPin, LcdBaudMode, [noparse][[/noparse]LcdStart, LcdCls, LcdOn]
PAUSE 500
DnLoad_Custom_Chars:
FOR idx1 = 0 TO 8
READ CC0 + idx1, char1
SEROUT LcdPin , LcdBaud, [noparse][[/noparse]CHAR1]
NEXT
'
[noparse][[/noparse] Main Routine calculation· ]
SEROUT LcdPin, LcdBaudMode, [noparse][[/noparse]"left ", 0 ]
Post Edited (gc3076) : 2/21/2006 8:15:29 PM GMT
LcdCC0, $02,$06,$0E,$1F,$0E,$06,$02,$00· ·(<- arrow head)
LcdCC1 $00,$00,$00,$1F,$00,$00,$00,$00·· ·(--- continued arrowhead)
How do I add the second special character to the code so that the graphic looks like a arrowhead ?
My code for the arrowhead is below:
' special characters
' {$STAMP BS2}
' {$PBASIC 2.5}
LcdPin········ PIN···· 14
'
[noparse][[/noparse] Constants ]
LcdBaud········ CON···· 84
LcdCls········· CON···· $0C
LcdCC0········· CON···· $F8
LcdBaudMode···· CON···· 84
AdcBaudMode···· CON···· 84
LcdStart······ CON···· 22
LcdOn········· CON···· 17
Line0········· CON···· 128
Line1········· CON···· 148
T9600········· CON···· 84
'
[noparse][[/noparse] Variables ]
idx1·········· VAR···· Byte
char1·········· VAR···· Byte
'
[noparse][[/noparse] EEPROM Data ]
CC0············ DATA··· LcdCC0, $02,$06,$0E,$1F,$0E,$06,$02,$00
'
[noparse][[/noparse] Initialization ]
PAUSE 500
SEROUT LcdPin, LcdBaudMode, [noparse][[/noparse]LcdStart, LcdCls, LcdOn]
PAUSE 500
DnLoad_Custom_Chars:
FOR idx1 = 0 TO 8
READ CC0 + idx1, char1
SEROUT LcdPin , LcdBaud, [noparse][[/noparse]CHAR1]
NEXT
'
[noparse][[/noparse] Main Routine calculation· ]
SEROUT LcdPin, LcdBaudMode, [noparse][[/noparse]"left ", 0 ]
Post Edited (gc3076) : 2/21/2006 8:15:29 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
'
[noparse][[/noparse] Variables ]
idx1·········· VAR···· Byte
idx2·········· VAR···· Byte
char1·········· VAR···· Byte
char2·········· VAR···· Byte
'
[noparse][[/noparse] EEPROM Data ]
CC0············ DATA··· LcdCC0, $02,$06,$0E,$1F,$0E,$06,$02,$00
CC1············ DATA··· LcdCC0, $00,$00,$00,$1F,$00,$00,$00,$00
'
[noparse][[/noparse] Initialization ]
PAUSE 500
SEROUT LcdPin, LcdBaudMode, [noparse][[/noparse]LcdStart, LcdCls, LcdOn]
PAUSE 500
DnLoad_Custom_Chars:
FOR idx1 = 0 TO 17
READ CC0 + idx1, char1
READ CC1 + idx2, char2
SEROUT LcdPin , LcdBaud, [noparse][[/noparse]CHAR1, char2]
NEXT
'
[noparse][[/noparse] Main Routine calculation· ]
SEROUT LcdPin, LcdBaudMode, [noparse][[/noparse]"left ", 0,1]
Post Edited (gc3076) : 2/21/2006 8:15:49 PM GMT
idx···· VAR···· Byte
char··· VAR···· Byte
CC0·····DATA··· LcdCC0, $02,$06,$0E,$1F,$0E,$06,$02,$00
CC1···· DATA··· LcdCC0, $00,$00,$00,$1F,$00,$00,$00,$00
Setup:
· PAUSE 500
DnLoad_Custom_Chars:
· FOR idx1 = 0 TO 17
··· READ CC0 + idx, char
··· SEROUT LcdPin , LcdBaud, [noparse][[/noparse]char]
· NEXT
· SEROUT LcdPin, LcdBaud, [noparse][[/noparse]LcdStart, LcdCls, LcdOn]
Main:
· SEROUT LcdPin, LcdBaud, [noparse][[/noparse]"Left ", 0, 1]
· END
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
' special characters
' {$STAMP BS2}
' {$PBASIC 2.5}
LcdPin PIN 14
'
[noparse][[/noparse] Constants ]
LcdBaud CON 84
LcdCls CON $0C
LcdCC0 CON $F8 'load or save each of the 8 bytes for special characters
LCD_display_CC0 CON 0
LcdCC1 CON $F9 'load or save each of the 8 bytes for special characters
LCD_display_CC1 CON 1
LcdBaudMode CON 84
AdcBaudMode CON 84
LcdStart CON 22
LcdOn CON 17
Line0 CON 128
Line1 CON 148
T9600 CON 84
'
[noparse][[/noparse] Variables ]
idx1 VAR Byte
char1 VAR Byte
'
[noparse][[/noparse] EEPROM Data ]
CC0 DATA LcdCC0, $04,$04,$0C,$1F,$0C,$04,$04,$00 'LCD character
CC1 DATA LcdCC1, $00,$00,$00,$1F,$00,$00,$00,$00 'LCD character
'
[noparse][[/noparse] Initialization ]
PAUSE 500
SEROUT LcdPin, LcdBaudMode, [noparse][[/noparse]LcdStart, LcdCls, LcdOn]
PAUSE 500
DnLoad_Custom_Chars:
FOR idx1 = 0 TO 8 'loads each of the look at line 28/29 (8 char)
READ CC0 + idx1, char1
SEROUT LcdPin , LcdBaud, [noparse][[/noparse]CHAR1]
NEXT
FOR idx1 = 0 TO 8
READ CC1 + idx1, char1
SEROUT LcdPin , LcdBaud, [noparse][[/noparse]CHAR1]
NEXT
'
[noparse][[/noparse] Main Routine calculation ]
SEROUT LcdPin, LcdBaudMode, [noparse][[/noparse]line1, " left ",LCD_display_CC0, LCD_display_CC1]
To answer your question of when the CC1 data is read, the way that Jon wrote the code, and the architecture of the Stamp, dictates that the CC1 data follows immediately after the CC0 data in EEPROM memory, so the FOR..NEXT loop reads the CC1 data when idx1 exceeds 7 (since there are 8 values in the CC0 DATA statement and idx1 starts at 0). If it helps, just think of the DATA statement as actually saying "these values start at an address that I am calling CC0". If you "run off the end" of the CC0 "list", you run into the CC1 "list" (again, CC1 is just a place in memory...the byte after the last CC0 value).
Definite need for caffeine...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax