async void MainPage_ReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { TextInclinometer.Text = string.Format(@"Inclinometer : P={0} R={1} Y={2}", args.Reading.PitchDegrees, args.Reading.RollDegrees, args.Reading.YawDegrees); }); }
void MainPage_ReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { Dispatcher.BeginInvoke(new Action(() => { TextInclinometer.Text = string.Format(@"Inclinometer : P={0} R={1} Y={2}", args.Reading.PitchDegrees, args.Reading.RollDegrees, args.Reading.YawDegrees); })); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); // Update dimensions of the world ViewModel.UpdateWorld(this.ActualWidth, this.ActualHeight); // Get location and update centre of world var accessStatus = await Geolocator.RequestAccessAsync(); geolocator = new Geolocator(); var position = await geolocator.GetGeopositionAsync(); UpdateLocation(position); geolocator.PositionChanged += Geolocator_PositionChanged; inclinometer = Inclinometer.GetDefault(); var inclination = inclinometer.GetCurrentReading(); PopulateWorld(); inclinometer.ReadingChanged += Inclinometer_ReadingChanged; inclinometer.ReportInterval = 1; UpdateElementsOnScreen(inclination); }
public AppModel() { CubeTransform = InitializeCubeTransform(); var inclinometer = Inclinometer.GetDefault(); if (inclinometer != null) { inclinometer.ReportInterval = 200; inclinometer.ReadingChanged += (o, e) => InclinationData.Value = e.Reading; } var orientationSensor = OrientationSensor.GetDefault(); if (orientationSensor != null) { orientationSensor.ReportInterval = 200; orientationSensor.ReadingChanged += (o, e) => OrientationData.Value = e.Reading; } RotationQuaternion = OrientationData.Select(d => d.Quaternion.ToQuaternion()).ToReadOnlyReactiveProperty(); RotationQuaternionString = RotationQuaternion.Select(q => $"{q.W:F2}; ({q.X:F2}, {q.Y:F2}, {q.Z:F2})").ToReadOnlyReactiveProperty(); // Rotation is represented by a matrix, a quaternion or Euler angles (roll, pitch and yaw). RotationMatrix = OrientationData.Select(d => d.RotationMatrix.ToMatrix3D()).ToReadOnlyReactiveProperty(); //RotationMatrix = RotationQuaternion.Select(q => q.ToMatrix3D()).ToReadOnlyReactiveProperty(); //RotationMatrix = InclinationData.Select(i => i.ToMatrix3D()).ToReadOnlyReactiveProperty(); // An inverse matrix represents the inverse rotation. RotationMatrix .ObserveOn(SynchronizationContext.Current) //.Subscribe(m => matrixTransform.Matrix = m); .Subscribe(m => { m.Invert(); matrixTransform.Matrix = m; }); }
private void OnGetInclinometer(object sender, RoutedEventArgs e) { Inclinometer inclinometer = Inclinometer.GetDefault(); InclinometerReading reading = inclinometer.GetCurrentReading(); this.DefaultViewModel["InclinometerResult"] = GetInclinometerResult(reading); }
private async void OnInclinometerReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs e) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { _reading.InsertVector3("Offset", new Vector3(e.Reading.RollDegrees, e.Reading.PitchDegrees, 0.0f)); }); }
/// <summary> /// Update InclinoMeter readings event and update UI /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">The <see cref="object"/> instance containing the event data.</param> private void UpdateInclinoMeter(object sender, EventArgs e) { try { Inclinometer inclino = Inclinometer.GetDefault(); if (inclino != null) { PitchLbl.Text = LocRM.GetString("XDegree") + ": " + String.Format("{0,5:0.00}", inclino.GetCurrentReading().PitchDegrees.ToString()) + " (°)"; RollLbl.Text = LocRM.GetString("YDegree") + ": " + String.Format("{0,5:0.00}", inclino.GetCurrentReading().RollDegrees.ToString()) + " (°)"; YawLbl.Text = LocRM.GetString("ZDegree") + ": " + String.Format("{0,5:0.00}", inclino.GetCurrentReading().YawDegrees.ToString()) + " (°)"; } else { PitchLbl.Text = LocRM.GetString("NotFound"); _timer.Stop(); } } catch (Exception ex) { _timer.Stop(); PitchLbl.Text = LocRM.GetString("Error"); Log.LogError(ex.ToString()); } }
async void OnInclinometerReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { ShowYawPitchRoll(args.Reading); }); }
private void OnGetInclinometer2(object sender, RoutedEventArgs e) { inclinometer = Inclinometer.GetDefault(); inclinometer.ReportInterval = inclinometer.MinimumReportInterval; inclinometer.ReadingChanged += (sender1, e1) => { this.DefaultViewModel["InclinometerResult"] = GetInclinometerResult(e1.Reading); }; }
private void activateSensorData() { Inclinometer inclinometer = Inclinometer.GetDefault(); if (inclinometer != null) { sensorRead = inclinometer.GetCurrentReading(); } }
private void OnInclinometerReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { txtPitch.Text = args.Reading.PitchDegrees.ToString(); txtRoll.Text = args.Reading.RollDegrees.ToString(); txtYaw.Text = args.Reading.YawDegrees.ToString(); }); }
async void inclinometer_ReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { ProjectionImage.RotationX = 90 - args.Reading.PitchDegrees; ProjectionImage.RotationZ = args.Reading.RollDegrees; ProjectionImage.RotationY = -args.Reading.YawDegrees; }); }
private async void inclinometer_ReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { PitchValue.Text = args.Reading.PitchDegrees.ToString(); RollValue.Text = args.Reading.RollDegrees.ToString(); YawValue.Text = args.Reading.YawDegrees.ToString(); TimeStamp.Text = args.Reading.Timestamp.ToString(); }); }
public SensorManager(Grid grid) { _accelerometer = new Accelerometer(); _gyrometer = new Gyrometer(); _inclinometer = new Inclinometer(); _light = new AmbientLight(); _compass = new Compass(); _updaters = new List <Action>(); _grid = grid; }
// Sample code for building a localized ApplicationBar //private void BuildLocalizedApplicationBar() //{ // // Set the page's ApplicationBar to a new instance of ApplicationBar. // ApplicationBar = new ApplicationBar(); // // Create a new button and set the text value to the localized string from AppResources. // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative)); // appBarButton.Text = AppResources.AppBarButtonText; // ApplicationBar.Buttons.Add(appBarButton); // // Create a new menu item with the localized string from AppResources. // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText); // ApplicationBar.MenuItems.Add(appBarMenuItem); //} private async void Start() { if (!timer.IsEnabled) { string runningMessage = "Reading: "; accelSensor = Accelerometer.GetDefault(); if (accelSensor != null) { accelSensor.ReportInterval = 66; runningMessage += "Accelerometer "; } // while not shown in the chapter, get the current location so that // true heading is more accurate. Geolocator locator = new Geolocator(); await locator.GetGeopositionAsync(); compassSensor = Compass.GetDefault(); if (compassSensor != null) { compassSensor.ReportInterval = 66; runningMessage += "Compass "; } try { gyroSensor = Gyrometer.GetDefault(); } catch (FileNotFoundException) { } if (gyroSensor != null) { gyroSensor.ReportInterval = 66; runningMessage += "Gyroscope "; } inclineSensor = Inclinometer.GetDefault(); if (inclineSensor != null) { inclineSensor.ReportInterval = 66; runningMessage += "Inclinometer "; } orientationSensor = OrientationSensor.GetDefault(); if (orientationSensor != null) { orientationSensor.ReportInterval = 66; runningMessage += "Orientation "; } timer.Start(); messageBlock.Text = runningMessage; } }
private async void inclinometerSensor_ReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { InclinometerReading reading = args.Reading; yawDegrees.Text = String.Format("{0,2:0.00}", reading.YawDegrees.ToString()); pitchDegrees.Text = String.Format("{0,2:0.00}", reading.PitchDegrees.ToString()); rollDegrees.Text = String.Format("{0,2:0.00}", reading.RollDegrees.ToString()); }); }
protected override void OnNavigatedTo(NavigationEventArgs e) { inclinometer = Inclinometer.GetDefault(); if (inclinometer != null) { inclinometer.ReadingChanged += inclinometer_ReadingChanged; Data.Visibility = Visibility.Visible; } else { NoSensorMessage.Visibility = Visibility.Visible; } }
public void OnGetInclinometer() { Inclinometer sensor = Inclinometer.GetDefault(); if (sensor != null) { InclinometerReading reading = sensor.GetCurrentReading(); InclinometerInfo = $"pitch degrees: {reading.PitchDegrees} roll degrees: {reading.RollDegrees} yaw accuracy: {reading.YawAccuracy} yaw degrees: {reading.YawDegrees}"; } else { InclinometerInfo = "Inclinometer not found"; } }
void Start() { #if WINDOWS_PHONE _sensor = Inclinometer.GetDefault(); _hasSensor = _sensor != null; if (_hasSensor) { _sensor.ReportInterval = _sensor.MinimumReportInterval; } #else _hasSensor = false; #endif }
public Scenario2_Polling() { this.InitializeComponent(); Sensor = Inclinometer.GetDefaultForRelativeReadings(); if (Sensor == null) { RootPage.NotifyUser("No relative inclinometer found", NotifyType.ErrorMessage); GetDataButton.IsEnabled = false; } else { GetDataButton.IsEnabled = true; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); sIncline = Inclinometer.GetDefault(SensorReadingType.Absolute); sDisplay = DisplayInformation.GetForCurrentView(); sOrient = OrientationSensor.GetDefault(SensorReadingType.Absolute); sOrient.ReadingChanged += SOrient_ReadingChanged; sDisplay.OrientationChanged += SDisplay_OrientationChanged; sIncline.ReadingChanged += SIncline_ReadingChanged; LastDisplayOrient = sDisplay.CurrentOrientation; LastIncline = sIncline.GetCurrentReading(); LastOrient = sOrient.GetCurrentReading(); timer.Start(); }
public EFISAdapterController( Inclinometer inclinometer, TurnCoordinator turnCoordinator, ADIVariables adiVariables, HSIVariables hsiVariables) { this.inclinometer = inclinometer; this.turnCoordinator = turnCoordinator; this.adiVariables = adiVariables; this.hsiVariables = hsiVariables; this.categoryService = serviceFactory.getCategoryService(); this.airframeDataService = serviceFactory.getAirframeDataService(); this.simSecurityService = serviceFactory.getSimSecurityService(); this.apDataService = serviceFactory.getAutoPilotDataService(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape | DisplayOrientations.LandscapeFlipped | DisplayOrientations.Portrait | DisplayOrientations.PortraitFlipped; acc = Accelerometer.GetDefault(); //act = ActivitySensor.GetDefaultAsync().GetResults(); alt = Altimeter.GetDefault(); baro = Barometer.GetDefault(); comp = Compass.GetDefault(); gyro = Gyrometer.GetDefault(); //has = HingeAngleSensor.GetDefaultAsync().GetResults(); inc = Inclinometer.GetDefault(); mm = Magnetometer.GetDefault(); os = OrientationSensor.GetDefault(); //pm = Pedometer.GetDefaultAsync().GetResults(); //ps = ProximitySensor.FromId(ProximitySensor.GetDeviceSelector()); sos = SimpleOrientationSensor.GetDefault(); }
public Scenario1() { this.InitializeComponent(); _inclinometer = Inclinometer.GetDefault(); if (_inclinometer != null) { // Select a report interval that is both suitable for the purposes of the app and supported by the sensor. // This value will be used later to activate the sensor. uint minReportInterval = _inclinometer.MinimumReportInterval; _desiredReportInterval = minReportInterval > 16 ? minReportInterval : 16; } else { rootPage.NotifyUser("No inclinometer found", NotifyType.StatusMessage); } }
private void SetupInclinometer() { _inclinometer = Inclinometer.GetDefault(); if (_inclinometer != null) { // Select a report interval that is both suitable for the purposes of the app and supported by the sensor. // This value will be used later to activate the sensor. uint minReportInterval = _inclinometer.MinimumReportInterval; _desiredReportInterval = minReportInterval > 16 ? minReportInterval : 16; // Establish the report interval. _inclinometer.ReportInterval = _desiredReportInterval; // Whenever the app is not present... Window.Current.VisibilityChanged += OnWindowVisibilityChanged; } }
public Scenario1_DataEvents() { this.InitializeComponent(); Sensor = Inclinometer.GetDefaultForRelativeReadings(); if (Sensor != null) { // Select a report interval that is both suitable for the purposes of the app and supported by the sensor. // This value will be used later to activate the sensor. uint minReportInterval = Sensor.MinimumReportInterval; DesiredReportInterval = minReportInterval > 16 ? minReportInterval : 16; } else { rootPage.NotifyUser("No relative inclinometer found", NotifyType.ErrorMessage); } }
public void OnGetInclinometerReport() { Inclinometer sensor = Inclinometer.GetDefault(); if (sensor != null) { sensor.ReportInterval = Math.Max(sensor.MinimumReportInterval, 1000); sensor.ReadingChanged += async(s, e) => { InclinometerReading reading = e.Reading; await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { InclinometerInfoReport = $"pitch degrees: {reading.PitchDegrees} roll degrees: {reading.RollDegrees} yaw accuracy: {reading.YawAccuracy} yaw degrees: {reading.YawDegrees} {reading.Timestamp:T}"; }); }; } }
/// <summary> /// このページがフレームに表示されるときに呼び出されます。 /// </summary> /// <param name="e">このページにどのように到達したかを説明するイベント データ。Parameter /// プロパティは、通常、ページを構成するために使用します。</param> protected override void OnNavigatedTo(NavigationEventArgs e) { accelerometer = Accelerometer.GetDefault(); if (accelerometer != null) { accelerometer.ReadingChanged += accelerometer_ReadingChanged; } inclinometer = Inclinometer.GetDefault(); if (inclinometer != null) { inclinometer.ReadingChanged += inclinometer_ReadingChanged; } compass = Compass.GetDefault(); if (compass != null) { compass.ReadingChanged += compass_ReadingChanged; } }
public MainPage() { this.InitializeComponent(); // Fires when the window has changed its rendering size // Set the scale on page load Scaling.SetScale(); Window.Current.SizeChanged += Current_SizeChanged; photonX = (float)boundaries.Width / 2; photonY = (float)boundaries.Height - (140f * scaleHeight); // Round Timer RoundTimer.Tick += RoundTimer_Tick; RoundTimer.Interval = new TimeSpan(0, 0, 1); // Enemy Timer EnemyTimer.Tick += EnemyTimer_Tick; // Controls intervals that spawn enemies EnemyTimer.Interval = new TimeSpan(0, 0, 0, 0, EnemyGenIntervalRand.Next(300, 2000)); // Weapon Positions WeaponPosX = (float)boundaries.Width / 2 - (50 * scaleWidth); WeaponPosY = (float)boundaries.Height - (150 * scaleHeight); // To Implement the inclinometre I followed this guide from Microsoft https://docs.microsoft.com/en-us/windows/uwp/devices-sensors/use-the-inclinometer // Grab the default inclinometre inclinometer = Inclinometer.GetDefault(); if (inclinometer != null) { // Establish the report interval for all scenarios uint minReportInterval = inclinometer.MinimumReportInterval; uint reportInterval = minReportInterval > 16 ? minReportInterval : 16; //Establish the event handler inclinometer.ReadingChanged += new TypedEventHandler <Inclinometer, InclinometerReadingChangedEventArgs>(ReadingChanged); } }
// Uncomment for Inclinometre // Create the change event private async void ReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs e) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { InclinometerReading reading = e.Reading; roll = reading.RollDegrees; pitch = reading.PitchDegrees; yaw = reading.YawDegrees; // Move right if (pitch > 0 && WeaponPosX < 1100 * scaleWidth) { WeaponPosX = WeaponPosX + pitch; } // Else move left else if (pitch < 0 && WeaponPosX > 100 * scaleWidth) { WeaponPosX = WeaponPosX + pitch; } }); }