Win8 on Intel Programming Course Modern UI : Sensors Cédric Andreolli Intel Software
Sensors
Sensors in few words Sensors convert a physical measure into a signal Sensors are used for Temperature Device Location : GPS Orientation Etc Sensors are used in mobile development since many years They are already available on tablet and on some Ultrabooks
Sensors Why use sensors Using sensors can improve the user experience They are used in games They are used in augmented reality They are used in GPS application A lot of mobile applications use sensors today !
Different kinds of sensors
Sensors Device location GPS is the most popular kind of sensor The GPS acquire the user position from satellites Wi-Fi can also be used (WPS) Give access to : Latitude Longitude Altitude
Sensors Accelerometer Compute the proper acceleration of an object An accelerometer contains 3 sensors : One for the x-axis One for the y-axis One for the z-axis An accelerometer that lay on a table will measure g=-9.81 m/s on the z-axis
Sensors Gyrometer It measures rotational velocity It doesn’t define a position but the current rotation speed Data difficult to use directly
Sensors Magnetometer Measures the strenght of a magnetic field Can be used to compute the device orientation
Sensors Light sensor Measures the intensity of light in Lux Windows 8 uses the light sensor to set the screen luminosity
Sensor fusion
What is the sensor fusion A single sensor do not provide clean data It is very hard to get a stable device orientation The value of a single sensor can suffer from interference Fusionning sensors can help solving this problem
Sensor fusion How does it work ? The fusion of the 3 default sensors gives access to : Compass + Inclinometer + Orientation
Programming with sensors
Access and Rights Some sensors give access to personal information Example : GPS gives the user’s current position You need to activate new capabilities Open the manifest and go to “Capabilities”
Programming with sensors
Windows.Devices.Sensors Namespace that gives access to the sensors. References : Accelerometer Compass Gyrometer Inclinometer LightSensor etc … Use the GetDefault() method to access the device : Var accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault()
Programming with sensors The Accelerometer Easy to implement Not so easy to use Represent the proper acceleration on each axis Interferences can modify the value Lets see how to retrieve the values of this sensor
Programming with sensors The Accelerometer – full code
Programming with sensors The Light Sensor – full code
Programming with sensors The Location service Implementation of the location service is different Using the location can be very interesting Show some places of interest near your position Indicates your current location to a friend etc … A lot of augmented reality applications use GPS
Programming with sensors
The Location Service – full code
Programming with sensors The Location Service – here’s how it looks
License Creative Commons – By 3.0 You are free: to Share — to copy, distribute and transmit the work to Remix — to adapt the work to make commercial use of the work Under the following conditions: Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). With the understanding that: Waiver — Any of the above conditions can be waived if you get permission from the copyright holder. Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license. Other Rights — In no way are any of the following rights affected by the license: – Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; – The author's moral rights; – Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. Notice — For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.