Presentation is loading. Please wait.

Presentation is loading. Please wait.

Touchdevelop api api acceleromete r measure acceleration Disclaimer: This document is provided as-is. Information and views expressed in this document,

Similar presentations


Presentation on theme: "Touchdevelop api api acceleromete r measure acceleration Disclaimer: This document is provided as-is. Information and views expressed in this document,"— Presentation transcript:

1 touchdevelop api api acceleromete r measure acceleration Disclaimer: This document is provided as-is. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it. This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes. © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and Windows Live are trademarks of the Microsoft group of companies. All other trademarks are property of their respective owners.

2 touchdevelop api accelerometer o electronic component that measures tilt and motion angle device is being held at movements such as rotation motion gestures such as swinging, shaking, and flicking o detect whether the phone is held in portrait or landscape mode o control games and other applications (such as music player) by moving or shaking the phone

3 touchdevelop api 3d coordinates Y is positive when this edge is up Z is negative when this edge is up X is negative when this edge is up Y is negative when this edge is up Z is positive when this edge is up X is positive when this edge is up

4 touchdevelop api 3d coordinates

5 touchdevelop api 3d coordinates Y is positive when this edge is up Z is negative when this edge is up X is negative when this edge is up Y is negative when this edge is up Z is positive when this edge is up X is positive when this edge is up

6 touchdevelop api events o shake o phone face up o phone face down o phone portrait o phone landscape left o phone landscape right

7 touchdevelop api apis o Senseshas accelerometer Indicates whether accelerometer is present on device Senseshas accelerometer

8 touchdevelop api apis o Sensesacceleration quick Gets filtered accelerometer data using a combination of a low-pass and threshold triggered high-pass on each axis to eliminate the majority of the sensor low amplitude noise while trending very quickly to large offsets (not perfectly smooth signal in that case), providing a very low latency. This is ideal for quickly reacting UI updates. Sensesacceleration quick o Sensesacceleration smooth Gets filtered accelerometer data using a 1 Hz first-order low-pass on each axis to eliminate the main sensor noise while providing a medium latency. This can be used for moderately reacting UI updates requiring a very smooth signal. Sensesacceleration smooth o Sensesacceleration stable Gets filtered and temporally averaged accelerometer data using an arithmetic mean of the last 25 'optimally filtered' samples, so over 500ms at 50Hz on each axis, to virtually eliminate most sensor noise. This provides a very stable reading but it has also a very high latency and cannot be used for rapidly reacting UI. Sensesacceleration stable

9 touchdevelop api apis o Sensesis device stable Indicates whether the device is 'stable' (no movement for about 0.5 seconds) Sensesis device stable More precise when a gyroscope is also present: o Sensesmotion Gets the current phone motion that combines data from the accelerometer Sensesmotion o Motionacceleration Gets the linear acceleration of the device, in gravitational units. Motionacceleration

10 touchdevelop api examples o accelerometer graph http://touchdevelop.com/anlchttp://touchdevelop.com/anlc o accelero colors http://touchdevelop.com/wnnyhttp://touchdevelop.com/wnny o bouncy balls http://touchdevelop.com/ojflhttp://touchdevelop.com/ojfl o turtle o meter http://touchdevelop.com/lkonhttp://touchdevelop.com/lkon o paddle game http://touchdevelop.com/awichttp://touchdevelop.com/awic

11 touchdevelop api exercise read accelerometer data: action main while true do var p = sensesacceleration quick ppost to wall timesleep(1) o when running, tilt phone slowly in different ways o shake phone

12 touchdevelop api exercises map vector to background color use board bonus exercise: level use just one axis

13 touchdevelop api homework finish exercises at home


Download ppt "Touchdevelop api api acceleromete r measure acceleration Disclaimer: This document is provided as-is. Information and views expressed in this document,"

Similar presentations


Ads by Google