コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the DeviceMotionImplementation class.
        /// </summary>
        public DeviceMotionImplementation()
        {
            try
            {
                accelerometer = Accelerometer.GetDefault();
                gyrometer     = Gyrometer.GetDefault();
                compass       = Compass.GetDefault();

#if WINDOWS_PHONE_APP
                magnetometer = Magnetometer.GetDefault();
#endif
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            sensorStatus = new Dictionary <MotionSensorType, bool>()
            {
                { MotionSensorType.Accelerometer, false },
                { MotionSensorType.Gyroscope, false },
                { MotionSensorType.Magnetometer, false },
                { MotionSensorType.Compass, false }
            };
        }
コード例 #2
0
        public Scenario3_Porting()
        {
            this.InitializeComponent();

            // Get two instances of the gyrometer:
            // One that returns the raw gyrometer data
            gyrometerWindows = Gyrometer.GetDefault();
            // Other on which the 'ReadingTransform' is updated so that data returned aligns with the native WP orientation (portrait)
            gyrometerWP = Gyrometer.GetDefault();

            if (gyrometerWP == null || gyrometerWindows == null)
            {
                rootPage.NotifyUser("No gyrometer found", NotifyType.ErrorMessage);
            }
            else
            {
                // Assumption is that this app has been developed for Windows Phone 8.1 (or earlier)
                // and hence assumes that the sensor returns readings in Portrait Mode, which may
                // not be true when the app or sensor logic is being ported over to a
                // Landscape-First Windows device
                // While we encourage you to re-design your app as a universal app to gain access
                // to many other advantages of developing a universal app, this scenario demonstrates
                // a simple approach to let the runtime honor your assumption on the
                // "native orientation" of the sensor.
                gyrometerWP.ReadingTransform = Windows.Graphics.Display.DisplayOrientations.Portrait;
                // If you were to go the route of universal app, make no assumptions about the
                // native orientation of the device. Instead rely on using a display orientation
                // (absolute or current) to enforce the reference frame for the sensor readings.
                // (which is done by updating 'ReadingTransform' property with the appropriate orientation)
            }
        }
コード例 #3
0
        private void OnGetGyrometer(object sender, RoutedEventArgs e)
        {
            Gyrometer        gyrometer = Gyrometer.GetDefault();
            GyrometerReading reading   = gyrometer.GetCurrentReading();

            this.DefaultViewModel["GyrometerResult"] = GetGyrometerResult(reading);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Accelerometer _accelerometer = Accelerometer.GetDefault(AccelerometerReadingType.Standard);;

            _gyrometer = Gyrometer.GetDefault();
            uint _acclDesiredReportInterval = _accelerometer.MinimumReportInterval;
            uint _gyroDesiredReportInterval = _gyrometer.MinimumReportInterval;

            // make timestamped folder for this record session
            string pathParent = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
            string folderPath = System.IO.Path.Combine(pathParent, "IMUData");

            System.IO.Directory.CreateDirectory(new Uri(folderPath).LocalPath);

            // create csv file for this record session
            String fileName = nanoTime() + ".csv";
            String filePath = System.IO.Path.Combine(folderPath, fileName);

            writerCSV = new StreamWriter(new FileStream(new Uri(filePath).LocalPath, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 4096, useAsync: true));
            writerCSV.WriteLine("timestamp" + "," + "omega_x" + "," + "omega_y" + "," + "omega_z" + "," + "alpha_x" + "," + "alpha_y" + "," + "alpha_z");
            //writerCSV.WriteLine("timestamp" + "," +  "alpha_x" + "," + "alpha_y" + "," + "alpha_z");


            // Establish the report interval
            _accelerometer.ReportInterval = _acclDesiredReportInterval;
            _gyrometer.ReportInterval     = _gyroDesiredReportInterval;


            _accelerometer.ReadingChanged += AcclReadingChanged;
            _gyrometer.ReadingChanged     += GyroReadingChanged;
            Console.WriteLine("Data Collecting ...");
            Console.ReadLine();
            writerCSV.Close();
        }
コード例 #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            foreach (FilterInfo device in videoDevices)
            {
                comboBox1.Items.Add(device.Name);
            }
            comboBox1.SelectedIndex = 0;

            videoSource = new VideoCaptureDevice();
            //Accelerometer defaultAcc = Accelerometer.GetDefault();
            _accelerometer = Accelerometer.GetDefault(AccelerometerReadingType.Standard); // set to standard instead of linear acceleration!!!
            //Accelerometer tmp = Accelerometer.GetDefault(AccelerometerReadingType.Linear);
            _gyrometer = Gyrometer.GetDefault();
            textBox1.Clear();
            if (_accelerometer != null)
            {
                _acclDesiredReportInterval = _accelerometer.MinimumReportInterval;
                textBox1.Text      = "IMUs are available on this device!";
                textBox1.BackColor = Color.Green;
                //InitializeTimer();
            }
            else
            {
                textBox1.Text      = "No IMU available on this device!";
                textBox1.BackColor = Color.Red;
            }
            if (_gyrometer != null)
            {
                _gyroDesiredReportInterval = _gyrometer.MinimumReportInterval;
            }
            //if (DEBUG) InitializeTimer();
        }
