Windows 8 RT and Windows Phone 8 have compatible sensors in
using Windows.Devices.Sensors;
This replaces the Microsoft.Devices.Sensors API used in Windows Phone OS 7.1.
Inclinometer derives from multiple sensors to return pitch, roll, and yaw values that correspond to rotation angles around the x, y, and z axes
OrientationSensor combines data from other sensors (what Microsft calls "Sensor Fusion") to return a rotation matrix and a Quaternion used to adjust the user's perspective in a game app.
All phones have one.
Accelerometer returns G-force values with respect to the x, y, and z axes.
SAMPLE: Accelerometer sensor sample
Accuracy of 5 degrees.
Gyrometer returns angular velocity values with respect to the x, y, and z axes.
// Determine whether device has a gyro: _gyrometer = Gyrometer.GetDefault(); if( _gyrometer != null){ // Establish report interval (in milliseconds): gyrometer.ReportInterval = 100; _gyrometer.ReadingChanged += _gyrometer_ReadingChanged; }else{ MessageBox.Show("No gyrometer found"); }
// Sensor is started by a non-zero report interval: uint reportInterval = 100; // To avoid exception if interval is too low: if( _gyrometer.MinimumReportInterval > reportInterval){ // Actual report interval is determined by the sensor: reportInterval = _gyrometer.MinimumReportInterval; } _gyrometer.ReportInterval = reportInterval; // Sensor is stopped by a zero report interval: _gyrometer.ReportInterval = 0;
// The preferred method forf apps that updates its user interface at a specific frame rate: // Sensor polling (instead of changed event handler): GyrometerReading reading = _gyrometer.GetCurrentReading; if( reading != null){ X_Reading.Text = String.Format("{0,5:0.00}", reading.AngularVelocityX); Y_Reading.Text = String.Format("{0,5:0.00}", reading.AngularVelocityY); Z_Reading.Text = String.Format("{0,5:0.00}", reading.AngularVelocityZ); }
// Sensor changed event handler (instead of polling): _gyrometer.reportInterval = 100; _gyrometer.ReadingChanged += _gyrometer_ReadingChanged; private void _gyrometer_ReadingChanged(Gyrometer sender, GyrometerReadingChangedEventArgs args){ Dispatcher.BeginInvoke() => { GyrometerReading reading = args.Reading; X_Reading.Text = String.Format("{0,5:0.00}", reading.AngularVelocityX); Y_Reading.Text = String.Format("{0,5:0.00}", reading.AngularVelocityY); Z_Reading.Text = String.Format("{0,5:0.00}", reading.AngularVelocityZ); }); } _gyrometer.ReportInterval = reportInterval; // Sensor is stopped by a zero report interval: _gyrometer.ReportInterval = 0;
Compass returns a heading with respect to True North and possibly Magetic North.
Measures magnetism. Can be significantly affected by metal surrounding the device.
To determine location.
Some have privacy issues.
BLAH: Cannot be programmatically controlled.
Windows Phone 8 does not have SD card.
| Your first name: Your family name: Your location (city, country): Your Email address: |
Top of Page
Thank you! |