Hello! I´m developing an app in Python for my n95 and I need to filter some data because the accelerometer gives so much noise, does anyone know a code to solve my problem? Thanks!
Hello! I´m developing an app in Python for my n95 and I need to filter some data because the accelerometer gives so much noise, does anyone know a code to solve my problem? Thanks!
Well, teorically, you need to get the current x value (or whatever axis you are using) and the last x value and subtract them
Then, compare with the value you want (e.g. 90). If the subtraction of the last and current value is bigger than the comparison value, trigger the action (in case of a shake)
Hope you understood,
Rafael.
Last edited by Rafael T.; 2009-01-18 at 23:19.
Much depends on the type of shake you want to employ.
I recommend logging the values of the axis to a file by modifying the sample axyz script provided with the extension. On the basis of the logged data manipulate the required values of the axis.
Otherwise, consider updating your firmware to the latest, to use the sensor module.
Best Regards,
Croozeus
Pankaj Nathani
www.croozeus.com
Yes, this would be an extended way for that, which is very cool
Anyway, here is a simple shake example I did using axyz module and it worked well in N95 8GB:
Code:import e32 import appuifw import axyz last_x = last_y = last_z = 0 def reduce_noise(x, y, z): global last_x global last_y global last_z cur_x, cur_y, cur_z = x - last_x, y - last_y, z - last_z last_x, last_y, last_z = x, y, z f = cur_x + cur_y + cur_z if f > 150: appuifw.note(u"Shake Detected!") axyz.connect(reduce_noise) app_lock = e32.Ao_lock() app_lock.wait()
Hope it helps,
Rafael.
Hi all,
Do you have any samples of shaking movement (left and right), i am trying to interpret the Next and Back of a music player that i am developing with accelerometers. Thanks,
Marcel
Thanks Rafael for your answer.
But i am facing the problem that when i tilt the phone to the left, since the callback sensor is called everytime, it checks the phone is in the left, and makes the music forward two times or more than one time. And it's not what i want. I want that after a tilt to left and back to the normal, this correspond to the event (Next()) of my application.
=)
i saw your code below, but i think it's only for shakes in general, not specific (for left or for right).
Thanks,
Marcel
This is really simple, but have to mention anyway: you have to remember, whether you have responded to the "left" event already or not. You still receive dozens (hundreds) of "left" events, but after the first event just happily ignore the rest. Wait until you get back to "normal" or "right", until you except any more lefts..
Like I said, so simple I was hesitating whether I even dare to mention it... but did, because I just gave up on listbox icons and moved to the next item on todo list: update Sensor Analyzer. Got to get into mood
Shaking head or was it nodding,
--jouni