Shop OBEX P1 Docs P2 Docs Learn Events
Inserting more than one Special Characters (LCD) — Parallax Forums

Inserting more than one Special Characters (LCD)

gc3076gc3076 Posts: 44
edited 2006-02-22 15:04 in BASIC Stamp
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

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-21 19:16
    It's easy: Add the definition after your first (so they appear in the DATA section in the order of their definition), and then change the download loop change the ending value of the download loop to 17 (for a total of 18 bytes downloaded [noparse][[/noparse]two are used to alert the LCD of custom character data]).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • gc3076gc3076 Posts: 44
    edited 2006-02-21 19:45
    Sorry I am missing something ?

    '
    [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
  • gc3076gc3076 Posts: 44
    edited 2006-02-21 23:43
    thoughts
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-22 00:01
    Sorry if I wasn't clear -- here's what I meant:

    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
  • gc3076gc3076 Posts: 44
    edited 2006-02-22 12:33
    That doesn't seem to work, where would the added CC1·DATA string·be read ?·
  • gc3076gc3076 Posts: 44
    edited 2006-02-22 13:21
    this works but seems like a lot of code for 2 characters, thoughts

    ' 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]
  • Tom WalkerTom Walker Posts: 509
    edited 2006-02-22 14:59
    gc3076,
    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 WilliamsJon Williams Posts: 6,491
    edited 2006-02-22 15:04
    I've attached a [noparse][[/noparse]working] demo.· Please run the program unmodified so that you can see the technique works before attempting to fold it into your own application.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.