I try to draw circles by timer when data receive from Serial. Numbers printed in Labels correctly, but circles not drawing. Please help...
There is code
#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: Serial Example
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#End Region
'Activity module
Sub Process_Globals
Dim Serial1 As Serial
Dim TextReader1 As TextReader
Dim TextWriter1 As TextWriter
Dim Timer1 As Timer
Dim connected As Boolean
Dim str0 As String
Dim str1 As String
Dim str2 As String
Dim str3 As String
Dim in0 As Long
Dim in1 As Long
Dim in2 As Long
Dim in3 As Long
Dim Value As String
Dim ix As Long
Dim ir As Long
Dim ig As Long
Dim ib As Long
Dim del1 As Int
End Sub
Sub Globals
Dim btnSend As Button
Dim txtLog As EditText
Dim txtSend As EditText
Private Button1 As Button
Private Label2 As Label
Private Label3 As Label
Private Label4 As Label
Private Label5 As Label
Private Label6 As Label
Private EditText1work As EditText
Private Button2work As Button
Private pnlGraph As Panel
Private cvsActivity, cvsGraph As Canvas
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Serial1.Initialize("Serial1")
Timer1.Initialize("Timer1", 100)
'Timer1.Enabled=True
End If
Activity.LoadLayout("1")
Activity.AddMenuItem("Connect", "mnuConnect")
Activity.AddMenuItem("Disconnect", "mnuDisconnect")
cvsGraph.Initialize(pnlGraph)
End Sub
Sub Activity_Resume
If Serial1.IsEnabled = False Then
Msgbox("Please enable Bluetooth.", "")
Else
Serial1.Listen 'listen for incoming connections
End If
End Sub
Sub mnuConnect_Click
Dim PairedDevices As Map
PairedDevices = Serial1.GetPairedDevices
Dim l As List
l.Initialize
For i = 0 To PairedDevices.Size - 1
l.Add(PairedDevices.GetKeyAt(i))
Next
Dim res As Int
res = InputList(l, "Choose device", -1) 'show list with paired devices
If res <> DialogResponse.CANCEL Then
Serial1.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address
End If
End Sub
Sub Serial1_Connected (Success As Boolean)
If Success Then
ToastMessageShow("Connected successfully", False)
TextReader1.Initialize(Serial1.InputStream)
TextWriter1.Initialize(Serial1.OutputStream)
Timer1.Enabled = True
connected = True
Else
connected = False
Timer1.Enabled = False
Msgbox(LastException.Message, "Error connecting.")
End If
End Sub
Sub mnuDisconnect_Click
Serial1.Disconnect
connected = False
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnSend_Click
If connected Then
TextWriter1.WriteLine(txtSend.Text)
TextWriter1.Flush
txtSend.Text = ""
'cvsGraph.DrawCircle(20dip,200dip,6dip,Colors.Red,True,1dip)
End If
End Sub
Sub Timer1_Tick
If connected Then
If TextReader1.Ready Then 'check if there is any data waiting to be read
Dim msg As String = TextReader1.ReadLine
Dim msg_trennen() As String = Regex.Split("/",msg)
Label2.Text=msg_trennen(0)
str0=msg_trennen(0)
in0=Label2.Text
Label3.Text=msg_trennen(1)
str1=msg_trennen(1)
del1=Label3.Text
in1 = del1/3
Label4.Text=msg_trennen(2)
str2=msg_trennen(2)
in2=Label4.Text
Label5.Text=msg_trennen(3)
str3=msg_trennen(3)
in3=Label5.Text
ix = ix + 1
Label6.Text=ix
cvsGraph.DrawCircle(ix,in1,3dip,Colors.Red,True,1dip)
cvsGraph.DrawCircle(20dip,200dip,6dip,Colors.Red,True,1dip)
'Log(msg_trennen(1))
'Log(msg_trennen(2))
txtLog.Text = txtLog.Text & TextReader1.ReadLine & CRLF
txtLog.SelectionStart = txtLog.Text.Length
End If
End If
End Sub
Sub Button1_Click
Dim PairedDevices As Map
PairedDevices = Serial1.GetPairedDevices
Dim l As List
l.Initialize
For i = 0 To PairedDevices.Size - 1
l.Add(PairedDevices.GetKeyAt(i))
Next
Dim res As Int
res = InputList(l, "Choose device", -1) 'show list with paired devices
If res <> DialogResponse.CANCEL Then
Serial1.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address
End If
End Sub
There is code
#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: Serial Example
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#End Region
'Activity module
Sub Process_Globals
Dim Serial1 As Serial
Dim TextReader1 As TextReader
Dim TextWriter1 As TextWriter
Dim Timer1 As Timer
Dim connected As Boolean
Dim str0 As String
Dim str1 As String
Dim str2 As String
Dim str3 As String
Dim in0 As Long
Dim in1 As Long
Dim in2 As Long
Dim in3 As Long
Dim Value As String
Dim ix As Long
Dim ir As Long
Dim ig As Long
Dim ib As Long
Dim del1 As Int
End Sub
Sub Globals
Dim btnSend As Button
Dim txtLog As EditText
Dim txtSend As EditText
Private Button1 As Button
Private Label2 As Label
Private Label3 As Label
Private Label4 As Label
Private Label5 As Label
Private Label6 As Label
Private EditText1work As EditText
Private Button2work As Button
Private pnlGraph As Panel
Private cvsActivity, cvsGraph As Canvas
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Serial1.Initialize("Serial1")
Timer1.Initialize("Timer1", 100)
'Timer1.Enabled=True
End If
Activity.LoadLayout("1")
Activity.AddMenuItem("Connect", "mnuConnect")
Activity.AddMenuItem("Disconnect", "mnuDisconnect")
cvsGraph.Initialize(pnlGraph)
End Sub
Sub Activity_Resume
If Serial1.IsEnabled = False Then
Msgbox("Please enable Bluetooth.", "")
Else
Serial1.Listen 'listen for incoming connections
End If
End Sub
Sub mnuConnect_Click
Dim PairedDevices As Map
PairedDevices = Serial1.GetPairedDevices
Dim l As List
l.Initialize
For i = 0 To PairedDevices.Size - 1
l.Add(PairedDevices.GetKeyAt(i))
Next
Dim res As Int
res = InputList(l, "Choose device", -1) 'show list with paired devices
If res <> DialogResponse.CANCEL Then
Serial1.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address
End If
End Sub
Sub Serial1_Connected (Success As Boolean)
If Success Then
ToastMessageShow("Connected successfully", False)
TextReader1.Initialize(Serial1.InputStream)
TextWriter1.Initialize(Serial1.OutputStream)
Timer1.Enabled = True
connected = True
Else
connected = False
Timer1.Enabled = False
Msgbox(LastException.Message, "Error connecting.")
End If
End Sub
Sub mnuDisconnect_Click
Serial1.Disconnect
connected = False
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnSend_Click
If connected Then
TextWriter1.WriteLine(txtSend.Text)
TextWriter1.Flush
txtSend.Text = ""
'cvsGraph.DrawCircle(20dip,200dip,6dip,Colors.Red,True,1dip)
End If
End Sub
Sub Timer1_Tick
If connected Then
If TextReader1.Ready Then 'check if there is any data waiting to be read
Dim msg As String = TextReader1.ReadLine
Dim msg_trennen() As String = Regex.Split("/",msg)
Label2.Text=msg_trennen(0)
str0=msg_trennen(0)
in0=Label2.Text
Label3.Text=msg_trennen(1)
str1=msg_trennen(1)
del1=Label3.Text
in1 = del1/3
Label4.Text=msg_trennen(2)
str2=msg_trennen(2)
in2=Label4.Text
Label5.Text=msg_trennen(3)
str3=msg_trennen(3)
in3=Label5.Text
ix = ix + 1
Label6.Text=ix
cvsGraph.DrawCircle(ix,in1,3dip,Colors.Red,True,1dip)
cvsGraph.DrawCircle(20dip,200dip,6dip,Colors.Red,True,1dip)
'Log(msg_trennen(1))
'Log(msg_trennen(2))
txtLog.Text = txtLog.Text & TextReader1.ReadLine & CRLF
txtLog.SelectionStart = txtLog.Text.Length
End If
End If
End Sub
Sub Button1_Click
Dim PairedDevices As Map
PairedDevices = Serial1.GetPairedDevices
Dim l As List
l.Initialize
For i = 0 To PairedDevices.Size - 1
l.Add(PairedDevices.GetKeyAt(i))
Next
Dim res As Int
res = InputList(l, "Choose device", -1) 'show list with paired devices
If res <> DialogResponse.CANCEL Then
Serial1.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address
End If
End Sub