Accelerometer Calibration Issues

I am working with the accelerometer, and am having some issues. I already have a calibration function which allows the user to set their “zero point;” the point at which they may hold the device without moving the player object.

I am not sure how to ‘calibrate’ the accelerometer so that the player can experience the intended gaming experience when they use the iPad (etc) in various positions.

Once approaching 90 degrees, and going past it, the controls either become sluggish or inverted.

If the person is simply laying on their back, than a simple inversion of the control variables would suffice, but I am having trouble with the issue surrounding playing the game at and around a 90 degree angle. I.E., leaning back in a chair.

I am using the following code, which I got from this message board in an older post (and had been a great help until arriving at this issue).

[lua]–sets up accelerometer data collection and variables for movement
system.setAccelerometerInterval(50)
local motionx = 0
local motiony = 0
local pointSetVar = 0.65

local function onAccelerate( event )
motionx = 15 * (event.xGravity)
motiony = 30 * (event.yGravity + pointSetVar)
instantMotionY = -1 * (event.yGravity)
end
Runtime:addEventListener (“accelerometer”, onAccelerate)

local function setPoint( event )
pointSetVar = instantMotionY
end

local pointSet = display.newRect (704, 20, 40, 40)
pointSet:addEventListener (“tap”, setPoint)

–moves the player ship
local function moveShip (event)
ship.x = ship.x + motionx
ship.y = ship.y - motiony[/lua]

This is one of the last things keeping me from finishing up, so help will be greatly appreciated. [import]uid: 102017 topic_id: 18666 reply_id: 318666[/import]