I am playing with the accelerometer event and I am trying to make sense of the 6 properties that are accessible:
xInstant, yInstant, zInstant & xGravity, yGravity, zGravity.
Could someone point me where there is any doc allowing to translate those metrics in angles and x/y/z translations ?
I am trying to capture acceloremeter events to see what it does, but I don’t get any value. Here is my code:
local updateScreen = function (event)
– Get x,y,z gravity and instant
local xG = event.xGravity
local yG = event.yGravity
local zG = event.zGravity
local xI = event.xInstant
local yI = event.yInstant
local zI = event.zInstant
local v_xG = string.format(’%.0f’, xG)
local v_yG = string.format(’%.0f’, yG)
local v_zG = string.format(’%.0f’, zG)
local v_xI = string.format(’%.0f’, xI)
local v_yI = string.format(’%.0f’, yI)
local v_zI = string.format(’%.0f’, zI)
The thing is when I run this app on device, tt always return 0, even if I directly use tt.text=string.format(’%d’,event.xGravity). So I don’t see any accelerometer response on device.
Finally I was trying to setup system.setAccelerometerInterval(50) and no matter what I put as value, like 10, .01 or 10Hz it always get an error, saying value must be a range between [10,100].
So if you already are getting some response of accelerometer on your test, could you point me where I wrong?
This code only works on shake, but it does output a value for event.yGravity if that is any help. I am also trying to figure out how to get this code to work without the need to shake the device, but at least it is a step in the right direction. By the way, changing the orientation and hitting shake will allow you to test in the simulator.
Thanks for your response. I will check that code today.
On the other hand, do you know what value is accepted in this call: system.setAccelerometerInterval( xxx ), because I tried to put 10, .1, 100 and no matters what I put, it always give me a warning message, saying parameter should be between the range of [10,100].