Posted By

parkerkrhoyt on 11/04/11


Tagged

javascript phone standards mobile web Sensor device tilt accelerometer phonegap gap


Versions (?)

Using the Accelerometer with PhoneGap


 / Published in: JavaScript
 

  1. var latest = null;
  2.  
  3. function doDeviceReady()
  4. {
  5. var options = {
  6. frequency: FREQUENCY_ACCEL
  7. };
  8.  
  9. watchID = navigator.accelerometer.watchAcceleration(
  10. doAcceleration,
  11. doError,
  12. options
  13. );
  14. }
  15.  
  16. function doAcceleration( acceleration )
  17. {
  18. latest = {
  19. x: acceleration.x,
  20. y: acceleration.y
  21. };
  22. }
  23.  
  24. function doError()
  25. {
  26. alert( 'Acceleration Error' );
  27. }

Report this snippet  

You need to login to post a comment.