O'Reilly logo

Windows Application Development Cookbook by Marcin Jamro

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

Reading data from a compass

The accelerometer is not the only sensor that can be used by UWP applications. The second one that is presented in this chapter is a compass. It allows you to get a heading relative to the magnetic north or geographic true north, if available. Of course, such a heading is returned in degrees. You will learn how to obtain values from a compass sensor in this recipe.

As an example, you will create an application that presents a compass rose that rotates according to the current heading relative to the magnetic north.

Getting ready

To step through this recipe, you only need the automatically generated project.

How to do it...

To prepare an example of rotating a compass rose according to data obtained from the compass sensor, ...

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