Here's my really poor attempt at some sensor-fusion control. It doesn't do what I intended (yet), but it does show you how to monitor sensors and use the data to display an oscilloscope. All you would need to do to create a pedometer is analyse the graph data for peak changes that would signify a bounce, or step. You could set a predetermined sensitivity, or you could get creative and make the sensitivity dynamic, adjusting automatically to the level of motion being experienced.
If I remember correctly, the Android NDK does have some built in step sensing functions, but they are not (yet) exposed in AGK.
Anyway, here's the code - it's ugly and doesn't do what it was intended to do, but should give you an idea on how to move forward with your own code.
SetWindowTitle( "sensorfusion" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 0, 0, 1, 0 )
TIME_CONSTANT = 30
FILTER_COEFFICIENT = 0.99
oneMinusCoeff# = 1.0 - FILTER_COEFFICIENT
dim scopex[50]
dim scopey[50]
dim scopez[50]
dot = CreateImageColor(255,255,255,255)
for t = 1 to 50
CreateSprite(t,dot)
setspritesize(t,8,8)
CreateSprite(t+100,dot)
setspritesize(t+100,8,8)
CreateSprite(t+200,dot)
setspritesize(t+200,8,8)
next t
do
gft# = GetFrameTime()
GyroOrientationX# = GyroOrientationX# + (GetRawGyroVelocityX() * gft# )
GyroOrientationY# = GyroOrientationY# + (GetRawGyroVelocityy() * gft# )
GyroOrientationZ# = GyroOrientationZ# + (GetRawGyroVelocityz() * gft# )
sttot# = sin(gft#)
cttot# = cos(gft#)
GyroOrientationYu# = sttot# * GyroOrientationY#
GyroOrientationXu# = sttot# * GyroOrientationX#
GyroOrientationZu# = sttot# * GyroOrientationZ#
fusedOrientationY# = (FILTER_COEFFICIENT * GyroOrientationYu# + oneMinusCoeff# * GetRawRotationVectorY() )
fusedOrientationX# = (FILTER_COEFFICIENT * GyroOrientationXu# + oneMinusCoeff# * GetRawRotationVectorX() )
fusedOrientationZ# = (FILTER_COEFFICIENT * GyroOrientationZu# + oneMinusCoeff# * GetRawRotationVectorZ() )
` Reset Gyro Drift by assigning the corrected sensor-fused value to the gyroOrientation
GyroOrientationX# = GetRawRotationVectorX()
GyroOrientationy# = GetRawRotationVectorY()
GyroOrientationz# = GetRawRotationVectorZ()
print(fusedOrientationY# * 10000.0)
print(fusedOrientationX# * 10000.0)
print(fusedOrientationZ# * 10000.0)
scopex[50] = fusedOrientationX# * 200000.0
scopey[50] = fusedOrientationY# * 200000.0
scopez[50] = fusedOrientationZ# * 200000.0
for t = 1 to 49
scopex[t] = scopex[t+1]
scopey[t] = scopey[t+1]
scopez[t] = scopez[t+1]
setspriteposition(t,300+(t*5),250+(scopex[t]*5))
setspriteposition(t+100,300+(t*5),550+(scopey[t]*5))
setspriteposition(t+200,600+(t*5),250+(scopez[t]*5))
next t
Print( ScreenFPS() )
Sync()
loop
exit