Hello good day.
why is DrawLine not performed if I jump with the timer1 to zeichne ?
cvsGraph.DrawLine(300,300, 300+x,300+y, Colors.Red, 1)
the values x and y are correctly calculated.
thanks.
greeting
why is DrawLine not performed if I jump with the timer1 to zeichne ?
cvsGraph.DrawLine(300,300, 300+x,300+y, Colors.Red, 1)
the values x and y are correctly calculated.
thanks.
greeting
B4X:
#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: esp8266
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Dim Timer1 As Timer
End Sub
Sub Globals
Private hlinks As Button
Private links As Button
Private hrechts As Button
Private mitte As Button
Private rechts As Button
Private vor As Button
Private zurueck As Button
Private v0 As Button
Private v1 As Button
Private v2 As Button
Private ser0 As Button
Private ser1 As Button
Private sharp As Button
Private edit1 As EditText
Dim WebView1 As WebView
Dim WebViewExtras1 As WebViewExtras
Dim zs As String
Dim vz As Int
Dim vzz As Float
Dim hz As Int
Dim hzz As Float
Dim pi As Float
Dim x As Int
Dim y As Int
Private image1 As Panel
Private cvsGraph As Canvas
End Sub
Sub Activity_Create(FirstTime As Boolean)
Timer1.Initialize("Timer1", 400)
Activity.LoadLayout("esp8266")
edit1.text =""
WebView1.Initialize("WebView1")
WebViewExtras1.addJavascriptInterface(WebView1, "B4A")
cvsGraph.Initialize(image1)
End Sub
Sub Activity_Resume
Timer1.Enabled = True
pi=3.14159
hzz=180
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Timer1.Enabled = False
End Sub
Sub Exit_App
Activity.Finish
ExitApplication
End Sub
Sub WebView1_PageFinished (Url As String)
Dim Javascript As String
Javascript = "B4A.CallSub('ProcessHTML', false, document.documentElement.innerText)"
' Javascript = "B4A.CallSub('ProcessHTML', false, document.documentElement.outerText)"
' Javascript = "B4A.CallSub('ProcessHTML', false, document.documentElement.innerHTML)"
' Javascript = "B4A.CallSub('ProcessHTML', false, document.documentElement.outerHTML)"
' Log("PageFinished: " & Javascript)
WebViewExtras1.executeJavascript(WebView1, Javascript)
End Sub
Sub ProcessHTML(Html As String)
' Log(Html)
zs = Html
End Sub
Sub Timer1_Tick
WebView1.LoadUrl("http://192.168.2.106/leer")
edit1.Text=zs
zeichne
End Sub
Sub rechts_Click
WebView1.LoadUrl("http://192.168.2.106/rechts")
End Sub
Sub hrechts_Click
WebView1.LoadUrl("http://192.168.2.106/hrechts")
End Sub
Sub mitte_Click
WebView1.LoadUrl("http://192.168.2.106/mitte")
End Sub
Sub hlinks_Click
WebView1.LoadUrl("http://192.168.2.106/hlinks")
End Sub
Sub links_Click
WebView1.LoadUrl("http://192.168.2.106/links")
End Sub
Sub v0_Click
WebView1.LoadUrl("http://192.168.2.106/v0")
End Sub
Sub v1_Click
WebView1.LoadUrl("http://192.168.2.106/v1")
End Sub
Sub v2_Click
WebView1.LoadUrl("http://192.168.2.106/v2")
End Sub
Sub zurueck_Click
WebView1.LoadUrl("http://192.168.2.106/zur")
End Sub
Sub vor_Click
WebView1.LoadUrl("http://192.168.2.106/vor")
End Sub
Sub ser0_Click
WebView1.LoadUrl("http://192.168.2.106/ser0")
End Sub
Sub ser1_Click
WebView1.LoadUrl("http://192.168.2.106/ser1")
vz=1
End Sub
Sub sharp_Click
WebView1.LoadUrl("http://192.168.2.106/sharp")
hz=1
End Sub
Sub zeichne()
If vz=1 Then
If vzz < 80 Then
vzz=vzz+1.8
x=Sin(vzz*pi/180)*100
y=Cos(vzz*pi/180)*100
cvsGraph.DrawLine(300,300, 300+x,300+y, Colors.Red, 1)
Else
vz=0
vzz=0
End If
End If
If hz=1 Then
If hzz < 360 Then
hzz=hzz+1.8
x=Sin(vzz*pi/180)*100
y=Cos(vzz*pi/180)*100
cvsGraph.DrawLine(300,300, 300+x,300+y, Colors.Red, 1)
Else
hz=0
hzz=180
End If
End If
End Sub
Sub Delay(nMilliSecond As Long)
Dim nBeginTime As Long
Dim nEndTime As Long
nEndTime = DateTime.Now + nMilliSecond
nBeginTime = DateTime.Now
Do While nBeginTime < nEndTime
nBeginTime = DateTime.Now
Log(nBeginTime)
If nEndTime < nBeginTime Then
Return
End If
DoEvents
Loop
End Sub