void Gyroscope_GyroscopeMeasurementValueChanged(object sender, GyroscopeMeasurementEventArgs e) { //Debug.WriteLine("{0},{1},{2}", e.Measurement.X, e.Measurement.Y, e.Measurement.Z); this.measurement = e.Measurement; // magnetometer has quite a bit of noise, if the value is less than 5 then chances are the // device is not moving. if (Math.Abs(measurement.X) > MinimumMovement) { rx += measurement.X; speedX = 1d + Math.Min(3, Math.Abs(measurement.X / 10)); } if (Math.Abs(measurement.Y) > MinimumMovement) { ry += measurement.Y; speedY = 1d + Math.Min(3, Math.Abs(measurement.Y / 10)); } if (Math.Abs(measurement.Z) > MinimumMovement) { rz += measurement.Z; speedZ = 1d + Math.Min(3, Math.Abs(measurement.Z / 10)); } if (timer == null) { var nowait = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() => { StartTimer(); })); } }
void OnGyroscopeMeasurementValueChanged(object sender, GyroscopeMeasurementEventArgs e) { var nowait = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() => { var m = e.Measurement; string caption = Math.Round(m.X, 3) + "," + Math.Round(m.Y, 3) + "," + Math.Round(m.Z, 3); GetTile("Gyroscope").SensorValue = caption; connected = true; })); }