O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the Gyroscope Sensor

The gyroscope sensor is not a required component of Windows Phone devices. It is therefore important to verify that it is supported before attempting to use it. For this, the static Gyroscope.IsSupported property is used, as demonstrated in the GyroscopeViewModel class (see Listing 16.9). The Start method of the GyroscopeViewModel oversees the creation of the Gyroscope instance.

The default value of the Gyroscope’s TimeBetweenUpdates property is 20 milliseconds, which on my test device was the minimum allowed value.

As with all sensor types, the CurrentValueChanged event is used to receive periodic updates from the sensor.

LISTING 16.9. GyroscopeViewModel.Start Method

public void Start() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required