concatenate multiple timers in succession

Watchkido1

Active Member
Licensed User
Longtime User
(Google translation from German)

Hello

Since yesterday I'm sitting here and Think.
How can i combine multiple timers ?

The problem:
I have the variables:
TimeToFight = 10000 '10 sec
Rounds = 3
Fighting Time = 120000 '2 minutes
Pause = 60000 '1 min

This sequence run like in a boxing match.
But at the BEGINNING of the fight time comes the command "Fight" at the END command "stop".
AND how can I give the timer 4 other times?
In the forum I could not find anything about chaining
Step7 with SPS this would be easy.
I take two flank markers and have each end and the beginning of the period.

Here I have only the end of time. Hmmm ... I stand in the dark.

Can someone please help me?

Thank you
frank
 
Last edited:

Watchkido1

Active Member
Licensed User
Longtime User
Bild

... Bild
 

Attachments

  • Boxingtimer.jpg
    Boxingtimer.jpg
    90.1 KB · Views: 260
Upvote 0

klaus

Expert
Licensed User
Longtime User
I'd suggest you to use 4 timers one for each time interval and 'play' with Timer.Enabled and variables to manage the rounds.
Timer1 launches Timer2
Timer2 launches Timer3
Timer3 launches Timer4
Timer4 launches Timer2
etc.
If last round Timer3 stops the cycle.

Best regards.
 
Upvote 0

Watchkido1

Active Member
Licensed User
Longtime User
Thanks

okay, thanks.
I thought I would have all this with 1 timer and make lots of loops.

Frank
 
Upvote 0

Watchkido1

Active Member
Licensed User
Longtime User
Jep, It´s Okay

:sign0060:


B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim Timer1, ShakeHands, Timedelay, KampfZeit, PausenZeit As Timer
   Dim LoadId0, PlayId0, LoadId2, PlayId2, LoadId3, PlayId3 As Int
   Dim LoadId4, PlayId4, LoadId5, PlayId5, LoadId1, PlayId1 As Int
   Dim LoadId7, PlayId7, LoadId8, PlayId8, LoadId6, PlayId6 As Int
   Dim SP As SoundPool
   
   
End Sub

Sub Globals
   Dim lblUeberschrift, lblCounter As Label
   Dim btnBeenden As Button
   Dim Zeit, Runden1, Counter, CounterSec, CounterMin As Int
   
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
   If FirstTime Then
      SP.Initialize(6)
      LoadId0 = SP.Load(File.DirAssets, "ShakeHands1.mp3")
      LoadId1 = SP.Load(File.DirAssets, "Fight1.mp3")
      LoadId2 = SP.Load(File.DirAssets, "Break1.mp3")
      LoadId3 = SP.Load(File.DirAssets, "Glocke1.wav")
      LoadId4 = SP.Load(File.DirAssets, "Glocke3.mp3")
      LoadId5 = SP.Load(File.DirAssets, "Glocke7.wav")
      LoadId6 = SP.Load(File.DirAssets, "Stop1.mp3")
   End If
   
   
   
   
   
   Activity.LoadLayout("Wettkampf") 

      If EinstellungenWettkampf.Timedelay < 5001 Then EinstellungenWettkampf.Timedelay = 6000
      Zeit =   EinstellungenWettkampf.Timedelay
      
      
      Runden1 = EinstellungenWettkampf.Runden

      Timer1.Initialize("Timer1", 1000 )' 1 sec
       Timedelay.Initialize("Timedelay", EinstellungenWettkampf.Timedelay - 5000 ) '5000 = die abgezogene Shakehandzeit
      KampfZeit.Initialize("Kampfzeit", EinstellungenWettkampf.Kampfzeit )
      PausenZeit.Initialize("Pausenzeit", EinstellungenWettkampf.Pause )
      ShakeHands.Initialize("ShakeHands", 5000)




End Sub


Sub Timer1_Tick


   If CounterSec = 59 Then
      'Timer1.Enabled= False
      CounterSec = -1
      CounterMin = CounterMin + 1
   End If 
       
       CounterSec = CounterSec + 1
      lblCounter.Text = CounterMin & ":"& CounterSec
 
 
 
End Sub




Sub Timedelay_Tick

   ToastMessageShow("TimeDelay",False)
   PlayId0 = SP.Play(LoadId0, 1, 1, 1, 0, 1) 'shake hands
   Timedelay.Enabled = False
   ShakeHands.Enabled =  True
   lblUeberschrift.Text = "Shake Hands"
End Sub

Sub ShakeHands_Tick

   ToastMessageShow("Shakehands" & Runden1,False)
   PlayId3 = SP.Play(LoadId3, 1, 1, 1, 0, 1) ' Glocke1
   PlayId1 = SP.Play(LoadId1, 1, 1, 1, 0, 1) ' fight
   
   ShakeHands.Enabled = False
   KampfZeit.Enabled = True
   
   CounterSec = 0
   CounterMin = 0
   lblUeberschrift.Text = "Noch " & Runden1 & " Runden"
End Sub


Sub Kampfzeit_Tick


   PlayId6 = SP.Play(LoadId6, 1, 1, 1, 0, 1) ' Stop
   PlayId4 = SP.Play(LoadId4, 1, 1, 1, 0, 1) ' Glocke3
   
   CounterSec = 0
   CounterMin = 0
   

   If Runden1 > 1 Then
      KampfZeit.Enabled = False
      PausenZeit.Enabled = True
      Runden1 = Runden1 -1
   Else
      PausenZeit.Enabled = False
      KampfZeit.Enabled = False
      PlayId5 = SP.Play(LoadId5, 1, 1, 1, 0, 1) ' Glocke7
      lblCounter.Text = "Kampfende"
      Timer1.Enabled = False
   End If
   
   lblUeberschrift.Text = "Pause " & Runden1
   

End Sub

Sub Pausenzeit_Tick



   PlayId3 = SP.Play(LoadId3, 1, 1, 1, 0, 1) ' Glocke1
   PlayId1 = SP.Play(LoadId1, 1, 1, 1, 0, 1) ' fight
   
   PausenZeit.Enabled = False
   KampfZeit.Enabled = True
   
   CounterSec = 0
   CounterMin = 0
   
   lblUeberschrift.Text = "Noch " & Runden1 & " Runden"

End Sub



Sub lblUeberschrift_Click
   
End Sub
Sub lblCounter_Click
   
      Timedelay.Enabled = True
      Timer1.Enabled = True

   
End Sub
Sub btnBeenden_Click
   Timer1.Enabled = False
   PausenZeit.Enabled = False
   KampfZeit.Enabled = False
   ShakeHands.Enabled = False
   Timedelay.Enabled = False
   Activity.Finish
End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
'   Timer1.Enabled = False
'   KampfZeit.Enabled = False
'   PausenZeit.Enabled = False
'   ShakeHands.Enabled = False
'   Timedelay.Enabled = False
   
   
End Sub




Sub btnNeustart_Click
   ToastMessageShow("NeuStarttaster",False)
   CounterSec = 0
   CounterMin = 0
   Timer1.Enabled = True
   
End Sub
 
Upvote 0
Top