NXT / LEGO-MINDSTORMS-MINDdroid

LEGO MINDSTORMS Android Apps
http://mindstorms.com
157 stars 73 forks source link

X & Y coordinates are swapped #4

Open philipck opened 11 years ago

philipck commented 11 years ago

I noticed an issue when running this app on an Asus tablet that the x and y acceleration parameters were swapped.

Shouldn't rotations about the x-axis be reflected as deltas in the Y?

ghoelzl commented 11 years ago

Thanks for writing this comment. MINDdroid was optimized for mobile phones - not for tablets. The app works well on tablets with displays with "portrait" layout, e.g. the Nexus 7 or the first Galaxy Tab.

philipck commented 11 years ago

Hi, thanks for your response. Do you know how the code might be modified to detect portrait vs. landscape? I am learning android development, and would be happy to help make the code tablet-compatible if someone can steer me in the right direction. I got the code to work on my Asus tablet just by switching the x & y in the sensor event, but a more general solution would be great.

ghoelzl commented 11 years ago

The problem and its solution is excellently documented at http://developer.download.nvidia.com/tegra/docs/tegra_android_accelerometer_v5f.pdf. Basically you have to find out the rotation of the screen from its "natural" orientation with http://developer.android.com/reference/android/view/Display.html#getRotation().

philipck commented 11 years ago

Awesome, that's exactly what I was looking for. Thanks! I will try some experiments tonight.