View Single Post
Posts: 915 | Thanked: 3,209 times | Joined on Jan 2011 @ Germany
#72
I think this change to share/tilt_maemo.c might add initial calibration of the accelerometer:
Code:
<.../neverball-1.5.5/share>:diff a b
39c39
<     int i, ax, ay, az;
---
>     int i, ax, ay, az, ax0, ay0, az0;
53,55c53,55
<         accel.x = ax * 0.2f + accel.x * 0.8f;
<         accel.y = ay * 0.2f + accel.y * 0.8f;
<         accel.z = az * 0.2f + accel.z * 0.8f;
---
>         accel.x = ax * 0.2f + accel.x * 0.8f + ax0;
>         accel.y = ay * 0.2f + accel.y * 0.8f + ay0;
>         accel.z = az * 0.2f + accel.z * 0.8f + az0;
59,61c59,65
<         accel.x = ax;
<         accel.y = ay;
<         accel.z = az;
---
>         ax0 = -ax;
>         ay0 = -ay;
>         az0 = -az;	
> 
>         accel.x = ax + ax0;
>         accel.y = ay + ay0;
>         accel.z = az + az0;
However, it's completely untested and really just a wild guess.

Edit:
Not sure under which circumstances tilt_stat will be called, so if the above doesn't work try this instead:
Code:
<.../neverball-1.5.5/share>:diff a b
25a26,28
>     int   x0;
>     int   y0;
>     int   z0;
53,55c56,58
<         accel.x = ax * 0.2f + accel.x * 0.8f;
<         accel.y = ay * 0.2f + accel.y * 0.8f;
<         accel.z = az * 0.2f + accel.z * 0.8f;
---
>         accel.x = ax * 0.2f + accel.x * 0.8f + accel.x0;
>         accel.y = ay * 0.2f + accel.y * 0.8f + accel.y0;
>         accel.z = az * 0.2f + accel.z * 0.8f + accel.z0;
59,61c62,68
<         accel.x = ax;
<         accel.y = ay;
<         accel.z = az;
---
>         accel.x0 = -ax;
>         accel.y0 = -ay;
>         accel.z0 = -az;	
> 
>         accel.x = ax + accel.x0;
>         accel.y = ay + accel.y0;
>         accel.z = az + accel.z0;

Last edited by sulu; 2011-12-06 at 12:37.
 

The Following User Says Thank You to sulu For This Useful Post: