B4R Question Leonardo need some special?

BaGRoS

Active Member
Licensed User
Hi

Simple test program

B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public Serial1 As Serial
    Public lcd As LiquidCrystal_I2C
    Private Scroll0, Scroll1 As Timer
 
    Dim txtScroll0() As Byte = "                1234567890ABCDEF                "
    Dim txtScroll1() As Byte = "                ...::  Test scroll  ::...               "
    Dim curs0, curs1 As Int
 
    Dim btn0, btn1 As Pin
 
    Dim bc As ByteConverter
     
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
 
    Scroll0.Initialize("Scroll0_Tick",250)
    Scroll1.Initialize("Scroll1_Tick",250)
 
    btn0.Initialize(6, btn0.MODE_INPUT_PULLUP)
    btn0.AddListener("btn0_StateChanged")
 
    btn1.Initialize(7, btn1.MODE_INPUT_PULLUP)
    btn1.AddListener("btn1_StateChanged")


    lcd.Initialize(0x27,16,2)
    lcd.Clear
    lcd.Backlight = True
    lcd.SetCursor(0,0)
    lcd.Write("     ******     ")
 
 
 
End Sub

Sub Scroll0_Tick
 
    lcd.SetCursor(0,0)
    Dim len As Int = txtScroll0.Length
    'Log(len)
    Dim txt() As Byte
 
    txt = bc.SubString2(txtScroll0 , curs0 , curs0+16)
    lcd.Write(txt)
 
    curs0 = curs0 + 1
    If curs0+17 > len Then
        curs0 = 0
    End If
 
 
 
End Sub

Sub Scroll1_Tick
 
    lcd.SetCursor(0,1)
    Dim len As Int = txtScroll1.Length
    'Log(len)
    Dim txt() As Byte
 
    txt = bc.SubString2(txtScroll1 , curs1 , curs1+16)
    lcd.Write(txt)
 
    curs1 = curs1 + 1
    If curs1+17 > len Then
        curs1 = 0
    End If
 
 
 
End Sub

Sub btn0_StateChanged(State As Boolean)
    Delay(10)
 
    If State Then
        lcd.SetCursor(0,0)
        lcd.Write("     **  **     ")
    Else
        'Scroll0.Enabled = True
        lcd.SetCursor(0,0)
        lcd.Write("Button0 - OK")
    End If
 
End Sub

Sub btn1_StateChanged(State As Boolean)
    Delay(10)
 
    If State Then
        lcd.SetCursor(0,1)
        lcd.Write("Button1 - ***")
        Else
        'Scroll1.Enabled = True
        lcd.SetCursor(0,1)
        lcd.Write("Button1 - OK  ")
    End If
 
End Sub

Working only once after upload... Show movie:


not working after reset and power off/on?! Ideas?

EDIT:
This https://www.b4x.com/android/forum/t...ot-starting-up-as-expected.78622/#post-498211 ; and this:
B4X:
'Serial1.Initialize(115200)
help me...
 
Last edited:

Similar Threads

Top