Shop OBEX P1 Docs P2 Docs Learn Events
LCD CGRam question — Parallax Forums

LCD CGRam question

agentileagentile Posts: 101
edited 2006-01-03 16:27 in BASIC Stamp
Hello,
· I am trying to create a custom character in a parallel 1x16 LCD display.··I have used one of the articles in StampWorks to get as far as I have.· So far, I have successfully created the degree symbol, which I wanted, but I cannot figure out where it is in CGram.· So, the following code·successfully·creates the character.

CX DATA $07, $05, $07, $00, $00, $00, $00, $00·· ' (degree symbol)

char = $40········ ····················· '·point to CGRAM
GOSUB LCD_Command················ ' prepare to write CG data
FOR index1 = CX TO (CX + 7)······ ' create degree symbol
READ index1, char····················· ' get byte from EEPROM
GOSUB LCD_Write······················ ' put into LCD CG RAM
NEXT

So, now I want to display it on the LCD, and so I write the following code

READ CX+k,char····· ' Read·EEPROM??·or CGRAm?··k is offset value·
GOSUB LCD_Write··· ' write degree symbol

So, for reasons I cannot explain, this code works, even though it appears I am simply reading from EEPROM and not CGRam.· The value of k·was found by trial and error.· The degree symbol shows up for any value of k from·3 to 15.· Why does this work?·· And what I am reading?

More specifically, my question is,·once I have written a character to CGRam, how do I access it?

thanks,
Andrew

·

Comments

  • Kaos KiddKaos Kidd Posts: 614
    edited 2005-12-31 06:33
    If it's like the 2X16, it's Ascii 0 = first, ascii 1 = second, ect...
    (I had to search for this one...)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Until our bytes cross again, may your chips never smoke, your bits never fall off, your parts bin never be empty and your jumpers never fall off.
    KK
    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-01 04:35
    There are 64 bytes in the CGRAM; each character consumes eight bytes. As KaosKidd pointed out, the character codes for customer characters are 0 - 7.

    In the program, the character definition is copied from EEPROM to the CGRAM; you have to do this at the beginning of the program because the CGRAM is volitale and it will be lost of power-down.

    Note that if you don't need custom characters you can write and read CGRAM and for use as temporary storage.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • agentileagentile Posts: 101
    edited 2006-01-01 23:29
    Jon,

    · Let me just make sure I understand.· Once I have written a single character to CGRam, it then becomes labeled as 0.· So, to access the character, I send the character 0 to the LCD·as a write command.· This will·access whatever is sitting in the first eight bytes of CGRam.· Is this correct?



    thanks,

    Andrew·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-01 23:37
    The first eight bytes of the CGRAM form character 0, the second eight bytes form character 1, and so on. So, yes, after you've moved your character definition(s) to CGRAM, displaying a character is a simple matter of writing its code (0 - 7) to the display (DDRAM).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Tom WalkerTom Walker Posts: 509
    edited 2006-01-03 16:27
    agentile,
    It depends on where you saved your character data. When you save it to the LCD (as was pointed out, this is volatile, so it will no longer be there if you power the LCD off), you specify WHERE to save it. If you save it in the first 8 bytes, then "printing" a char 0 will display the character defined by what you saved starting at 0. "Printing" a char 1 will display the character defined by the 8 bytes starting at what you saved starting at byte 8.

    Ouch...that was poorly worded, but I need more caffeine....

    HTH

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
Sign In or Register to comment.