コード例 #6
0
        /// <summary>
        /// Update Gyrometer 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 UpdateGyrometer(object sender, EventArgs e)
        {
            try
            {
                Gyrometer gyrometer = Gyrometer.GetDefault();
                if (gyrometer != null)
                {
                    XPanel.Text = LocRM.GetString("XAxis") + ": " +
                                  String.Format("{0,5:0.00}", gyrometer.GetCurrentReading().AngularVelocityX) + "(°)/s";
                    YPanel.Text = LocRM.GetString("YAxis") + ": " +
                                  String.Format("{0,5:0.00}", gyrometer.GetCurrentReading().AngularVelocityY) + "(°)/s";
                    ZPanel.Text = LocRM.GetString("ZAxis") + ": " +
                                  String.Format("{0,5:0.00}", gyrometer.GetCurrentReading().AngularVelocityZ) + "(°)/s";

                    pictureBoxX.Image = Rotate(imageX, Math.Max(-135, Math.Min(135, gyrometer.GetCurrentReading().AngularVelocityX)));
                    pictureBoxY.Image = Rotate(imageY, Math.Max(-135, Math.Min(135, gyrometer.GetCurrentReading().AngularVelocityY)));
                    pictureBoxZ.Image = Rotate(imageZ, Math.Max(-135, Math.Min(135, gyrometer.GetCurrentReading().AngularVelocityZ)));
                }
                else
                {
                    XPanel.Text = LocRM.GetString("NotFound");
                    _timer.Stop();
                }
            }
            catch (Exception ex)
            {
                Log.LogError(ex.ToString());
                XPanel.Text = LocRM.GetString("Error");
                _timer.Stop();
            }
        }
コード例 #7
0
 private void OnGetGyrometer2(object sender, RoutedEventArgs e)
 {
     gyrometer = Gyrometer.GetDefault();
     gyrometer.ReportInterval  = gyrometer.MinimumReportInterval;
     gyrometer.ReadingChanged += (sender1, e1) =>
     {
         this.DefaultViewModel["GyrometerResult"] = GetGyrometerResult(e1.Reading);
     };
 }
コード例 #8
0
        /// <summary>
        /// Stops this instance.
        /// </summary>
        partial void Stop()
        {
            var gyroscope = Gyrometer.GetDefault();

            if (gyroscope != null)
            {
                gyroscope.ReadingChanged -= GyroscopeReadingChanged;
            }
        }
コード例 #9
0
        // 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;
            }
        }
 public UWPDeviceInformationService()
 {
     easDevice     = new EasClientDeviceInformation();
     accelerometer = Accelerometer.GetDefault();
     gyrometer     = Gyrometer.GetDefault();
     magnetometer  = Magnetometer.GetDefault();
     try
     {
         vibrationDevice = VibrationDevice.GetDefaultAsync().GetResults();
     }
     catch { }
 }
コード例 #11
0
        private void Initsensor()
        {
            //Accelerometer 相關
            _accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault();

            //Gyromete 相關
            _gyrometer = Gyrometer.GetDefault();

            //Create log file
            Alog = new TestLog("TestAccelerometer.txt");
            Glog = new TestLog("TestGyrometer.txt");
            Hlog = new TestLog("TestAS7000HRM.txt");
        }
コード例 #12
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     gyrometer = Gyrometer.GetDefault();
     if (gyrometer != null)
     {
         gyrometer.ReadingChanged += gyrometer_ReadingChanged;
         Data.Visibility           = Visibility.Visible;
     }
     else
     {
         NoSensorMessage.Visibility = Visibility.Visible;
     }
 }
コード例 #13
0
        /// <summary>
        /// Starts this instance.
        /// </summary>
        partial void Start()
        {
            var gyroscope = Gyrometer.GetDefault();

            if (gyroscope == null)
            {
                return;
            }

            gyroscope.ReportInterval = (uint)Interval;

            gyroscope.ReadingChanged += GyroscopeReadingChanged;
        }
コード例 #14
0
        private void ResolveSensorInfo()
        {
            if (Windows.Devices.Sensors.Accelerometer.GetDefault() != null)
            {
                HasAccelerometerSensor = true;
            }

            if (Compass.GetDefault() != null)
            {
                HasCompass = true;
            }

            try
            {
                if (Gyrometer.GetDefault() != null)
                {
                    HasGyroscopeSensor = true;
                }
            }
            catch (Exception e)
            {
                /* Older phone software had a bug causing the
                 * Gyrometer.GetDefault() to throw a file operation
                 * exception.
                 */
                System.Diagnostics.Debug.WriteLine(e.ToString());
                HasGyroscopeSensor = Microsoft.Devices.Sensors.Gyroscope.IsSupported;
            }

            if (Windows.Devices.Sensors.Inclinometer.GetDefault() != null)
            {
                HasInclinometerSensor = true;
            }

            /* Motion API requires both magnetometer (compass) and
             * accelerometer sensors. Gyroscope sensor is used for more
             * accurate results but is not mandatory.
             */
            MotionApiAvailable = Microsoft.Devices.Sensors.Motion.IsSupported;

            if (Windows.Devices.Sensors.OrientationSensor.GetDefault() != null)
            {
                HasOrientationSensor = true;
            }

            // ProximityDevice is NFC
            if (ProximityDevice.GetDefault() != null)
            {
                HasProximitySensor = true;
            }
        }
コード例 #15
0
        public override void Init()
        {
            if (!SystemInfo.supportsGyroscope)
            {
                Debug.Log("No Gyro Detected, tracking may not work properly");
            }

            sensor = OrientationSensor.GetDefault();
            gyro   = Gyrometer.GetDefault();
            gyro.ReportInterval = gyro.MinimumReportInterval;
            acro = Accelerometer.GetDefault();

            trackingNodes[TrackingNode.HEAD] = new TrackingNode();
        }
コード例 #16
0
        public void OnGetGyrometer()
        {
            Gyrometer sensor = Gyrometer.GetDefault();

            if (sensor != null)
            {
                GyrometerReading reading = sensor.GetCurrentReading();
                GyrometerInfo = $"X: {reading.AngularVelocityX} Y: {reading.AngularVelocityY} Z: {reading.AngularVelocityZ}";
            }
            else
            {
                GyrometerInfo = "Gyrometer not found";
            }
        }
コード例 #17
0
ファイル: MainPage.xaml.cs プロジェクト: arkiq/LabFebruary24
        private async void checkForGyro()
        {
            MessageDialog msgDialog = new MessageDialog("");

            gyrometer = Gyrometer.GetDefault();
            if (gyrometer == null)
            {
                msgDialog.Content = "No gyro present";
                await msgDialog.ShowAsync();
            }
            else
            {
                gyrometer.ReadingChanged += Gyrometer_ReadingChanged;
            }
        }
コード例 #18
0
        private void ToggleGyrometer()
        {
            if (this.SensorSwitches.G != null)
            {
                if (this.SensorSwitches.G.Value > 0)
                {
                    if (this.gyrometer == null)
                    {
                        this.gyrometer = Gyrometer.GetDefault();
                    }

                    if (this.gyrometer != null)
                    {
                        this.gyrometer.ReportInterval =
                            Math.Max(
                                Math.Max(baseMinimum, (uint)this.SensorSwitches.Interval),
                                this.gyrometer.MinimumReportInterval);
                        if (this.SensorSwitches.G.Value != 1)
                        {
                            this.gyrometer.ReadingChanged += this.NewGyro;
                        }

                        this[GYROSCOPE].Id    = this.SensorSwitches.Id;
                        this[GYROSCOPE].Delta = this.SensorSwitches.Delta;

                        if (this.SensorSwitches.G.Value != 3)
                        {
                            this.SensorSwitches.G = null;
                            this.NewGyro(this.gyrometer, null);
                        }
                        else
                        {
                            this.SensorSwitches.G = null;
                        }
                    }
                }
                else
                {
                    if (this.gyrometer != null)
                    {
                        this.gyrometer.ReadingChanged -= this.NewGyro;
                        this.NewGyro(null, null);
                    }

                    this.SensorSwitches.G = null;
                }
            }
        }
コード例 #19
0
 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();
 }
コード例 #20
0
        private void InitializeGyrometer()
        {
            if (gyrometer == null)
            {
                gyrometer = Gyrometer.GetDefault();
                if (gyrometer == null)
                {
                    status.Log(LocalizableStrings.SENSORS_NO_GYROMETER);
                    return;
                }

                uint minInterval = gyrometer.MinimumReportInterval;
                gyrometer.ReportInterval = Math.Max(minInterval, MAX_REPORT_INTERVAL);
                startGyrometer.IsEnabled = true;
                status.Log(LocalizableStrings.SENSORS_GYROMETER_INITIALIZED);
            }
        }
コード例 #21
0
        public Scenario1_DataEvents()
        {
            this.InitializeComponent();

            _gyrometer = Gyrometer.GetDefault();
            if (_gyrometer != 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 = _gyrometer.MinimumReportInterval;
                _desiredReportInterval = minReportInterval > 16 ? minReportInterval : 16;
            }
            else
            {
                rootPage.NotifyUser("No gyrometer found", NotifyType.ErrorMessage);
            }
        }
コード例 #22
0
        /// <summary>
        /// Initializes a new instance of the DeviceMotionImplementation class.
        /// </summary>
        public DeviceMotionImplementation()
        {
            accelerometer = Accelerometer.GetDefault();
            gyrometer     = Gyrometer.GetDefault();
            compass       = Compass.GetDefault();

#if WINDOWS_PHONE_APP
            magnetometer = Magnetometer.GetDefault();
#endif
            sensorStatus = new Dictionary <MotionSensorType, bool>()
            {
                { MotionSensorType.Accelerometer, false },
                { MotionSensorType.Gyroscope, false },
                { MotionSensorType.Magnetometer, false },
                { MotionSensorType.Compass, false }
            };
        }
コード例 #23
0
        public void OnGetGyrometerReport()
        {
            Gyrometer sensor = Gyrometer.GetDefault();

            if (sensor != null)
            {
                sensor.ReportInterval = Math.Max(sensor.MinimumReportInterval, 1000);

                sensor.ReadingChanged += async(s, e) =>
                {
                    GyrometerReading reading = e.Reading;
                    await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        GyrometerInfoReport = $"X: {reading.AngularVelocityX} Y: {reading.AngularVelocityY} Z: {reading.AngularVelocityZ} { reading.Timestamp:T}";
                    });
                };
            }
        }
コード例 #24
0
 public GyrometerImpl()
 {
     _sensor = Gyrometer.GetDefault();
     if (_sensor == null)
     {
         return;
     }
     _sensor.ReadingChanged += (sender, args) => {
         var reading = new GyrometerReport {
             AngularVelocityX = args.Reading.AngularVelocityX,
             AngularVelocityY = args.Reading.AngularVelocityY,
             AngularVelocityZ = args.Reading.AngularVelocityZ,
             Timestamp        = args.Reading.Timestamp
         };
         if (ReadingChanged != null)
         {
             ReadingChanged(reading);
         }
     };
 }
コード例 #25
0
ファイル: GyrometerTests.xaml.cs プロジェクト: jokm1/uno-2
 public GyrometerTestsViewModel(CoreDispatcher dispatcher) : base(dispatcher)
 {
     _gyrometer = Gyrometer.GetDefault();
     if (_gyrometer != null)
     {
         _gyrometer.ReportInterval = 250;
         SensorStatus = "Gyrometer created";
     }
     else
     {
         SensorStatus = "Gyrometer not available on this device";
     }
     Disposables.Add(Disposable.Create(() =>
     {
         if (_gyrometer != null)
         {
             _gyrometer.ReadingChanged -= Gyrometer_ReadingChanged;
         }
     }));
 }
