Created
March 7, 2015 15:05
-
-
Save mayur-tendulkar/0ef8f1ae2946eda1275c to your computer and use it in GitHub Desktop.
Read sensor's changed data in ReadingChanged event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For Gyrometer | |
private async void ReadingChanged(object sender, GyrometerReadingChangedEventArgs e) | |
{ | |
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => | |
{ | |
GyrometerReading reading = e.Reading; | |
txtXAxis.Text = String.Format("{0,5:0.00}", reading.AngularVelocityX); | |
txtYAxis.Text = String.Format("{0,5:0.00}", reading.AngularVelocityY); | |
txtZAxis.Text = String.Format("{0,5:0.00}", reading.AngularVelocityZ); | |
}); | |
} | |
//For SimpleOrientationSensor | |
private async void OrientationChanged(object sender, SimpleOrientationSensorOrientationChangedEventArgs e) | |
{ | |
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => | |
{ | |
SimpleOrientation orientation = e.Orientation; | |
switch (orientation) | |
{ | |
case SimpleOrientation.NotRotated: | |
txtOrientation.Text = "Not Rotated"; | |
break; | |
case SimpleOrientation.Rotated90DegreesCounterclockwise: | |
txtOrientation.Text = "Rotated 90 Degrees Counterclockwise"; | |
break; | |
case SimpleOrientation.Rotated180DegreesCounterclockwise: | |
txtOrientation.Text = "Rotated 180 Degrees Counterclockwise"; | |
break; | |
case SimpleOrientation.Rotated270DegreesCounterclockwise: | |
txtOrientation.Text = "Rotated 270 Degrees Counterclockwise"; | |
break; | |
case SimpleOrientation.Faceup: | |
txtOrientation.Text = "Faceup"; | |
break; | |
case SimpleOrientation.Facedown: | |
txtOrientation.Text = "Facedown"; | |
break; | |
default: | |
txtOrientation.Text = "Unknown orientation"; | |
break; | |
} | |
}); | |
} | |
//For LightSensor | |
private async void ReadingChanged(object sender, LightSensorReadingChangedEventArgs e) | |
{ | |
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => | |
{ | |
LightSensorReading reading = e.Reading; | |
txtLuxValue.Text = String.Format("{0,5:0.00}", reading.IlluminanceInLux); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment