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 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 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 Stop() { motionManager.StopAccelerometerUpdates(); motionManager.StopGyroUpdates(); prevAccelTimeStamp = 0; prevGyroTimeStamp = 0; }
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; } }
private void CollisionWithExit() { if (pacman.Frame.IntersectsWith(exit.Frame)) { _motionManager.StopAccelerometerUpdates(); _pacmanXVelocity = 0; _pacmanYVelocity = 0; new UIAlertView("Congratulations", "You've won the game!", null, "OK", null).Show(); } }
protected override bool StopService() { _isOrientationUpdateThreadActive = false; if (_motionManager != null && IsAvailable()) { _motionManager.StopAccelerometerUpdates(); return(true); } return(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; }
public override void ViewDidLoad() { base.ViewDidLoad(); motionManager = new CMMotionManager(); StartButton.TouchUpInside += (sender, e) => { motionManager.StartAccelerometerUpdates(NSOperationQueue.CurrentQueue, (data, error) => { this.xLabel.Text = data.Acceleration.X.ToString("0.0000"); this.yLabel.Text = data.Acceleration.Y.ToString("0.0000"); this.zLabel.Text = data.Acceleration.Z.ToString("0.0000"); }); }; StopButton.TouchUpInside += (sender, e) => { motionManager.StopAccelerometerUpdates(); }; }
partial void UIButton25_TouchUpInside(UIButton sender) { motionManager.StopAccelerometerUpdates(); stoptime = DateTime.Now; builder.Length--; builder.Append("],"); builder.Append("\"EndTime\":\"" + stoptime.ToString() + "\","); var alert = UIAlertController.Create("Mode", builder.ToString(), UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("iOS_Car", UIAlertActionStyle.Default, async action => { builder.Append("\"Mode\":\"Car\"}"); await UseContainerSAS(sas, "iOS_Car", builder.ToString()); })); alert.AddAction(UIAlertAction.Create("iOS_Bus", UIAlertActionStyle.Default, async action => { builder.Append("\"Mode\":\"Bus\"}"); await UseContainerSAS(sas, "iOS_Bus", builder.ToString()); })); alert.AddAction(UIAlertAction.Create("iOS_Train", UIAlertActionStyle.Default, async action => { builder.Append("\"Mode\":\"Train\"}"); await UseContainerSAS(sas, "iOS_Train", builder.ToString()); })); alert.AddAction(UIAlertAction.Create("iOS_Metro", UIAlertActionStyle.Default, async action => { builder.Append("\"Mode\":\"Metro\"}"); await UseContainerSAS(sas, "iOS_Metro", builder.ToString()); })); alert.AddAction(UIAlertAction.Create("iOS_Walk", UIAlertActionStyle.Default, async action => { builder.Append("\"Mode\":\"Walk\"}"); await UseContainerSAS(sas, "iOS_Walk", builder.ToString()); })); alert.AddAction(UIAlertAction.Create("iOS_Bike", UIAlertActionStyle.Default, async action => { builder.Append("\"Mode\":\"Bike\"}"); await UseContainerSAS(sas, "iOS_Bike", builder.ToString()); })); alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null)); PresentViewController(alert, animated: true, completionHandler: null); }
public void Stop() { motionManager.StopAccelerometerUpdates(); prevTimeStamp = 0; }
public void StopReading() { _motionManager.StopAccelerometerUpdates(); }
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; } } }
public override void ViewWillDisappear(bool animated) { motionManager.StopAccelerometerUpdates(); motionManager = null; }
protected override void StopListening() { _motionManager?.StopAccelerometerUpdates(); }
protected override void StopSensingCore() { _locationManager.StopUpdatingLocation(); _sensorManager.StopAccelerometerUpdates(); }
public override void Stop() { motionManager.StopAccelerometerUpdates(); started = false; state = SensorState.Disabled; }
protected override void Stop(CMMotionManager mgr) => mgr.StopAccelerometerUpdates();
protected override async Task StopListeningAsync() { await base.StopListeningAsync(); _motionManager?.StopAccelerometerUpdates(); }
protected override void StopSensor() { _sensorManager.StopAccelerometerUpdates (); }
private void stopMonitoring() { motionManager.StopAccelerometerUpdates(); }
public void Stop() { isRunning = false; isData = false; motionManager.StopAccelerometerUpdates(); }
public void Stop() { motionManager.StopAccelerometerUpdates(); }