Shake

bluedude

Well-Known Member
Licensed User
Longtime User
Shake logic

I know I can get to the sensor but does anyone have shake logic? How to detect a shake?

Cheers,
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Have a look at the attached example, it's an adaptation of the code from your link.

You should test it, I can't having no device.
Tested a similar code with B4PPC.

You should play with the ShakeThreshold variable to adapt the sensivitiy.
Using the variables JerkX, JerkY and JerkZ instead of Jerk you could have a test for each direction.

Hope this helps.

What do you want to do with the result ?

Best regards.
 

Attachments

  • Shake.zip
    5.8 KB · Views: 340
Last edited:
Upvote 0

Cor

Active Member
Licensed User
Longtime User
Hello,

change Accelorometer to Accelorometer1
Accelorometer.StartListening("Accelorometer1")

and
ShakeThreshold=150

and it works on real device

thanks


B4X:
Sub btnActivate_CheckedChange(Checked As Boolean)
   Activated=Checked
   If Activated=True Then
      Accelorometer.StartListening("Accelorometer1")
      LastUpdate=DateTime.Now
   Else
      Accelorometer.StopListening
   End If
End Sub
 
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
Thanks guys I will try it a.s.a.p. Working on a deals app. and I want to "shake to make". Basically a new deal when you shake.
 
Upvote 0

bluedude

Well-Known Member
Licensed User
Longtime User
Just tried the zip, it is very sensitive and even a slight move says "shake". Will pay around with a few parameters.

Thanks for the great effort!
 
Upvote 0
Top