public override void OnDisappearing() { try { Magnetometer.ReadingChanged -= OnMagnetometerReadingChanged; if (Magnetometer.IsMonitoring) { Magnetometer.Stop(); } Accelerometer.ShakeDetected -= OnShakeDetected; Accelerometer.ReadingChanged -= OnAccelerometerReadingChanged; if (Accelerometer.IsMonitoring) { Accelerometer.Stop(); } Gyroscope.ReadingChanged -= OnGyroscopeReadingChanged; if (Gyroscope.IsMonitoring) { Gyroscope.Stop(); } } catch (FeatureNotSupportedException ex) { Logger.Debug("Feature not supported: " + ex.Message); } }
public void ToggleGyroscope() { // The Main Thread - To start the code on Main Thread MainThread.BeginInvokeOnMainThread(() => { try { if (Gyroscope.IsMonitoring) { Console.WriteLine("Gyroscope Stoped"); Gyroscope.Stop(); Console.WriteLine("Gyroscope Stoped - isStarted : " + isStarted); } else { Console.WriteLine("Gyroscope Started"); Gyroscope.Start(speed); this.isStarted = true; Console.WriteLine("Gyroscope Started - isStarted : " + isStarted); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device } catch (Exception ex) { // Other error has occurred. } }); }
void Stop() { if (Compass.IsMonitoring) { Compass.ReadingChanged -= Compass_ReadingChanged; Compass.Stop(); } if (Accelerometer.IsMonitoring) { Accelerometer.ReadingChanged -= Accelerometer_Essentials_ReadingChanged; Accelerometer.Stop(); } if (Gyroscope.IsMonitoring) { Gyroscope.ReadingChanged -= Gyroscope_ReadingChanged; Gyroscope.Stop(); } if (Magnetometer.IsMonitoring) { Magnetometer.ReadingChanged -= Magnetometer_ReadingChanged; Magnetometer.Stop(); } // device-specific sensor readings if (Device.RuntimePlatform.Equals((Device.Android))) { MessagingCenter.Unsubscribe <Sensors.Android.LinearAcceleration>(this, Sensors.Android.SubscriberMessage.LinearAcceleration); } }
public async Task Stop_Monitor(SensorSpeed sensorSpeed) { // TODO: the test runner app (UI version) should do this, until then... if (!HardwareSupport.HasGyroscope) { return; } var tcs = new TaskCompletionSource <GyroscopeData>(); Gyroscope.ReadingChanged += Gyroscope_ReadingChanged; Gyroscope.Start(sensorSpeed); void Gyroscope_ReadingChanged(object sender, GyroscopeChangedEventArgs e) { tcs.TrySetResult(e.Reading); } var d = await tcs.Task; Gyroscope.Stop(); Gyroscope.ReadingChanged -= Gyroscope_ReadingChanged; Assert.False(Gyroscope.IsMonitoring); }
public void ControlSunscribe(bool flag) { try { if (Gyroscope.IsMonitoring && !flag) { Gyroscope.Stop(); GyroWatch.Reset(); } else if (!Gyroscope.IsMonitoring && flag) { GyroWatch.Start(); Gyroscope.Start(Config.sensorSpeed); } else { //Dont think anything is needed here } } catch (FeatureNotEnabledException ex) { } catch (Exception ex) { } }
public void ToggleGyroscope() { try { if (Gyroscope.IsMonitoring) { Gyroscope.Stop(); this.Started = false; Console.WriteLine("Gyroscope is stoped"); } else { Gyroscope.Start(Speed); this.Started = true; Console.WriteLine("Gyroscope is started"); } } catch (FeatureNotSupportedException fnsEx) { Console.WriteLine("Non Pris en charge" + fnsEx); } catch (Exception ex) { Console.WriteLine("Une Exception s'est produite" + ex); } }
public void GyroscopeSwitch_Toggled(object sender, ToggledEventArgs e) { try { if (e.Value && !Gyroscope.IsMonitoring) { Gyroscope.ReadingChanged += Gyroscope_ReadingChanged; Gyroscope.Start(speed); } else if (!e.Value && Gyroscope.IsMonitoring) { Gyroscope.Stop(); Gyroscope.ReadingChanged -= Gyroscope_ReadingChanged; GyroscopeMin = null; GyroscopeMax = null; } } catch (FeatureNotSupportedException) { // Feature not supported on device } catch (Exception) { // Other error has occurred. } }
public void ToggleMetrics(bool isToogled) { try { if (isToogled) { Accelerometer.Start(speed); //Barometer.Start(speed); Compass.Start(speed); Gyroscope.Start(speed); Magnetometer.Start(speed); OrientationSensor.Start(speed); } else { Accelerometer.Stop(); //Barometer.Stop(); Compass.Stop(); Gyroscope.Stop(); Magnetometer.Stop(); OrientationSensor.Stop(); } } catch (FeatureNotSupportedException) { ShowNotSupportedError(); } catch (Exception ex) { ShowError(ex.Message); } }
public IObservable <MotionReading> WhenReadingTaken() { this.observable = this.observable ?? Observable.Create <MotionReading>(ob => { var handler = new EventHandler <GyroscopeDataUpdatedEventArgs>((sender, args) => ob.OnNext(new MotionReading(args.X, args.Y, args.Z)) ); var sensor = new Gyroscope { Interval = 250 }; sensor.DataUpdated += handler; sensor.Start(); return(() => { sensor.Stop(); sensor.DataUpdated -= handler; sensor.Dispose(); }); }) .Publish() .RefCount(); return(this.observable); }
public void ToggleGyroscope() { try { if (Gyroscope.IsMonitoring) { Gyroscope.Stop(); this.lblResult.Text += "Stop!!!" + Environment.NewLine; } else { Gyroscope.Start(speed); this.lblResult.Text = ""; } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device this.lblResult.Text = fnsEx.ToString(); } catch (Exception ex) { // Other error has occurred. this.lblResult.Text = ex.ToString(); } }
public void ToggleGyroscope() { try { if (Gyroscope.IsMonitoring) { Gyroscope.Stop(); isStarted = false; } else { Gyroscope.Start(speed); isStarted = true; } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device throw fnsEx.InnerException; } catch (Exception ex) { // Other error has occurred. throw ex.InnerException; } }
protected override void OnDisappearing() { Accelerometer.Stop(); Gyroscope.Stop(); Magnetometer.Stop(); Compass.Stop(); base.OnDisappearing(); }
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e) { if (_g != null) { _g.Stop(); _g.CurrentValueChanged -= GyroscopeCurrentValueChanged; } }
protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e) { base.OnNavigatingFrom(e); if (gyro != null) { gyro.Stop(); gyro.CurrentValueChanged -= gyro_CurrentValueChanged; } }
/// <summary> /// Stop the specified sensorType. /// </summary> /// <param name="sensorType">Sensor type.</param> public void Stop(MotionSensorType sensorType) { switch (sensorType) { case MotionSensorType.Accelerometer: if (accelerometer != null) { accelerometer.DataUpdated -= AccelerometerDataUpdated; accelerometer.Stop(); } else { Debug.WriteLine("Accelerometer not available"); } break; case MotionSensorType.Gyroscope: if (gyroscope != null) { gyroscope.DataUpdated -= GyroscopeDataUpdated; gyroscope.Stop(); } else { Debug.WriteLine("Gyrometer not available"); } break; case MotionSensorType.Magnetometer: if (magnetometer != null) { magnetometer.DataUpdated -= MagnetometerDataUpdated; magnetometer.Stop(); } else { Debug.WriteLine("Magnetometer not available"); } break; case MotionSensorType.Compass: if (orientation != null) { orientation.DataUpdated -= OrientationDataUpdated; orientation.Stop(); } else { Debug.WriteLine("OrientationSensor not available"); } break; } sensorStatus[sensorType] = false; }
private void PositionChanged(object sender, PositionEventArgs e) { Gyroscope.Stop(); if (updatePosition != null && lastPosition.Latitude != e.Position.Latitude && lastPosition.Longitude != e.Position.Longitude) { updatePosition(e.Position); } Gyroscope.Start(SensorSpeed.UI); }
public void StopSensors() { Accelerometer.Stop(); Magnetometer.Stop(); Gyroscope.Stop(); Accelerometer.ReadingChanged -= Accelerometer_ReadingChanged; Magnetometer.ReadingChanged -= Magnetometer_ReadingChanged; Gyroscope.ReadingChanged -= Gyrotometer_ReadingChanged; OrientationSensor.ReadingChanged -= OrientationSensor_ReadingChanged; _instance = null; }
public DeviceStatus stop() { if (_gyroscope != null) { _gyroscope.Stop(); _timer.Stop(); return(DeviceStatus.DEVICE_OK); } else { return(DeviceStatus.DEVICE_ERROR); } }
private void stopButton_Click(object sender, RoutedEventArgs e) { if (accelerometer != null) { // Stop the accelerometer. accelerometer.Stop(); accOutput.Text = "accelerometer stopped."; } if (accelerometer != null) { // Stop the accelerometer. gyroscope.Stop(); gyrOutput.Text = "gyroscope stopped."; } }
public async Task StopTracking() { if (!CrossGeolocator.Current.IsListening) { return; } await CrossGeolocator.Current.StopListeningAsync(); Gyroscope.Stop(); CrossGeolocator.Current.PositionChanged -= PositionChanged; updatePosition = null; }
private void stop_Click(object sender, EventArgs e) { timer.Stop(); if (Accelerometer.IsSupported) { accelSensor.Stop(); } if (Compass.IsSupported) { compassSensor.Stop(); } if (Gyroscope.IsSupported) { gyroSensor.Stop(); } messageBlock.Text = "Press start"; }
private async Task StopRecordingPerform() { if (!IsRecording) { return; } _skipWriting = true; _timer.Change(Timeout.Infinite, Timeout.Infinite); Accelerometer.ReadingChanged -= Accelerometer_ReadingChanged; Accelerometer.Stop(); if (_gyroscopeIsSensing) { Gyroscope.ReadingChanged -= Gyroscope_ReadingChanged; Gyroscope.Stop(); } if (_locationCancellationSource != null) { _locationCancellationSource.Cancel(); _locationCancellationSource.Dispose(); _locationCancellationSource = null; } // Close up and bundle up the writer await _writer.FlushAsync(); lock (_writerLock) { _writer.Dispose(); _writer = null; } await App.StopAudioRecording(); #if !DEBUG Analytics.TrackEvent("Recording.Stop"); #endif IsRecording = false; _skipWriting = false; }
private void Abilities_Disappearing(object sender, EventArgs e) { try { if (Gyroscope.IsMonitoring) { Gyroscope.Stop(); Gyroscope.ReadingChanged -= Gyroscope_ReadingChanged; } } catch { } try { if (Accelerometer.IsMonitoring) { Accelerometer.Stop(); Accelerometer.ShakeDetected -= Accelerometer_ShakeDetected; } } catch { } }
private void appBarButtonPause_Click(object sender, EventArgs e) { int currentIndex = panorama.SelectedIndex; switch (currentIndex) { case 0: if (((bool)IsolatedStorageSettings.ApplicationSettings["LocationConsent"] == true) && (geoTracking)) { geolocator.PositionChanged -= geolocator_PositionChanged; geolocator.StatusChanged -= geolocator_StatusChanged; geolocator = null; geoTracking = false; geoStatusTB.Text = "Detenido."; } break; case 1: if ((accelerometer != null) && (accActive)) { // Detener el acelerometro accActive = false; accelerometer.Stop(); accelerometerStatusTB.Text = "Detenido."; } break; case 2: if ((gyroscope != null) && gyroscope.IsDataValid && gyroActive) { // Detener el giroscopio gyroActive = false; gyroscope.Stop(); timer.Stop(); gyroStatusTB.Text = "Detenido"; } break; } }
private void ApplicationBarIconButton_Click(object sender, EventArgs e) { if (gyroscope != null && gyroscope.IsDataValid) { // Stop data acquisition from the gyroscope. gyroscope.Stop(); timer.Stop(); statusTextBlock.Text = "gyroscope stopped."; } else { if (gyroscope == null) { // Instantiate the Gyroscope. gyroscope = new Gyroscope(); // Specify the desired time between updates. The sensor accepts // intervals in multiples of 20 ms. gyroscope.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20); // The sensor may not support the requested time between updates. // The TimeBetweenUpdates property reflects the actual rate. timeBetweenUpdatesTextBlock.Text = "time between updates: " + gyroscope.TimeBetweenUpdates.TotalMilliseconds + " ms"; gyroscope.CurrentValueChanged += new EventHandler <SensorReadingEventArgs <GyroscopeReading> >(gyroscope_CurrentValueChanged); } try { statusTextBlock.Text = "starting gyroscope."; gyroscope.Start(); timer.Start(); } catch (InvalidOperationException) { statusTextBlock.Text = "unable to start gyroscope."; } } }
private void Button_OnClicked(object sender, EventArgs e) { try { if (Gyroscope.IsMonitoring) { Gyroscope.Stop(); } else { Gyroscope.Start(speed); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device } catch (Exception ex) { // Other error has occurred. } }
public void ToggleGyroscope() { try { if (Gyroscope.IsMonitoring) { Gyroscope.Stop(); } else { Gyroscope.Start(speed); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device } catch (Exception ex) { // Other error has occurred. } }
public async Task Monitor(SensorSpeed sensorSpeed) { if (!TestSupported) { return; } var tcs = new TaskCompletionSource <GyroscopeData>(); Gyroscope.ReadingChanged += Gyroscope_ReadingChanged; Gyroscope.Start(sensorSpeed); void Gyroscope_ReadingChanged(GyroscopeChangedEventArgs e) { tcs.TrySetResult(e.Reading); } var d = await tcs.Task; Gyroscope.Stop(); Gyroscope.ReadingChanged -= Gyroscope_ReadingChanged; }
public static void ToggleGyroscope() { try { if (Gyroscope.IsMonitoring) { Log.Debug("Dev_Gyroscope", "Stop Gyroscope"); Gyroscope.Stop(); } else { Gyroscope.Start(speed); Log.Debug("Dev_Gyroscope", "Start Gyroscope"); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device } catch (Exception ex) { // Other error has occurred } }
public void StartGyroscope(Boolean start) { try { if (start == false) { Gyroscope.Stop(); } else { Gyroscope.Start(speed); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device DisplayAlert("Error", fnsEx.Message, "OK"); } catch (Exception ex) { // Other error has occurred. DisplayAlert("Error", ex.Message, "OK"); } }