コード例 #26
0
        async void initialize()
        {
            //-----------------------------------------------------------------------------陀螺仪部分
            string errMessage = "";

            try
            {
                //获取默认的陀螺仪对象
                gyrometer = Gyrometer.GetDefault();
                if (gyrometer == null)
                {
                    await new MessageDialog("不支持陀螺仪").ShowAsync();
                    return;
                }
                //设置读取数据的时间间隔
                gyrometer.ReportInterval  = 1000;
                gyrometer.ReadingChanged += gyrometer_ReadingChanged;
                gyrometerReading          = gyrometer.GetCurrentReading();
            }

            catch (Exception err)
            {
                errMessage = err.Message;
            }

            if (errMessage != "")
            {
                await new MessageDialog(errMessage).ShowAsync();
            }

            //-------------------------------------------------------------
            GetLocation();
            ShowData();
            starclient = new StarClient(GetTime()[0], GetTime()[1], GetTime()[2], GetTime()[3], weidu, jingdu,
                                        Double.Parse(currentX), Double.Parse(currentY), Double.Parse(currentZ));
            number = starclient.planetnumber();

            //MySqlite = new mysqlite();
            //MySqlite.creatTable();
        }
コード例 #27
0
        /// <summary>
        /// Resolves the sensor information.
        /// </summary>
        private void ResolveSensorInfo()
        {
            if (Windows.Devices.Sensors.Accelerometer.GetDefault() != null)
            {
                HasAccelerometerSensor = true;
            }

            if (Compass.GetDefault() != null)
            {
                HasCompass = true;
            }

            try
            {
                if (Gyrometer.GetDefault() != null)
                {
                    HasGyroscopeSensor = true;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }

            if (Windows.Devices.Sensors.Inclinometer.GetDefault() != null)
            {
                HasInclinometerSensor = true;
            }

            if (Windows.Devices.Sensors.OrientationSensor.GetDefault() != null)
            {
                HasOrientationSensor = true;
            }

            // ProximityDevice is NFC
            if (ProximityDevice.GetDefault() != null)
            {
                HasProximitySensor = true;
            }
        }
コード例 #28
0
        public void Start(SensorType sensorType, int interval)
        {
            switch (sensorType)
            {
            case SensorType.Accelerometer:
                accelerometer = Accelerometer.GetDefault();
                if (accelerometer != null)
                {
                    accelerometer.ReadingChanged += Accelerometer_ReadingChanged;
                }
                break;

            case SensorType.Gyroscope:
                gyrometer = Gyrometer.GetDefault();
                if (gyrometer != null)
                {
                    gyrometer.ReadingChanged += Gyrometer_ReadingChanged;
                }
                break;

            case SensorType.Magntometer:
                magnetometer = Magnetometer.GetDefault();
                if (magnetometer != null)
                {
                    magnetometer.ReadingChanged += Magnetometer_ReadingChanged;
                }
                break;

            case SensorType.Altimeter:
                altimeter = Altimeter.GetDefault();
                if (altimeter != null)
                {
                    altimeter.ReadingChanged += Altimeter_ReadingChanged;
                }
                break;
            }

            sensorTypeStatus[sensorType] = true;
        }
コード例 #29
0
        private void ConfigureGyrometer()
        {
            // Get the reference to the sensor and see if it is available
            _gyrometer = Gyrometer.GetDefault();
            if (_gyrometer == null)
            {
                return;
            }

            _sensorSettings.IsGyrometerAvailable = true;

            // Set the minimum report interval.  Care must be taken to ensure
            // it is not set to a value smaller than the device minimum
            var minInterval = _gyrometer.MinimumReportInterval;

            _gyrometer.ReportInterval
                = Math.Max(_sensorSettings.SensorReportInterval, minInterval);
            _gyrometer.ReadingChanged += GyrometerOnReadingChanged;

            // Read the initial sensor value
            _sensorSettings.LatestGyrometerReading = GetGyrometerReading();
        }
コード例 #30
0
        public Scenario2()
        {
            this.InitializeComponent();

            _gyrometer = Gyrometer.GetDefault();
            if (_gyrometer != 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 = _gyrometer.MinimumReportInterval;
                _desiredReportInterval = minReportInterval > 16 ? minReportInterval : 16;

                // Set up a DispatchTimer
                _dispatcherTimer          = new DispatcherTimer();
                _dispatcherTimer.Tick    += DisplayCurrentReading;
                _dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, (int)_desiredReportInterval);
            }
            else
            {
                rootPage.NotifyUser("No gyrometer found", NotifyType.StatusMessage);
            }
        }