LCD BARgraphs


Closed Thread
Results 1 to 40 of 233

Thread: LCD BARgraphs

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Hi vbcoder,

    You're welcome.

    There are 3 bars per character, so you can get 48 per line on a 2x16.
    <br>
    DT

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Question aren't characters in a 5x7 Matrix arranged ???

    Quote Originally Posted by Darrel Taylor View Post
    Hi vbcoder,

    You're welcome.

    There are 3 bars per character, so you can get 48 per line on a 2x16.
    <br>

    Hi, Darrel

    I know it's YOUR Bargraph example ... but 5 bars can be used with "general programming" ...

    May be a Typo from yours ???



    Translated and modified from a Stamp application :

    ' This program generates a horizontal bargraph
    ' with a 2x16 Intelligent LCD Display HD 44780 / KS 0062.

    DEFINE OSC 20
    DEFINE LCD_EBIT 1

    Led var Portb.5
    Scale var Portb.2

    ' ** Variables **

    BarVal Var Word ' Value to be graphed.
    Bars Var Byte ' Number of full |||/||||| bars to draw.
    Balance Var Byte ' Balance left after all |||/|||||s are drawn.
    Padding Var Byte ' Number of spaces to fill width.
    Balf Var Byte ' Is a 'Balance' character needed? (1=yes, 0=no).
    Temp Var Byte
    Fullbar Var Byte
    Maxbar Var Byte


    ' ** Constants **

    BWdth Con 16
    Basebar Con 0 ' ASCII value of 0 bar (blank).





    IF NOT Scale THEN

    Fullbar = 3
    ELSE
    Fullbar = 5

    ENDIF

    Maxbar = BWdth*Fullbar ' Max bar counts.



    ' Transfer the bit patterns that make up the bars into the LCD's CGRAM.
    ' The vertical bars are made up of 8 identical bit patterns

    ' A | bar consists of 0, 5 times $10, 0
    ' A || bar consists of 0, 5 times $14, 0
    ' A ||| bar consists of 0, 5 times $15, 0

    ' We repeat each pattern 8 times.

    IF Fullbar = 3 THEN

    Lcdout $FE,64,0,0,0,0,0,0,0,0 'Motif 0
    Lcdout $0,$10,$10,$10,$10,$10,$10,$0 'Motif 1
    Lcdout $0,$14,$14,$14,$14,$14,$14,$0 'Motif 2
    Lcdout $0,$15,$15,$15,$15,$15,$15,$0 'Motif 3


    ELSE


    Lcdout $FE,64,0,0,0,0,0,0,0,0 'Motif 0
    Lcdout $0,$10,$10,$10,$10,$10,$10,$0 'Motif 1
    Lcdout $0,$18,$18,$18,$18,$18,$18,$0 'Motif 2
    Lcdout $0,$1C,$1C,$1C,$1C,$1C,$1C,$0 'Motif 3
    Lcdout $0,$1E,$1E,$1E,$1E,$1E,$1E,$0 'Motif 4
    Lcdout $0,$1F,$1F,$1F,$1F,$1F,$1F,$0 'Motif 5

    ENDIF

    Goto OverBargraph


    ' The value in 'Bar_Val' is displayed as a horizontal bar graph
    ' from the current cursor location with a total width (in characters) set by the WIDTH constant.
    ' Each character position can represent a maximum value of 3/5 using the Fullbar character |||.
    ' The routine calculates how many full bars to use by dividing by 3/5.
    ' If there is a remainder after dividing by 3/5, the routine joins on a partial-bar character
    ' ( | or || or ||| or |||| or ||||| ) to represent the balance.
    ' Then it pads out the remainder of the bar width with spaces to erase any leftover bars



    Bargraph:

    Bars = (BarVal min MaxBar) / Fullbar ' One full bar for each 3/5 graph units.
    Balance = (BarVal min Maxbar) //Fullbar ' Balance is the remainder after a division by 3/5.
    Balf = Balance min 1
    Padding = BWdth - (Bars + Balf) ' Number of spaces to fill bar width.

    LCDOut Rep Fullbar\Bars,Rep (Balance + Basebar)\Balf,Rep " " \Padding

    Return

    OverBargraph:

    For BarVal = 0 to Maxbar

    Lcdout $FE,$80
    Gosub Bargraph
    Lcdout $FE, $C0, #BarVal," "
    Pause 300

    Next BarVal



    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 19:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

Members who have read this thread : 2

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