Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
Posts: 7
Registered: ‎10-21-2013
My Device: Z10
My Carrier: N/A
Accepted Solution

Accelerometer miscalibration

I am having a problem where my accelerometer remains calibrated to the standard navigator angle until I flip the device (& therefore my application) at least once, after that returning to my original orientation works correctly.

 

This is how I am initialising the system

 

	orientation_direction_t tDirection;
	int iAngle;
	orientation_get(&tDirection, &iAngle);
	sensor_remap_coordinates(iAngle);

 And then on a reorient I am doing the following within a BPS event loop

case NAVIGATOR_ORIENTATION_CHECK:
{
    int iAngle = navigator_event_get_orientation_angle(pEvent);
    sensor_remap_coordinates(iAngle);
    //Signal navigator that we intend to resize
    navigator_orientation_check_response(pEvent, true);
}
break;
case NAVIGATOR_ORIENTATION:
{
    int iAngle = navigator_event_get_orientation_angle(pEvent);
    sensor_remap_coordinates(iAngle);
    if (m_bPresentNeeded)
    {
        DoPresent();
    }
    GraphicsRotateScreen(iAngle);
    navigator_done_orientation(pEvent);
}
break;

 

If Anyone could help me with this I would very much appreciate it

New Contributor
Posts: 7
Registered: ‎10-21-2013
My Device: Z10
My Carrier: N/A

Re: Accelerometer miscalibration

Ok, so incase anyone else experiences this issue I will post my solution here.

 

If the device and your app is forced to landscape orientation this wil cause the accelerometer to be calibrated incorrectly.

 

To fix this I used the following workaround in my app initialisation

orientation_direction_t tDirection;
int iAngle;
orientation_get(&tDirection, &iAngle);

// This is here to force alignment to the left if the device is held 
// vertically upon startup, this prevents the misalignment bug
if(iAngle % 180 == 0)
    iAngle = 90;

sensor_remap_coordinates(iAngle);

 Hope this helps anyone else with this issue

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Accelerometer miscalibration

Have you tested this on different OS versions?

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
New Contributor
Posts: 7
Registered: ‎10-21-2013
My Device: Z10
My Carrier: N/A

Re: Accelerometer miscalibration

Yes, 10.0.9/10.1/10.2