stefanoa Active Member Licensed User Longtime User Jul 30, 2012 #1 i'm trying to use shake event in my app with code from your example http://www.b4x.com/forum/basic4android-getting-started-tutorials/9857-android-shake-event-phonesensors.html#post54631 but the event "Shaked" is released too speed and not wait for 1.5 seconds configured in TimeThreshold on shake module: Code: Copy 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 Code: Copy Sub Shaked PlayRandom End Sub how can i wait for "n" seconds between a "shaked" event and another? thanks Last edited: Jul 30, 2012
i'm trying to use shake event in my app with code from your example http://www.b4x.com/forum/basic4android-getting-started-tutorials/9857-android-shake-event-phonesensors.html#post54631 but the event "Shaked" is released too speed and not wait for 1.5 seconds configured in TimeThreshold on shake module: Code: Copy 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 Code: Copy Sub Shaked PlayRandom End Sub how can i wait for "n" seconds between a "shaked" event and another? thanks
mc73 Well-Known Member Licensed User Longtime User Jul 30, 2012 #2 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. Upvote 0
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.
stefanoa Active Member Licensed User Longtime User Jul 30, 2012 #3 ok.. i try.. although, it should work the parameter TimeThreshold for this purpose... thanks for now.. Upvote 0
ok.. i try.. although, it should work the parameter TimeThreshold for this purpose... thanks for now..
Erel B4X founder Staff member Licensed User Longtime User Jul 31, 2012 #4 It should wait for 1.5 seconds. Do you see these messages in the logs: "Shake.CalcAxis - still waiting" Upvote 0
It should wait for 1.5 seconds. Do you see these messages in the logs: "Shake.CalcAxis - still waiting"
stefanoa Active Member Licensed User Longtime User Jul 31, 2012 #5 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: Code: Copy sensor.Initialize(sensor.TYPE_ACCELEROMETER) Shake.CallBackActivity = "BrowseAudioVideo" '<< form name in chechbox to activate shaking: Code: Copy 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: Code: Copy Sub Shaked Msgbox("SHAKED!!!!!","") '---PlayRandom End Sub and then i have the code module "shake.bas" (as your example) with TimeThreshold = 1500 'milliseconds Last edited: Jul 31, 2012 Upvote 0
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: Code: Copy sensor.Initialize(sensor.TYPE_ACCELEROMETER) Shake.CallBackActivity = "BrowseAudioVideo" '<< form name in chechbox to activate shaking: Code: Copy 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: Code: Copy Sub Shaked Msgbox("SHAKED!!!!!","") '---PlayRandom End Sub and then i have the code module "shake.bas" (as your example) with TimeThreshold = 1500 'milliseconds
Erel B4X founder Staff member Licensed User Longtime User Aug 1, 2012 #6 Are you releasing the msgbox in less than 1.5 seconds? Upvote 0
stefanoa Active Member Licensed User Longtime User Aug 1, 2012 #7 yes! also if i remove msgbox and put: Code: Copy Sub ShakeEvent Activity.Color = Colors.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255)) sounds.Play(bounceId, 1, 1, 1, 0, 1) End Sub is too speed and not wait for 1.5 seconds.. Upvote 0
yes! also if i remove msgbox and put: Code: Copy Sub ShakeEvent Activity.Color = Colors.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255)) sounds.Play(bounceId, 1, 1, 1, 0, 1) End Sub is too speed and not wait for 1.5 seconds..
mc73 Well-Known Member Licensed User Longtime User Aug 1, 2012 #8 Tried my suggestion, by the way? Just curious... Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Aug 1, 2012 #9 Can you upload your project? Upvote 0