Accelerometer?

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Gene
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 75
Joined: Wed Mar 09, 2011 6:48 pm
Location: Northern California

Accelerometer?

Post by Gene » Sun Feb 24, 2013 6:08 pm

Has anyone worked with the accelerometer feature of the Android yet? I have done some experimenting, and am uncertain about the results. What I am getting appears to be more along the lines of what I have seen described as the "Rotation Vector Sensor."

The rotation sensor isn't implemented in LiveCode, but it is described in this web page: http://developer.android.com/guide/topi ... tion-accel. Scroll down the page from the acceleration sensor to see a description of the rotation sensor. The page is for java programming, but has detailed reference information about the various native capabilities of Android, including all of the sensors that might be aboard any given device. Regardless of the question in this post, the site might be a valuable information site in the future.

Anyway, I built a simple utility to display the raw output of the x,y, and z parameters. These seem to be reacting solely to the devices orientation on three axis, rather than the motion, or acceleration along the axis. Maybe I'm misinterpreting what I am seeing, or misinterpreting what the accelerometer feature is supposed to do with respect to LiveCode. Any ideas :?:

Thanks - Gene

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Accelerometer?

Post by sturgis » Sun Feb 24, 2013 6:21 pm

If you set up a simple app with a field that lists, x, y,z accelerometer readings, and then rather than rotate, move the device up, down, right, left in a single plane, the accelerometers do register this.

In fact if you log things with accelerationchanged you can just track the highs and lows for each of x, y, and z. They do definitely work.

I have a small app that lets me roll a ball around based on the accelerometers (with some quicky inertia type coding involved) and can slide my kindle around flat on the desktop and get movement.

I'm not sure that all accelerometers are created equal though. There might be some variation based on the hardware.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Accelerometer?

Post by Simon » Sun Feb 24, 2013 11:57 pm

I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Gene
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 75
Joined: Wed Mar 09, 2011 6:48 pm
Location: Northern California

Re: Accelerometer?

Post by Gene » Mon Feb 25, 2013 5:33 am

Thanks for the replies folks. I'm not having much trouble with the code to get readings on the sensors - it's just that the output of the accelerometer on my device puzzles me.

As I said initially, the accelerometer readings appear to me to show the orientation of the device rather than the acceleration along any of the three axis. For example, when the phone is motionless and horizontal, the z parameter hovers around a reading of about "10." However, when I tilt it up so the top of the phone is vertical (pointing to the sky), the reading drops to about "1", and stays there. However, I don't get any additional reaction when I move the phone abruptly from a standing stop in any direction and hold the orientation constant.

There must be something I'm missing here. Or, maybe my Electrify M is different than normal for some reason (not likely, I think). Still, it returns "false" when I query it about the availability of "rotation rate", which is something else that is unexpected.

I'm going to write up an experiment along the line of what Sturgis described, where I can isolate the high and low readings and see how they change as I abruptly move the phone. At this point I don't have an important application for the accelerometer function, but curiosity drives me. It's hard walk away from the problem now.

By the way, the link to the lesson on sensors is a keeper.

Cheers - Gene

Post Reply

Return to “Android Deployment”