Writing custom characters to LCD display


Closed Thread
Results 1 to 40 of 60

Hybrid View

  1. #1
    badrad's Avatar
    badrad Guest

    Default Writing custom characters to LCD display

    Hi all. New to this forum. Tried a search but did not find any answer to my current design task.

    My current application is using the pic 16f876a displaying user data onto an Optrex 2x16 display. I would like to display a couple of custom characters, which in the Optrex manual seems to allow, by using the CG RAM area.

    I have not been able to find any command in the LCDOUT command that allows me to send data to this RAM area.

    Has anyone here tried this before and if so, some code example?

    Thanks!

  2. #2
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    Hi badrad,

    LCDOUT $FE,$60,$02,$06,$1a,$1a,$1a,$06,$02,$00
    LCDOUT $FE,$78,$06,$0f,$0f,$0f,$0f,$0f,$0f,$00

    The first line writes a "speaker" character to CGRAM address 4 and the last writes a "battery" to CGRAM addess 7.

    To use the character you just write......
    LCDOUT $04 'will write the "speaker" symbol.

    The addresses(characternumber) are the numbers located right after the $FE.

    character 0 = $40
    character 1= $48
    character 2 = $50
    character 3= $58
    character 4 = $60
    character 5= $68
    character 6 = $70
    character 7= $78

    The character itself is made up by the rest of the numbers following the address. Can't remeber if the bits are arranged horizontally or vertically. Draw it on a paper and have a look.

    /Ingvar

  3. #3
    badrad's Avatar
    badrad Guest


    Did you find this post helpful? Yes | No

    Default Hey Thanks!

    Ingvar,
    thanks ever so much, that worked out well. that has really save me so much time from having work it all out.

    I wanted to display some smiley faces and sad faces on the unit that I have built for kindergarten and primary school kids so that they can learn about energy, without having to deal with large numbers and such.

    thanks again.

    badrad

  4. #4
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Smile

    No worries,

    The image of happy kids in my mind makes it worth the effort, all three minutes of it ;-)

    Cheers
    /Ingvar

  5. #5
    badrad's Avatar
    badrad Guest


    Did you find this post helpful? Yes | No

    Default

    BTW, here is smiley and sad face symbol that i am trying out.

    LCDOUT $FE,$60,$00,$0a,$0a,$00,$00,$11,$0e,$00 'smiley symbol
    LCDOUT $FE,$78,$00,$0a,$0a,$00,$00,$0e,$11,$00 'sad symbol

    many thanks again!

    ps: the only problem with image of the happy kids was there were 60+ in each classroom, as we had to double up classes for the labs! there was so much energy in that small classroom and they were all so enthusiatic!


    badrad

  6. #6
    ants's Avatar
    ants Guest


    Did you find this post helpful? Yes | No

    Default How did you calculate that?

    Hi,

    I have used the character calculator at http://www.geocities.com/dinceraydin/lcd/charcalc.htm to draw some symbols, but cant understand how to implement the in picbasic pro. How did you arrive at those values for the battery symbol?

    Sorry if its a stupid question!

    Thanks,
    Anthony

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Anthony,

    There are 8 Custom Character locations. The location is selected by sending a command with the following format.
    %01xxx000 where xxx is the location 0-7

    location 0 = %01000000 = $40 = 64
    location 1 = %01001000 = $48 = 72
    location 2 = %01010000 = $50 = 80
    location 3 = %01011000 = $58 = 88
    location 4 = %01100000 = $60 = 96
    location 5 = %01101000 = $68 = 104
    location 6 = %01110000 = $70 = 112
    location 7 = %01111000 = $78 = 120

    The location is followed by 8 bytes of character data. Each byte represents 1 row of 5 dots from left to right. The upper 3 bits are ignored. You need to send all 8 rows, even if the character doesn't use them all.
    The 8th row is normally reserved for the Cursor.

    Using the examples from Ingvar & badrad you get these characters


    Code:
    Speaker LCDOUT $FE,$60,$02,$06,$1a,$1a,$1a,$06,$02,$00
    
    $02=%00010     X 
    $06=%00110    XX 
    $1a=%11010  XX X 
    $1a=%11010  XX X 
    $1a=%11010  XX X 
    $06=%00110    XX 
    $02=%00010     X 
    $00=%00000
    
    battery LCDOUT $FE,$78,$06,$0f,$0f,$0f,$0f,$0f,$0f,$00
    
    $06=%00110   XX 
    $0f=%01111  XXXX
    $0f=%01111  XXXX
    $0f=%01111  XXXX
    $0f=%01111  XXXX
    $0f=%01111  XXXX
    $0f=%01111  XXXX
    $00=%00000
    
    smiley LCDOUT $FE,$60,$00,$0a,$0a,$00,$00,$11,$0e,$00
    
    $00=%00000 
    $0a=%01010   X X 
    $0a=%01010   X X 
    $00=%00000
    $00=%00000
    $11=%10001  X   X
    $0e=%01110   XXX 
    $00=%00000
    
    Sad LCDOUT $FE,$78,$00,$0a,$0a,$00,$00,$0e,$11,$00
    
    $00=%00000
    $0a=%01010   X X 
    $0a=%01010   X X 
    $00=%00000
    $00=%00000
    $0e=%01110   XXX 
    $11=%10001  X   X
    $00=%00000
    To use the values from the Custom Character Generator you mentioned. You can either use the values that it creates, or you can subtract 128 to get values that resemble the examples here. The upper 3 bits of each byte is ignored by the display, so it will work either way.

    HTH,
    Last edited by Darrel Taylor; - 21st August 2012 at 20:16.

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I was just playing around with Ingvar's battery icon, and thought this was pretty neat.
    It allows you to show the battery level with the same icon.
    The demo just runs thru a loop counting backwards from 10, and changes the Custom Character accordingly.

    It also demonstrates how you can animate the characters by simply updating the CGRAM.
    Any characters that are already on the screen will automatically be updated as well.
    Code:
    BattLevel  var byte     ' 0 - 10, 0=Empty  10=Full
    Char       var byte
    y          var byte
    
    LCDout $FE,1,"    ",1," ",1," ",1," ",1  ' Show 4 batteries
    
    Loop:    ' Test loop showing all the possible Battery Levels
        for BattLevel = 10 to 0 step -1
            gosub ShowBattery
            pause 500
        next BattLevel
    goto Loop
    
    
    ShowBattery:     ' Show Battery Level  0 - 10, 0=Empty  10=Full
            lcdout $FE,$48,$06
            for y = 5 to 1 step -1
                if BattLevel >= (y * 2 - 1) then
                    if BattLevel >= (y * 2) then
                       Char = $0F
                    else
                       Char = $0B
                    endif
                else
                    Char = $09
                endif
                lcdout Char
            next y
            lcdout $0F,$00
    return
    Darrel
    Last edited by Darrel Taylor; - 21st August 2012 at 17:46.

  9. #9
    ants's Avatar
    ants Guest


    Did you find this post helpful? Yes | No

    Talking You guys are great :-)

    Thanks for the really clear explanation, got it working straight away!

    Many thanks..

    Anthony

  10. #10
    swordman's Avatar
    swordman Guest


    Did you find this post helpful? Yes | No

    Default Hi

    I use
    OPTREX hd4470A0 LCD
    16f877A (4mhz)
    pbp2.45


    I can't display this string , whats wrong ?

    LCDOUT $FE,$60,$00,$0a,$0a,$00,$00,$11,$0e,$00 'smiley symbol

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi swordman,

    Sending that string will define the Custom Character at location number 4. Then to actually display the character use this.

    LCDOUT 4

    HTH,
    Darrel

  12. #12
    swordman's Avatar
    swordman Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel !

    Working fine

  13. #13
    swordman's Avatar
    swordman Guest


    Did you find this post helpful? Yes | No

    Default

    Hi,
    How can I display 2 custom char like this:


    Lcdout $FE,$85,4
    LCDOUT $FE,$60,$1F,$11,$11,$11,$11,$11,$11,$0


    Lcdout $FE,$C2,4
    LCDOUT $FE,$78,$3,$5,$9,$9,$9,$11,$11,$0


    when I write that code lcd display only second

  14. #14
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Swordman,

    The second example uses Address $78 which is Location 7.

    To display that Custom Character use this

    <font="courier">Lcdout $FE,$C2,7</font>

    Darrel
    Last edited by Darrel Taylor; - 18th October 2005 at 06:17.

  15. #15
    Join Date
    Oct 2006
    Location
    Cape Town SA
    Posts
    23


    Did you find this post helpful? Yes | No

    Default More symbols

    This is fun!
    Here are 3 more:

    lcdout $FE,$60,$1F,$11,$15,$17,$17,$15,$11,$1F 'copyright sign
    lcdout $FE,$70,$0E,$11,$11,$11,$0E,$04,$0E,$04 'female symbol
    lcdout $FE,$78,$07,$03,$05,$08,$0E,$11,$11,$0E 'male symbol

    Lcdout $FE, $D4, 4, 6, 7

  16. #16
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Sweet

    and the tool to create them + PBP code easy... PicMultiCalc... once again
    http://www.mister-e.org/pages/utilitiespag.html

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1404&stc=1&d=117207765 7">
    Attached Images Attached Images  
    Last edited by mister_e; - 21st February 2007 at 19:31.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  17. #17
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    and the tool to create them + PBP code easy... PicMultiCalc... once again
    http://www.mister-e.org/pages/utilitiespag.html
    You're such a stud Steve.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  18. #18
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    LMAO, not sure of the meaning of this 'stud' expression but... thanks

    To me it's sounds x-rated... but since too much time i'm single so
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. LCD Display
    By lambert in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th January 2010, 22:18
  2. assembly in Pic
    By lerameur in forum Off Topic
    Replies: 11
    Last Post: - 1st May 2008, 20:06
  3. Replies: 14
    Last Post: - 26th September 2007, 05:41
  4. Crystalfontz LCD
    By jman12 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 9th February 2007, 15:04
  5. LCD Display not working - PIC heating...
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 24th September 2006, 07:35

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts