Sub Globals
Private TimerBlink As Timer, StopButton As Button, LED_ON As Boolean
Private Hertz, RealTime, Interval, StartTime As Double
End Sub
Sub Activity_Create(FirstTime As Boolean)
Hertz=12
Interval=1000/Hertz
Dim TimerInterval As Int =Interval/10
If TimerInterval<1 Then
TimerInterval=1
End If
TimerBlink.Initialize("TimerBlink",TimerInterval)
StopButton.Initialize("Button")
StopButton.Text="Press to stop"
Activity.AddView(StopButton,0,0,100%x,20%y)
End Sub
Sub Activity_Resume
TimerBlink.Enabled=True
RealTime=DateTime.Now+1000
StartTime=RealTime
End Sub
Sub Button_Click
ExitApplication
End Sub
Private Sub TimerBlink_Tick
If DateTime.Now>RealTime Then
RealTime=RealTime+Interval/2
If LED_ON=True Then
LED_ON=False
DoSomeThing
Else
LED_ON=True
Log("Off")
End If
End If
End Sub
Sub DoSomeThing
Dim Showtime As Double= (RealTime-StartTime)/1000
Log($"On after $1.3{Showtime} sec Interval= $1.1{Interval} msec"$)
End Sub