B4R Question LCD display utils ?

peacemaker

Expert
Licensed User
Longtime User
HI, All

Maybe is there any ready shared B4R subs set for printing on LCD displays with formatting strings?
I mean "automated" printing:
  • in the center,
  • long text with multiline carriage return,
  • ticker (scrolling line) ...

I'm trying to use LCD:
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Private lcd As LiquidCrystal_I2C
    Private i2c_address As Byte = 0x27 'PCF8574 Texas Instruments, without any jumper over A0, A1, A2 bits (PCF8574 chip from NXP semiconductors, its default I2C address is 0x3F)
    Private const Columns As Byte = 20
    Private const Rows As Byte = 4
'    Dim CharMap() As Byte = Array As Byte (0x00,0x1B,0x1B,0x00,0x11,0x1F,0x0E,0x00)
End Sub

Private Sub Setup
    lcd.Initialize(i2c_address, Columns, Rows)
    lcd.Clear
    lcd.Backlight = True
End Sub

Public Sub Print
    Log("Printing...")
    Setup
    lcd.SetCursor(0,0)
'    lcd.CreateChar (0, CharMap)
'    lcd.Write (Array As Byte(0))
    Dim line1 As String = JoinStrings(Array As String ("Test result = ", " 0.0 %"))
    lcd.Write(line1)
End Sub

Public Sub Test
    Setup
    For i = 0 To Rows - 1
        For j = 0 To Columns - 1
            lcd.SetCursor(j, i)
            lcd.Write(i)
        Next
    Next
    Delay(500)
    lcd.Clear
    Print_Center(1, "http://web.site")
End Sub

'printing at the line centered
Private Sub Print_Center(Top As UInt, s As String)
    Dim Length As UInt = s.Length
    Dim Left As UInt
    If Length <= Columns Then
        Left = (Columns - Length) / 2
    Else
        Left = 0
    End If
    lcd.SetCursor(Left, 2)
    lcd.Write(s)
End Sub

But maybe any ready subs ?
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…