B4R Library rLcdBarGraph - draw a bar graph on your LCD display (LCD 1602)

Discussion in 'B4R Libraries' started by Johan Schoeman, Jun 8, 2019.

  1. Johan Schoeman

    Johan Schoeman Expert Licensed User

    A wrap for this Github project. Attached a B4R sample project and the library. Extract the library from rLcdBarGraph.zip and copy the folder and its contents to your B4R additional libs folder. Copy the xml to the root of your B4R additional libs folder.

    Sure you will figure out numcolumns, startX, and startY (there is pop up help in the library)

    Wiring diagram:
    lcdbargraph_bb.png

    What it looks like (in the attached example I am starting the bar graph in row 1, column 8 and are using 8 columns (numcolumns) for the bar graph)
    20190608_124313.jpg


    Sample Code:
    Code:
    #Region Project Attributes
        
    #AutoFlushLogs: True
        
    #CheckArrayBounds: True
        
    #StackBufferSize: 300
    #End Region


    Sub Process_Globals
        
    Public Serial1 As Serial
        
    Private lcd As LiquidCrystal        'create instance of rLiquidCrystal library
        Private lcdbg As LcdBarGraph        'create instance of rLcdBarGraph library
        
        
    Dim numcolumns As Byte = 8          'number of columns to use for displaying the bar graph
        Dim startX As Byte = 8              'start displaying the bar graph at Column 8 (first column is column 0) of LCD1602
        Dim startY As Byte = 1              'start displaying the bar graph on the second row (first row is 0) of LCD1602
        
        
    Dim t As Timer
        
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        t.Initialize(
    "t_tick"1000)
        
        
    ' Init the LCD: RS,RW,EN,Data(4)
        lcd.Initialize(8,255,9Array As Byte(4,5,6,7))
        lcd.Begin(
    16,2)
        lcd.DisplayOn = 
    True
        
    ' Init the bignum with lcd display
        lcd.Clear
        
    'initialize LcdBarGraph with the number of columns to use, the column start position (0 to 16 for LCD1602), and the row start position (0 or 1 for LCD1602)
        lcdbg.Initialize(lcd, numcolumns, startX, startY)
        t.Enabled = 
    True
        
    End Sub

    Sub t_tick
        lcd.SetCursor(
    00)
        lcd.Write(
    "Value = ")
        
    Dim mynum As Int = Rnd(0101)
        lcd.SetCursor(
    80)
        lcd.Write(
    " ")
        lcd.Write(
    " ")
        lcd.Write(
    " ")
        lcd.SetCursor(
    80)
        lcd.Write(mynum)
        lcdbg.drawValue(mynum, 
    100)
        
    End Sub
     

    Attached Files:

    embedded, Erel and janderkan like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice