http://mbed.org/teams/components/code/MotionSensor/#226520fc09bf