#Region Project Attributes
#ApplicationLabel: 2 Timers
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim stdTimer1, stdTimer2 As Int ' values in seconds
Dim tmr1, tmr2 As Timer ' My 2 timers
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private ButtonTimer1,ButtonTimer2 As Button ' buttons to start and stop timers
Private EditTextTimer1, EditTextTimer2 As EditText ' TxtBox to display time
Dim Timer1Min, Timer1Sec, Timer1TotalSec As Int ' values in Minutes, seconds, TotalSeconds before the end
Dim Timer2Min, Timer2Sec, Timer2TotalSec As Int ' values in Minutes, seconds, TotalSeconds before the end
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("LayoutTimer")
stdTimer1= 10 * 60 ' 10 minutes
stdTimer2= 45 * 60 ' 45 minutes
EditTextTimer1.Text=Sec2Chrono (stdTimer1) ' format time for timer1
EditTextTimer2.Text=Sec2Chrono (stdTimer2) ' format time for timer1
Timer1TotalSec=stdTimer1 ' prepare countdown
Timer2TotalSec=stdTimer2 ' prepare countdown
tmr1.Initialize ("Timer1Loop", 1000) ' change value every 1sec
tmr2.Initialize ("Timer2Loop", 1000) ' change value every 1sec
End Sub
Sub Timer1Loop_Tick
' timer tick
Timer1TotalSec = Timer1TotalSec-1 ' -1 sec
If Timer1TotalSec=0 Then ' the end
tmr1.Enabled=False ' timer stopped
ButtonTimer1_Click ' simulate Button1 clic to reset Timer
Dim b As Beeper
b.Initialize( 1300, 500)
b.Beep ' beep
End If
Timer1_ChangeText ' REFRESH countdown
End Sub