Gestures with the WP7 Accelerometer

22 11 2010

First and foremost, if you want in depth information about the accelerometer you should check out Dave Edson’s excellent blog post, Using the Accelerometer on Windows Phone 7.  While his post is extremely informative, it was a bit of overkill for what I needed.  I assume this may be true for a lot of you as well.

I just needed to recognize a simple gesture I wanted to see what it “looked” like to the accelerometer.  I didn’t smooth out the curve or use the AccelerometerHelper class.  Here are the steps I followed to determine that the raw data appeared to be sufficient for my needs:

  1. Start the accelerometer and record the data
  2. Perform the gesture
  3. Stop the accelerometer
  4. Use Excel to analyze the data
  5. Write the gesture detection code
  6. Test, Test, Test

I wrote a quick and dirty program (included below) to capture the data and send me an email.  The email is plain text that I save into notepad then import into Excel as a delimited text file.

These are the x-axis readings for one trial for me flicking the phone with my right hand:

image

There are two key points on this chart: When the x value hits about 1.3G, and when it hits about –2G.  My gesture detection code looks for these values, in this order, in a small time frame (about 1 second).

Tips

  • Perform several trials before you start coding your gesture recognition.  If possible, use different people.  What worked 10 out of 10 times for me worked 3 out of 10 times for someone else.
  • Left and Right handed gestures can be drastically different.
  • Be cognizant of how long the gesture should take and code your recognition accordingly.
  • Relax your gesture parameters as much as possible, but be wary of false positives.  In order to prevent stacking gestures, I put in a pause of about 250 ms between gestures.
  • Give some sort of feedback when they successfully perform a gesture.  A vibration lasting about 200 ms seemed to work well for my scenario.

Download Accelerometer Test Solution Here





Boozazzl 1.3 Released

18 11 2010

screenshot_07_funfactAn updated version of the best blood alcohol estimator is now live on the marketplace!  Boozazzl’s exciting new features include:

  • Track your friends easily with multiple Boozazzl profiles
  • Fun facts and quotes with every drink
  • Additional drink menu items like “chug” and “finish”
  • More intuitive time to peak and time to limit displays
  • A variety of performance enhancements make the experience even more fluid and enjoyable

More great features are coming soon.  Keep up to date by following @azzlsoft on Twitter or Azzl on Facebook.