Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim YOYO As IOIO
Dim astreams As AsyncStreams
End Sub
Sub Globals
Dim uart1 As Uart
Dim instrm As InputStream
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Main")
YOYO.Connect("yoyo",False,0,0)
YOYO.OpenUart("uart",11,uart1.IP_FLOATING,12,uart1.OP_NORMAL,4800,uart1.PARITY_NONE,uart1.STOPBIT_ONE)
End Sub
Sub yoyo_connected(noerror As Boolean)
'connected event, if noerror than connection made
If noerror Then
Log("yoyo Connected")
Log("yoyo Hardware: " & YOYO.GetIOIOVersion(YOYO.VER_HARDWARE))
Log("yoyo Bootloader: " & YOYO.GetIOIOVersion(YOYO.VER_BOOTLOADER))
Log("yoyo Firmware: " & YOYO.GetIOIOVersion(YOYO.VER_FIRMWARE))
Log("IOIO Library: " & YOYO.GetIOIOVersion(YOYO.VER_IOIOLIB))
Log("B4A Library: v"& YOYO.Version)
Else
Dim trouble As Exception
trouble=LastException
Log("yoyo "&trouble.Message) '&"yoyo State: "&yoyo.State&CRLF&CRLF)
End If
End Sub
Sub uart_open(noerror As Boolean, result As Object, input As Object, output As Object)
'get input and output stream as here well
If noerror Then
uart1=result
outstrm=output
instrm=input
Dim bufferout(5) As Byte
Dim bufferin(5) As Byte
'send bytes out on pin 11
bufferout(0)=0x00
bufferout(1)=0x01
bufferout(2)=0x02
bufferout(3)=0x03
bufferout(4)=0x04
outstrm.Flush
outstrm.WriteBytes(bufferout,0,5)
Log("RX on Pin 11 and TX on pin 12")
Log("00 01 02 03 04 sent on pin 12")
Log(instrm)
End If
End Sub