internal override void CheckAndDisableSensors() { base.CheckAndDisableSensors(); if (Accelerometer.ShouldBeDisabled) { motionManager.StopAccelerometerUpdates(); } if ((Compass.ShouldBeDisabled || Orientation.ShouldBeDisabled) && !Compass.IsEnabled && !Orientation.IsEnabled) { locationManagerActivated = false; locationManager.StopUpdatingHeading(); } if (Gyroscope.ShouldBeDisabled) { motionManager.StopGyroUpdates(); } if ((UserAcceleration.ShouldBeDisabled || Gravity.ShouldBeDisabled || Orientation.ShouldBeDisabled) && !UserAcceleration.IsEnabled && !Gravity.IsEnabled && !Orientation.IsEnabled) { motionManager.StopDeviceMotionUpdates(); } }
public void StopUpdatesWithMotionType(MotionDataType type) { switch (graphDataSource) { case MotionDataType.AccelerometerData: if (mManager.AccelerometerActive) { mManager.StopAccelerometerUpdates(); } break; case MotionDataType.GyroData: if (mManager.GyroActive) { mManager.StopGyroUpdates(); } break; case MotionDataType.DeviceMotion: if (mManager.DeviceMotionActive) { mManager.StopDeviceMotionUpdates(); } break; } }
/// <summary> /// Stop the specified sensor type reading. /// </summary> /// <param name="sensorType">Sensor type</param> public override void Stop(SensorType sensorType) { switch (sensorType) { case SensorType.Accelerometer: AccelerometerActive = false; motionManager.StopAccelerometerUpdates(); break; case SensorType.Gyroscope: GyroActive = false; motionManager.StopGyroUpdates(); break; case SensorType.DeviceMotion: DeviceMotionActive = false; motionManager.StopDeviceMotionUpdates(); break; case SensorType.Compass: CompassActive = false; locationManager.StopUpdatingHeading(); break; case SensorType.LightLevel: LightLevelActive = false; break; } }
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; }
protected override void Dispose(bool disposing) { displayLink.Invalidate(); motionManager.StopDeviceMotionUpdates(); base.Dispose(disposing); }
public override void ViewDidDisappear(bool animated) { base.ViewDidDisappear(animated); if (motionManager.DeviceMotionActive) { motionManager.StopDeviceMotionUpdates(); } }
public void Stop() { if (_motionManager == null) { return; } _motionManager.StopDeviceMotionUpdates(); _motionManager = null; }
private void PollDeviceMotion() { if (DateTime.Now > nextDeviceMotionPoll) { SaveDeviceMotion(); Task.Run(async() => { await Task.Delay(TimeSpan.FromMinutes(2)); cmManager.StopDeviceMotionUpdates(); }); nextDeviceMotionPoll = DateTime.Now.AddSeconds(deviceMotionInterval); } }
public override void ViewDidDisappear(bool animated) { base.ViewDidDisappear(animated); man.StopDeviceMotionUpdates(); InvokeOnMainThread(() => { var speedVariable = client.Variables.FirstOrDefault(x => x.Name == "Speed"); if (speedVariable != null) { speedVariable.Value = 0; } var turnVariable = client.Variables.FirstOrDefault(x => x.Name == "Turn"); if (turnVariable != null) { turnVariable.Value = 0; } }); client = null; }
protected override async Task StopListeningAsync() { await base.StopListeningAsync(); _motionManager?.StopDeviceMotionUpdates(); }
public override void Update() { base.Update(); // Enable/disable supported sensors and update enabled sensors if (accelerometerSensor != null) { bool enable = accelerometerSensor.IsEnabled; if (enable != motionManager.AccelerometerActive) { if (accelerometerSensor.IsEnabled) { motionManager.StartAccelerometerUpdates(); } else { motionManager.StopAccelerometerUpdates(); } } if (enable) { var accelerometerData = motionManager.AccelerometerData; accelerometerSensor.Acceleration = accelerometerData != null?CmAccelerationToVector3(accelerometerData.Acceleration) : Vector3.Zero; } } if (compassSensor != null) { bool enable = compassSensor.IsEnabled; if (enable != locationManagerActivated) { if (compassSensor.IsEnabled) { locationManager.StartUpdatingHeading(); } else { locationManager.StopUpdatingHeading(); } locationManagerActivated = compassSensor.IsEnabled; } if (enable) { compassSensor.Heading = GetNorthInRadian(locationManager); } } if (gyroscopeSensor != null) { bool enable = gyroscopeSensor.IsEnabled; if (enable != motionManager.GyroActive) { if (gyroscopeSensor.IsEnabled) { motionManager.StartGyroUpdates(); } else { motionManager.StopGyroUpdates(); } } if (enable) { var gyroData = motionManager.GyroData; gyroscopeSensor.RotationRate = gyroData != null?CmRotationRateToVector3(gyroData.RotationRate) : Vector3.Zero; } } if (userAccelerationSensor != null) { bool enable = userAccelerationSensor.IsEnabled || gravitySensor.IsEnabled || orientationSensor.IsEnabled; if (enable != motionManager.DeviceMotionActive) { if (enable) { motionManager.StartDeviceMotionUpdates(); } else { motionManager.StopDeviceMotionUpdates(); } } if (enable) { var motion = motionManager.DeviceMotion; // Update orientation sensor if (motion != null && motion.Attitude != null) { var q = motionManager.DeviceMotion.Attitude.Quaternion; var quaternion = new Quaternion((float)q.x, (float)q.z, -(float)q.y, (float)q.w); if (compassSensor != null) { // re-adjust the orientation to align with the north (common behavior on other platforms) TODO current implementation only takes in account the first value. if (firstNorthValue <= 0) { firstNorthValue = GetNorthInRadian(locationManager); } quaternion = Quaternion.RotationY(-firstNorthValue) * quaternion; } orientationSensor.FromQuaternion(quaternion); } else { orientationSensor.Reset(); } // Update gravity sensor gravitySensor.Vector = motion != null?CmAccelerationToVector3(motion.Gravity) : Vector3.Zero; // Update user acceleration userAccelerationSensor.Acceleration = motion != null?CmAccelerationToVector3(motion.Gravity) : Vector3.Zero; } } }
private void StopDeviceMotion() { motionManager.StopDeviceMotionUpdates(); }
public override void ViewWillDisappear(bool animated) { base.ViewWillDisappear(animated); _motionManager.StopDeviceMotionUpdates(); }
public override void Stop() { motionManager.StopDeviceMotionUpdates(); started = false; state = SensorState.Disabled; }