Sub Process_Globals
Dim tw As TextWriter
Dim recording As Boolean
Type AxisData (flipCount As Int, lastPeak As Float,lastValue As Float, timeStamp As Long)
Dim AxisX As AxisData
Dim MagnitudeThreshold As Float
Dim TimeThreshold As Int
MagnitudeThreshold = 11
TimeThreshold = 1500 'milliseconds <<<<<<<<<<<<<<<<<<<<
Dim CallBackActivity As String
End Sub
B4X:
Sub Shaked
PlayRandom
End Sub
how can i wait for "n" seconds between a "shaked" event and another?
thanks
I think that you can set a timer running inside the Shaked sub. Then, when this sub is recalled, you can check whether this timer is running and exit. Set the timer to stop its action when 'n' seconds passed by checking the system time.
PS: I know nothing about this module, so forgive me if it already includes this type of things.
in log not appear "Shake.CalcAxis - still waiting"...
the shake event is released repeatedly and not every 1.5 sec...
i have in activity_create:
B4X:
sensor.Initialize(sensor.TYPE_ACCELEROMETER)
Shake.CallBackActivity = "BrowseAudioVideo" '<< form name
in chechbox to activate shaking:
B4X:
Sub ShakeCheckBox_CheckedChange(Checked As Boolean)
Activated=Checked
If Activated=True Then
sensor.StartListening("sensor")
Accelorometer.StartListening("Accelorometer")
LastUpdate=DateTime.Now
Else
Accelorometer.StopListening
sensor.StopListening
End If
End Sub
in shake event:
B4X:
Sub Shaked
Msgbox("SHAKED!!!!!","")
'---PlayRandom
End Sub
and then i have the code module "shake.bas" (as your example) with TimeThreshold = 1500 'milliseconds