#Region Project Attributes
#MainFormWidth: 800
#MainFormHeight: 600
#MergeLibraries: true
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private btnClearList As B4XView
Private tarProtocol As B4XView
Private Spi As Int
Private rwSpi As Int
Private timLoop As Timer
Dim tempBytes As ByteConverter
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("frmMain") 'Load the layout file.
MainForm.Show
addText("Programm started")
timLoop.Initialize("timLoop",1000)
timLoop.Enabled = True
Spi = WiringPiSPISetup(0,32000000)
addText("WiringPiSPISetup:" & Spi)
End Sub
Sub timLoop_Tick
Dim strData As String = "0"
Dim Data() As Byte = tempBytes.StringToBytes(strData,"UTF8")
rwSpi = WiringPiSPIDataRW(0,Data,strData.Length)
addText("WiringPiSPIDataRW:" & rwSpi)
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub btnClearList_Click
tarProtocol.Text = ""
End Sub
Sub addText(Text As String)
tarProtocol.Text = tarProtocol.Text & Text & CRLF
End Sub
Sub WiringPiSPISetup(Channel As Int, Speed As Int) As Int
Dim jo As JavaObject
Return jo.InitializeStatic("com.pi4j.wiringpi.Spi").RunMethod("wiringPiSPISetup", Array As Object(Channel, Speed))
End Sub
Sub WiringPiSPIDataRW(Channel As Int, Data() As Byte, Len As Int) As Int
Dim jo As JavaObject
Return jo.InitializeStatic("com.pi4j.wiringpi.Spi").RunMethod("wiringPiSPIDataRW", Array As Object(Channel, Data, Len))
End Sub