Exemplo n.º 1
0
        public void StopSensorUpdates()
        {
            if (_motionManager.AccelerometerAvailable)
            {
                _motionManager.StopAccelerometerUpdates();
            }

            if (_motionManager.GyroAvailable)
            {
                _motionManager.StopGyroUpdates();
            }

            if (_motionManager.MagnetometerAvailable)
            {
                _motionManager.StopMagnetometerUpdates();
            }

            if (_motionManager.DeviceMotionAvailable)
            {
                _motionManager.StopDeviceMotionUpdates();
                _pedometer.StopPedometerUpdates();
            }

            IsListening = false;
        }
        /// <summary>
        /// Stop the specified sensorType.
        /// </summary>
        /// <param name="sensorType">Sensor type.</param>
        public void Stop(MotionSensorType sensorType)
        {
            switch (sensorType)
            {
            case MotionSensorType.Accelerometer:
                if (motionManager.AccelerometerActive)
                {
                    motionManager.StopAccelerometerUpdates();
                }
                else
                {
                    Debug.WriteLine("Accelerometer not available");
                }
                break;

            case MotionSensorType.Gyroscope:
                if (motionManager.GyroActive)
                {
                    motionManager.StopGyroUpdates();
                }
                else
                {
                    Debug.WriteLine("Gyroscope not available");
                }
                break;

            case MotionSensorType.Magnetometer:
                if (motionManager.MagnetometerActive)
                {
                    motionManager.StopMagnetometerUpdates();
                }
                else
                {
                    Debug.WriteLine("Magnetometer not available");
                }
                break;

            case MotionSensorType.Compass:
                if (CLLocationManager.HeadingAvailable)
                {
                    locationManager.StopUpdatingHeading();
                    locationManager.UpdatedHeading -= OnHeadingChanged;
                }
                else
                {
                    Debug.WriteLine("Compass not available");
                }
                break;
            }
            sensorStatus[sensorType] = false;
        }
Exemplo n.º 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            motionManager = new CMMotionManager();

            StartButton.TouchUpInside += (sender, e) =>
            {
                motionManager.StartMagnetometerUpdates(NSOperationQueue.CurrentQueue, (data, error) =>
                {
                    this.xLabel.Text = data.MagneticField.X.ToString("0.0000");
                    this.yLabel.Text = data.MagneticField.Y.ToString("0.0000");
                    this.zLabel.Text = data.MagneticField.Z.ToString("0.0000");
                });
            };

            StopButton.TouchUpInside += (sender, e) =>
            {
                motionManager.StopMagnetometerUpdates();
            };
        }
Exemplo n.º 4
0
 protected override void Stop(CMMotionManager mgr)
 {
     mgr.StopMagnetometerUpdates();
 }
Exemplo n.º 5
0
 public void StopReading()
 {
     _motionManager.StopMagnetometerUpdates();
 }