Writing custom characters to LCD display


Results 1 to 40 of 60

Threaded View

  1. #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 18:46.

Similar Threads

  1. LCD Display
    By lambert in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th January 2010, 23:18
  2. assembly in Pic
    By lerameur in forum Off Topic
    Replies: 11
    Last Post: - 1st May 2008, 21:06
  3. Replies: 14
    Last Post: - 26th September 2007, 06:41
  4. Crystalfontz LCD
    By jman12 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 9th February 2007, 16:04
  5. LCD Display not working - PIC heating...
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 24th September 2006, 08: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