public MainPage() { InitializeComponent(); // this.NavigationCacheMode = NavigationCacheMode.Required; //DataEntry.saveAll(); //DataEntry.loadAll(); this.accelSensor = Accelerometer.GetDefault(); if (this.accelSensor != null) this.accelSensor.ReadingChanged += new TypedEventHandler<Accelerometer, AccelerometerReadingChangedEventArgs>(myAccelHandler); this.compSensor = Compass.GetDefault(); if (this.compSensor != null) this.compSensor.ReadingChanged += new TypedEventHandler<Compass, CompassReadingChangedEventArgs>(myCompassHandler); this.gyroSensor = Gyrometer.GetDefault(); if (this.gyroSensor != null) this.gyroSensor.ReadingChanged += new TypedEventHandler<Gyrometer, GyrometerReadingChangedEventArgs>(myGyroHandler); this.incliSensor = Inclinometer.GetDefault(); if (this.incliSensor != null) this.incliSensor.ReadingChanged += new TypedEventHandler<Inclinometer, InclinometerReadingChangedEventArgs>(myIncliHandler); this.lightSensor = LightSensor.GetDefault(); if (this.lightSensor != null) this.lightSensor.ReadingChanged += new TypedEventHandler<LightSensor, LightSensorReadingChangedEventArgs>(myLightHandler); accelX = accelY = accelZ = comp = gyroX = gyroY = gyroZ = incliYaw = incliPitch = incliRoll = light = 0; // Sample code to localize the ApplicationBar //BuildLocalizedApplicationBar(); }
public ActionHelper() { inclinometer = Inclinometer.GetDefault(); inclinometer.ReadingChanged += inclinometer_ReadingChanged; InclinometerState = MagnetometerAccuracy.Unknown; offYaw = 0;offRoll = 0;offPitch = 0; }
private void SetupSensor() { _inclinometer = Sensor.Inclinometer.GetDefault(); if (_inclinometer == null) { // tell user they don't have an inclinometer } }
async void inclinometer_ReadingChanged( Inclinometer sender, InclinometerReadingChangedEventArgs args ) { await Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.Normal, () => { ProjectionImage.RotationX = 90 - args.Reading.PitchDegrees; ProjectionImage.RotationZ = args.Reading.RollDegrees; ProjectionImage.RotationY = -args.Reading.YawDegrees; } ); }
private void SetupSensor() { _inclinometer = Sensor.Inclinometer.GetDefault(); if( _inclinometer == null ) { // tell user they don't have an inclinometer } }
private async void inclinometer_ReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { PitchValue.Text = args.Reading.PitchDegrees.ToString(); RollValue.Text = args.Reading.RollDegrees.ToString(); YawValue.Text = args.Reading.YawDegrees.ToString(); TimeStamp.Text = args.Reading.Timestamp.ToString(); }); }
void OnReadingChanged(Sensor sender, InclinometerReadingChangedEventArgs args) { var handler = changed; if (handler != null) { var value = ConvertToInclination(args.Reading); var e = new InclinometerEventArgs(value); handler.Invoke(this, e); } }
private static Sensor GetSensor() { try { return(Sensor.GetDefault()); } catch { return(null); } }
public XNAInputService() { accelerometer = Accelerometer.GetDefault(); gyrometer = Gyrometer.GetDefault(); inclinometer = Inclinometer.GetDefault(); keyboardState = oldKeyboardState = new KeyboardState(); mouseState = oldMouseState = new MouseState(); oldTouchCollection = touchCollection = new Touch[0]; xboxStates = oldXboxStates = new GamePadState[4]; }
private async void InclinometerOnReadingChanged(Sensor.Inclinometer sender, Sensor.InclinometerReadingChangedEventArgs args) { await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { PitchDegrees = args.Reading.PitchDegrees; RollDegrees = args.Reading.RollDegrees; YawDegrees = args.Reading.YawDegrees; SetupNewLocation(); }); }
public MainPage() { InitializeComponent(); this.DataContext = this; myIncMeter = Inclinometer.GetDefault(); myIncMeter.ReportInterval = myIncMeter.MinimumReportInterval; myAccel = Accelerometer.GetDefault(); myAccel.ReportInterval = myIncMeter.MinimumReportInterval; CompositionTarget.Rendering += CompositionTarget_Rendering; }
private void Inclinometer_ReadingChanged(Windows.Devices.Sensors.Inclinometer sender, Windows.Devices.Sensors.InclinometerReadingChangedEventArgs args) { if (Interlocked.CompareExchange(ref Updating, 1, 0) == 1) { return; } Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { UpdateElementsOnScreen(args.Reading); Interlocked.Exchange(ref Updating, 0); }); }
private void SetupSensor() { _inclinometer = Sensor.Inclinometer.GetDefault(); if (_inclinometer == null) { // tell the user they dont have an inclinometer on the device } else { _lastPitchDegrees = _inclinometer.GetCurrentReading().PitchDegrees; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { inclinometer = Inclinometer.GetDefault(); if (inclinometer != null) { inclinometer.ReadingChanged += inclinometer_ReadingChanged; Data.Visibility = Visibility.Visible; } else { NoSensorMessage.Visibility = Visibility.Visible; } }
public Scenario2_Polling() { this.InitializeComponent(); Sensor = Inclinometer.GetDefaultForRelativeReadings(); if (Sensor == null) { RootPage.NotifyUser("No relative inclinometer found", NotifyType.ErrorMessage); GetDataButton.IsEnabled = false; } else { GetDataButton.IsEnabled = true; } }
/// <summary> /// このページがフレームに表示されるときに呼び出されます。 /// </summary> /// <param name="e">このページにどのように到達したかを説明するイベント データ。Parameter /// プロパティは、通常、ページを構成するために使用します。</param> protected override void OnNavigatedTo(NavigationEventArgs e) { accelerometer = Accelerometer.GetDefault(); if ( accelerometer!= null ) { accelerometer.ReadingChanged += accelerometer_ReadingChanged; } inclinometer = Inclinometer.GetDefault(); if ( inclinometer != null ) { inclinometer.ReadingChanged += inclinometer_ReadingChanged; } compass = Compass.GetDefault(); if ( compass != null ) { compass.ReadingChanged += compass_ReadingChanged; } }
public Scenario1() { this.InitializeComponent(); _inclinometer = Inclinometer.GetDefault(); if (_inclinometer != 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 = _inclinometer.MinimumReportInterval; _desiredReportInterval = minReportInterval > 16 ? minReportInterval : 16; } else { rootPage.NotifyUser("No inclinometer found", NotifyType.StatusMessage); } }
public Scenario1_DataEvents() { this.InitializeComponent(); Sensor = Inclinometer.GetDefaultForRelativeReadings(); if (Sensor != 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 = Sensor.MinimumReportInterval; DesiredReportInterval = minReportInterval > 16 ? minReportInterval : 16; } else { rootPage.NotifyUser("No relative inclinometer found", NotifyType.ErrorMessage); } }
public RehabilitationMode() { this.InitializeComponent(); this.InitializeSound(); _inclinometer = Inclinometer.GetDefault(); if (_inclinometer != 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 = _inclinometer.MinimumReportInterval; _desiredReportInterval = minReportInterval > 300 ? minReportInterval : 300; } else { //rootPage.NotifyUser("No inclinometer found", NotifyType.StatusMessage); System.Diagnostics.Debug.WriteLine("No inclinometer found"); } }
public Log(MainWindow window, bool isBehavior = false) { this.window = window; this.isBehavior = isBehavior; this.statusAnalyzer = new StatusAnalyze(window); logDir = Directory.GetCurrentDirectory() + "\\logs\\" + Config.userName+ Config.startTime.ToString("_MM_dd_HH_mm_ss"); if (!Directory.Exists(logDir)) { Directory.CreateDirectory(logDir); } logList = new List<LogRecord>(); this.accelerometer = Accelerometer.GetDefault(); this.inclinometer = Inclinometer.GetDefault(); //this.inclinometer.ReadingChanged += onInclinometerReadingChanged; this.gyrometer = Gyrometer.GetDefault(); this.orientationSensor = OrientationSensor.GetDefault(); this.compass = Compass.GetDefault(); this.lightsensor = LightSensor.GetDefault(); }
public MainPage() { InitializeComponent(); _locator = new Geolocator(); Loaded += OnControlLoaded; _lightSensor = LightSensor.GetDefault(); if (_lightSensor != null) { //For now we get a base reading to use to compare later _baseReading = _lightSensor.GetCurrentReading(); //Register for the reading change _lightSensor.ReadingChanged += OnLightReadingChanged; } _accelerometerSensor = Accelerometer.GetDefault(); if (_accelerometerSensor != null) { _accelerometerSensor.Shaken += OnShaken; } _compassSensor = Compass.GetDefault(); if (_compassSensor != null) { _compassSensor.ReadingChanged += OnCompassReadingChanged; } _gyroSensor = Gyrometer.GetDefault(); if (_gyroSensor != null) { _gyroSensor.ReadingChanged += OnGyroReadingChanged; } _inclineSensor = Inclinometer.GetDefault(); if (_inclineSensor != null) { _inclineSensor.ReadingChanged += OnInclineReadingChanged; } _orientationSensor = OrientationSensor.GetDefault(); if (_orientationSensor != null) { _orientationSensor.ReadingChanged += OnOrientationReadingChanged; } }
public Scenario2() { this.InitializeComponent(); _inclinometer = Inclinometer.GetDefault(); if (_inclinometer != 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 = _inclinometer.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 inclinometer found", NotifyType.StatusMessage); } }
private void InclinometerReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { if (this.ReadingChanged != null) ReadingChanged(_sensor, args); }
public InclinometerService() : base() { _sensor = Inclinometer.GetDefault(); }
/// <summary> /// send sensor data to server ,depend on different mode. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void inclinometer_ReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { InclinometerReading reading = args.Reading; if (args.Reading.YawAccuracy != InclinometerState) { InclinometerState = args.Reading.YawAccuracy; if (InclinometerStateChanged != null) InclinometerStateChanged(this, EventArgs.Empty); } if (connected && mode == SensorMode.TRACKER) App.comHelper.sendTrack(-(reading.YawDegrees-offYaw), -(reading.RollDegrees-offRoll), -(reading.PitchDegrees-offPitch)); else if (connected && mode == SensorMode.JOYSTICK) App.comHelper.sendAxis((reading.PitchDegrees-offPitch) / 120 + 0.5, -(reading.RollDegrees-offRoll) / 100 + 0.5); else if (mode == SensorMode.CALIBRATION) { offYaw = reading.YawDegrees; offRoll = reading.RollDegrees; offPitch = reading.PitchDegrees; } }
public void Stop() { _inclinometer = null; }
public void myIncliHandler(Inclinometer i, InclinometerReadingChangedEventArgs e) { Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { this.value_incli_yaw.Text = e.Reading.YawDegrees.ToString("0.00"); this.incliYaw = e.Reading.YawDegrees; this.value_incli_pitch.Text = e.Reading.PitchDegrees.ToString("0.00"); this.incliPitch = e.Reading.PitchDegrees; this.value_incli_roll.Text = e.Reading.RollDegrees.ToString("0.00"); this.incliRoll = e.Reading.RollDegrees; checkTimeToLog(); } ); }
/// <summary> /// inclinometer handler /// </summary> /// <param name="sender"></param> /// <param name="args"></param> async void InclinometerReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { InclinometerReading reading = args.Reading; var pitchDouble = reading.PitchDegrees; var rollDouble = reading.RollDegrees; var yawDouble = reading.YawDegrees; int pitch = Convert.ToInt32(pitchDouble); int roll = Convert.ToInt32(rollDouble); int yaw = Convert.ToInt32(yawDouble); //Pitch.Text = pitch.ToString(); //Roll.Text = roll.ToString(); //Yaw.Text = yaw.ToString(); //Vector.Text = GetCameraViewDirection(pitch, roll, yaw).ToString(); DirectionTextblock.Text = GetCameraViewDirection(pitch, roll, yaw).ToString(); }); }
public void Start() { _inclinometer = Inclinometer.GetDefault(); }
void _inclinometer_ReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { try { InclinometerReading reading = args.Reading; if (reading != null) { SensorEventArgs sensorArgs = new SensorEventArgs(reading.RollDegrees); if (SensorReadingChanged != null) { SensorReadingChanged(sender, sensorArgs); } } } catch (Exception) { _inclinometerEnabled = false; } _inclinometerChecked = true; }
/// <summary> /// MainPage constructor /// </summary> public MainPage() { this.InitializeComponent(); _inputProcessor = new SIUC311.Manipulations.InputProcessor(ReportPopupGrid, null); // This is a static public property that will allow downstream pages to get // a handle to the MainPage instance in order to call methods that are in this class. Current = this; // Setup SetWindowsUser(); SetDNSDomain(); RefreshQueue(); InitHeadings(); InitRadioButtons(); if (haveInternetAccess = CheckForInternet()) { //NotifyUser("Internet.", NotifyType.ReportMessage); } else { //NotifyUser("No internet.", NotifyType.ReportMessage); } appSettings = ApplicationData.Current.LocalSettings.Values; _cd = Window.Current.CoreWindow.Dispatcher; _geolocatorForTracker = new Geolocator(); // May not need all three. Just synchronize access to one. _geolocatorForRequest = new Geolocator(); _geolocatorForMap = new Geolocator(); _compass = Compass.GetDefault(); // Get the default compass object _inclinometer = Inclinometer.GetDefault(); // Get the default inlinometer object _locationIcon10m = new LocationIcon10m(); _locationIcon100m = new LocationIcon100m(); _locationIcon2000m = new LocationIcon2000m(); // Assign an event handler for the compass reading-changed event if (_compass != null) { // Establish the report interval for all scenarios uint minReportInterval = _compass.MinimumReportInterval; uint reportInterval = minReportInterval > 16 ? minReportInterval : 16; _compass.ReportInterval = reportInterval; _compass.ReadingChanged += new TypedEventHandler<Compass, CompassReadingChangedEventArgs>(CompassReadingChanged); } else { DirectionTextblock.Text = "No compass"; } // Assign an event handler for the inclinometer reading-changed event if (_inclinometer != null) { // Establish the report interval for all scenarios uint minReportInterval = _inclinometer.MinimumReportInterval; uint reportInterval = minReportInterval > 16 ? minReportInterval : 16; _inclinometer.ReportInterval = reportInterval; // Establish the event handler _inclinometer.ReadingChanged += new TypedEventHandler<Inclinometer, InclinometerReadingChangedEventArgs>(InclinometerReadingChanged); } else { DirectionTextblock.Text = "No inclinometer"; } Application.Current.Suspending += (sender, args) => OnSuspending(); Application.Current.Resuming += (sender, o) => OnResuming(); Window.Current.VisibilityChanged += Current_VisibilityChanged; TitleGrid.Background = new SolidColorBrush(Color.FromArgb(255, 102, 0, 0)); Map.MapType = MapType.Aerial; }
async void MainPage_ReadingChanged( Inclinometer sender, InclinometerReadingChangedEventArgs args ) { await Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => { TextInclinometer.Text = string.Format( @"Inclinometer : P={0} R={1} Y={2}", args.Reading.PitchDegrees, args.Reading.RollDegrees, args.Reading.YawDegrees ); } ); }
private void OnInclineReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs args) { }
public void Run(IBackgroundTaskInstance taskInstance) { ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; DeviceWatcherTriggerDetails triggerDetails = (DeviceWatcherTriggerDetails)taskInstance.TriggerDetails; bool surfaceKeyboardAttached = false; int numKeyboardsDetected = 0; string lastID = ""; foreach (DeviceWatcherEvent e in triggerDetails.DeviceWatcherEvents) { switch (e.Kind) { case DeviceWatcherEventKind.Add: //Debug.WriteLine("Add: " + e.DeviceInformation.Id); if ("Surface Keyboard".Equals(e.DeviceInformation.Name)) { //Surface Keyboard being attached //Reading sensor data to determine displays Windows.Devices.Sensors.Inclinometer _inclinometer = Inclinometer.GetDefault(); if (_inclinometer != null) { Debug.WriteLine("Sensorwert: " + _inclinometer.GetCurrentReading().PitchDegrees); settings.Values["pitch"] = _inclinometer.GetCurrentReading().PitchDegrees; if (_inclinometer.GetCurrentReading().PitchDegrees < 20) { settings.Values["surfaceMode"] = "tablet"; sendMessage(); } else { settings.Values["surfaceMode"] = "desktop"; sendMessage(); } } numKeyboardsDetected++; lastID = e.DeviceInformation.Id; //UPDATE. [System.Devices.InterfaceEnabled, True] //surfaceKeyboardAttached = true; } break; case DeviceWatcherEventKind.Update: //Debug.WriteLine("Update: " + e.DeviceInformationUpdate.Id); if (settings.Values["id"] != null) { if (settings.Values["id"].Equals(e.DeviceInformationUpdate.Id)) { Debug.WriteLine("Surface keyboard detached or attached"); surfaceKeyboardAttached = true; } } //Debug.WriteLine("UPDATE. " + string.Join(",", e.DeviceInformationUpdate.Properties.ToList())); break; case DeviceWatcherEventKind.Remove: Debug.WriteLine("Remove: " + e.DeviceInformationUpdate.Id); break; } } ; if (numKeyboardsDetected == 1) { settings.Values["id"] = lastID; } settings.Values["keyboardStatus"] = surfaceKeyboardAttached; }
private void SetupInclinometer() { _inclinometer = Inclinometer.GetDefault(); if (_inclinometer != 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 = _inclinometer.MinimumReportInterval; _desiredReportInterval = minReportInterval > 16 ? minReportInterval : 16; // Establish the report interval. _inclinometer.ReportInterval = _desiredReportInterval; // Whenever the app is not present... Window.Current.VisibilityChanged += OnWindowVisibilityChanged; } }
private async void OnInclinometerReadingChanged(Inclinometer sender, InclinometerReadingChangedEventArgs e) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { _reading.InsertVector3("Offset", new Vector3(e.Reading.RollDegrees, e.Reading.PitchDegrees, 0.0f)); }); }