// Constructor public MainPage() { InitializeComponent(); _engine = new Engine(); _engine.ghostCreated += new Engine.GhostCreated(ghostCreated); _engine.worldObjectCreated += new Engine.WorldObjectCreated(worldObjectCreated); _engine.worldObjectRemoved += new Engine.WorldObjectRemoved(worldObjectRemoved); _engine.ghostsMoved += new Engine.GhostsMoved(ghostsMoved); _engine.gameStarted += new Engine.GameStarted(gameStarted); _engine.gameOver += new Engine.GameOver(gameOver); //_engine.Player.Position = new GeoCoordinate(0, 0); _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); _watcher.MovementThreshold = 0; _watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); _watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); if (Compass.IsSupported) { _compass = new Compass(); _compass.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<CompassReading>>(compassChanged); _compass.Start(); } gpsHideAnimation.Completed += new EventHandler(gpsHideAnimation_Completed); rect.Visibility = Visibility.Collapsed; }
public MainPage() { this.DataContext = this; InitializeComponent(); this.WarningBlock1.Visibility = System.Windows.Visibility.Collapsed; this.WarningBlock2.Visibility = System.Windows.Visibility.Collapsed; this.WarningBlock3.Visibility = System.Windows.Visibility.Collapsed; this.WarningBlock4.Visibility = System.Windows.Visibility.Collapsed; m_fValue1 = 0.01f; m_fValue2 = 0.03f; m_fValue3 = 0.05f; m_fValue4 = 0.06f; m_fValue5 = 0.08f; m_fValue6 = 0.1f; m_fValue7 = 0.2f; m_fValue8 = 0.3f; m_fValue9 = 0.4f; m_fValue10 = 0.5f; // time interval m_fInterval = 120; if (Compass.IsSupported) { m_oCompass = new Compass(); m_oCompass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(m_fInterval); m_oCompass.CurrentValueChanged += m_oCompass_CurrentValueChanged; m_oCompass.Start(); } }
public bool SearchOctant( Map map, Compass compass, int start, SearchDirection direction, Tour tour ) { SearchSet oc = m_Octants[(int)compass]; int incr = direction == SearchDirection.Outwards ? 1 : -1; for( int i=start;;i+=incr) { if( i < 0 || i > m_Radius ) return false; EntrySet entrySet = oc.GetEntrySet( i ); if( entrySet == null ) continue; List<Entry> entries = entrySet.Entries; foreach( OctantEntry entry in entries ) { if( tour( map, entry.X, entry.Y ) ) return true; } return false; } }
public void BorderBlock() { InitItem(new Vector2(100, 100), null); InitFlat(true); Moving1.OnHitBorder += (i, d) => { BorderCount++; BorderDirection = d; }; // Obere Kante Move(new Vector2(100, 3), new Vector2(102, 2), Angle.UpperRight); CheckBorderEvent(1, Compass.North); Move(new Vector2(100, 3), new Vector2(98, 2), Angle.UpperLeft); CheckBorderEvent(1, Compass.North); // untere Kante Move(new Vector2(100, 197), new Vector2(102, 198), Angle.LowerRight); CheckBorderEvent(1, Compass.South); Move(new Vector2(100, 197), new Vector2(98, 198), Angle.LowerLeft); CheckBorderEvent(1, Compass.South); // linke Kante Move(new Vector2(3, 100), new Vector2(2, 102), Angle.LowerLeft); CheckBorderEvent(1, Compass.West); Move(new Vector2(3, 100), new Vector2(2, 98), Angle.UpperLeft); CheckBorderEvent(1, Compass.West); // rechte Kante Move(new Vector2(197, 100), new Vector2(198, 102), Angle.LowerRight); CheckBorderEvent(1, Compass.East); Move(new Vector2(197, 100), new Vector2(198, 98), Angle.UpperRight); CheckBorderEvent(1, Compass.East); }
public void CalBomb(int num, Compass compass) { Vector3 pos = new Vector3(transform.position.x, -0.3f, transform.position.z); GameObject bomb = nc.CreateGameObject(bombThrow, pos, transform.rotation); //GameObject bomb = Instantiate(bombThrow, new Vector3(transform.position.x, -0.3f, transform.position.z), transform.rotation) as GameObject; bomb.GetComponent<BombAnimation>().Play(num, compass, GamePlay.myPlayer); }
// Constructor public MainPage() { InitializeComponent(); // Sample code to localize the ApplicationBar //BuildLocalizedApplicationBar(); timer = new DispatcherTimer(); timer.Tick += timer_Tick; timer.Interval = TimeSpan.FromMilliseconds(66); if (Accelerometer.IsSupported) { accelSensor = new Accelerometer(); accelSensor.TimeBetweenUpdates = TimeSpan.FromMilliseconds(66); } if (Compass.IsSupported) { compassSensor = new Compass(); compassSensor.TimeBetweenUpdates = TimeSpan.FromMilliseconds(66); compassSensor.Calibrate += compassSensor_Calibrate; } if (Gyroscope.IsSupported) { gyroSensor = new Gyroscope(); gyroSensor.TimeBetweenUpdates = TimeSpan.FromMilliseconds(66); } }
// returns whether the direction of the tile is an opening or a wall public Path opening (Compass direction) { // CROSS TILE if (type == Shape.CROSS) return Path.OPEN; // DEAD END TILE // if orientations match, path is open // otherwise path is wall if (type == Shape.DEAD) return (orientation == direction) ? Path.OPEN : Path.WALL; // STRAIGHT TILE if (type == Shape.STRAIGHT) { // straight tiles can only have a dir of // SOUTH or WEST // reorient search direction to match orientation of if (direction == Compass.EAST) direction = Compass.WEST; else if (direction == Compass.NORTH) direction = Compass.SOUTH; // if orientations match, path is open // otherwise path is wall return (direction == orientation) ? Path.OPEN : Path.WALL; } return Path.OPEN; }
// Use this for initialization void Start() { // Enable the compass. //Input.location.Start(); compass = Input.compass; compass.enabled = true; transform.Rotate(0,45,0); }
void CompassCancel() { if (_compass != null) { _compass.Stop(); _compass.Dispose(); _compass = null; } }
public Tile(Shape t, Transform trans) { type = t; transform = trans; // reduce euler angle to integral value and convert to Compass type if (trans != null) orientation = (Compass)(Mathf.Round (transform.eulerAngles.y / 90f) % 4); }
public void Play (int getNum, Compass getCompass, Player player) { if(GamePlay.IsSingle) { _Play(getNum,(int)getCompass, player.getNet, player.damageNum); }else{ networkView.RPC("_Play",RPCMode.All,getNum,(int)getCompass, player.getNet, player.damageNum); } }
public TargetingSystem(Boundaries boundaries, Coordinate coordinate, Compass direction, int speed) { Target = new Coordinate(coordinate); Direction = direction; Hits = 1; Speed = speed; _boundaries = boundaries; _start = new Coordinate(coordinate); }
public Tile (Shape t, Transform trans) { type = t; transform = trans; // reduce euler angle to integral value and convert to Compass type orientation = (Compass)(Mathf.Round (transform.eulerAngles.y / 90f) % 4); // Debug.Log ("Tile pos: " + tileX + ", " + tileZ); }
public BoeingPFD() { bmp = new Bitmap(DisplaySize.Width,DisplaySize.Height); this.g = Graphics.FromImage(bmp); g.SmoothingMode = SmoothingMode.AntiAlias; compass = new Compass(CompassSize); alt = new Altimeter(AltimeterSize); ah = new ArtificialHorizon(ArtificialHorizonSize); ai = new AirspeedIndicator(AirspeedIndicatorSize); vsi = new VerticalSpeedIndicator(VerticalSpeedIndicatorSize); }
public LocationViewModel() { this._compass = new Compass(); if (Compass.IsSupported) { this.UseCompass = false; } else { this.UseCompass = false; } }
private void ApplicationBarIconButton_Click(object sender, EventArgs e) { if (compass != null && compass.IsDataValid) { // Stop data acquisition from the compass. compass.Stop(); timer.Stop(); statusTextBlock.Text = "compass stopped."; // Detect compass axis accelerometer.Stop(); } else { if (compass == null) { // Instantiate the compass. compass = new Compass(); // Specify the desired time between updates. The sensor accepts // intervals in multiples of 20 ms. compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20); // The sensor may not support the requested time between updates. // The TimeBetweenUpdates property reflects the actual rate. timeBetweenUpdatesTextBlock.Text = compass.TimeBetweenUpdates.TotalMilliseconds + " ms"; compass.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<CompassReading>>(compass_CurrentValueChanged); compass.Calibrate += new EventHandler<CalibrationEventArgs>(compass_Calibrate); } try { statusTextBlock.Text = "starting compass."; compass.Start(); timer.Start(); // Start accelerometer for detecting compass axis accelerometer = new Accelerometer(); accelerometer.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<AccelerometerReading>>(accelerometer_CurrentValueChanged); accelerometer.Start(); } catch (InvalidOperationException) { statusTextBlock.Text = "unable to start compass."; } } }
public CompassSamplePage() { InitializeComponent(); // not all the devices support compass if(Compass.IsSupported) { _c = new Compass(); _c.CurrentValueChanged += CompassCurrentValueChanged; _c.Start(); } }
private static ICell GoOrientation(IMaze maze, Compass direction) { switch (direction) { case Compass.North: return maze.GoNorth(); case Compass.East: return maze.GoEast(); case Compass.South: return maze.GoSouth(); default: return maze.GoWest(); } }
private TankState() { _fuel = API.CurrentFuel(); _targetInSight = API.IdentifyTarget(); _currentPosition = TankAPI.CurrentPosition; _cardinalDirection = TankAPI.CardinalDirection; _distances = new Dictionary<Direction, int> { {Direction.Front, API.LidarFront()}, {Direction.Back, API.LidarBack()}, {Direction.Left, API.LidarLeft()}, {Direction.Right, API.LidarRight()} }; }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); if (!Compass.IsSupported) { MessageBox.Show("Dein Gerät unterstützt keinen Kompass :("); return; } compass = new Compass(); compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(500); compass.CurrentValueChanged += compass_CurrentValueChanged; compass.Calibrate += compass_Calibrate; compass.Start(); }
public void BorderDropEast() { InitItem(new Vector2(100, 100), null); InitFlat(false); Moving1.OnHitBorder += (i, d) => { BorderCount++; BorderDirection = d; }; // rechte Kante Move(new Vector2(199, 100), new Vector2(201, 102), Angle.LowerRight); CheckBorderEvent(0); Assert.AreEqual(0, Item1.Id); }
public void Awake() { #if UNITY_ANDROID compassEnabled = true; #else compassEnabled = false; #endif if (compassEnabled) { compass = Input.compass; compass.enabled = true; } else { #if UNITY_EDITOR Debug.Log("NO COMPASS"); #endif } originalHeading = transform.rotation.eulerAngles.y; }
public string ReturnHeading() { if (!Compass.IsSupported) { throw new Exception("Could not load Compass"); } if (_compass == null) { _compass = new Compass(); _compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(100); _compass.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<CompassReading>>(_compass_CurrentValueChanged); try { _compass.Start(); } catch (InvalidOperationException e) { if (_compass != null) { _compass.Dispose(); _compass = null; } throw new Exception("Could not initiate compass readings", e); } } string trueHeading = null; if (_compass != null) { // block on the search until the async result return lock (_locker) { while (_trueHeading == null) { Monitor.Pulse(_locker); } trueHeading = _trueHeading; _trueHeading = null; } } return trueHeading; }
[RPC]private void _Play (int getNum, int getCompass, NetworkPlayer net, int damage) { num = getNum; compass = (Compass)getCompass; checkPlay = true; target = transform.position; if(compass == Compass.north) target.z += num; else if(compass == Compass.east) target.x += num; else if(compass == Compass.west) target.x -= num; else target.z -= num; if(num == 2) oneTime = true; else max = num; foreach(Player p in MultiPlayer.playerList) { if(p.getNet == net){ player = p; break; } } this.damage = damage; }
private void Btn_Brujula_Click(object sender, RoutedEventArgs e) { if(Compass.IsSupported) { if (!vBrujula) { objBrujula = new Compass(); objBrujula.TimeBetweenUpdates = TimeSpan.FromMilliseconds(100); objBrujula.CurrentValueChanged += objBrujula_CurrentValueChanged; objBrujula.Start(); Btn_Brujula.Content = "Apagar Brújula"; } else { vBrujula = false; Btn_Brujula.Content = "Iniciar Brújula"; objBrujula.Stop(); } } else { MessageBox.Show("El dispositivo no tiene brújula","Brújula", MessageBoxButton.OK); } }
protected override void InitInstanceOverride() { // Creates and starts the location service. _GeoWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); _GeoWatcher.StatusChanged += new EventHandler <GeoPositionStatusChangedEventArgs>(GeoWatcher_StatusChanged); _GeoWatcher.PositionChanged += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(GeoWatcher_PositionChanged); _GeoWatcher.Start(); // Creates and starts the compass service. if (Compass.IsSupported) { _Compass = new Compass(); _Compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(250); _Compass.CurrentValueChanged += new EventHandler <SensorReadingEventArgs <CompassReading> >(Compass_CurrentValueChanged); _Compass.Calibrate += new EventHandler <CalibrationEventArgs>(OnCompassCalibrate); //_Compass.Start(); } // Deploys handlers. RegisterCoreEventHandlers(); }
public void Set(Compass direction, T value) { switch (direction) { case Compass.North: North = value; break; case Compass.East: East = value; break; case Compass.South: South = value; break; case Compass.West: West = value; break; } }
/// <summary> /// Creates a coordinates object. Gets a Compass enum and sets ValueVectorAccordingly. /// (1,1) SouthEast, (-1,1) SouthWest, (-1,-1) NorthWest, (1,-1) NorthEast. /// </summary> /// <param name="dir"></param> public Coordinates(Compass dir) { VecDir = dir; if (dir.Equals(Compass.SouthEast)) { ValueVector = new Vector2(1, 1); } else if (dir.Equals(Compass.SouthWest)) { ValueVector = new Vector2(-1, 1); } else if (dir.Equals(Compass.NorthWest)) { ValueVector = new Vector2(-1, -1); } else if (dir.Equals(Compass.NorthEast)) { ValueVector = new Vector2(1, -1); } }
private void OnGetDataButtonClick(object sender, RoutedEventArgs e) { var compass = Compass.GetDefault(); if (compass == null) { this.DefaultViewModel["CompassData"] = new { MagneticNorth = "Compass not found", TrueNorth = "Compass not found", Accuracy = "Compass not found" }; } else { var reading = compass.GetCurrentReading(); compass.ReadingChanged += OnCompassReadingChanged; SetCompassReading(reading); } }
protected async override void OnAppearing() { base.OnAppearing(); var hasPermission = await Utils.CheckPermissions(Permission.Location); if (!hasPermission) { return; } // start compass Compass.Start(SensorSpeed.UI); Compass.ReadingChanged += Compass_ReadingChanged; // start position var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 1; locator.PositionChanged += Locator_PositionChanged; await locator.StartListeningAsync(new TimeSpan(1), 1, true); }
public virtual void helm() { CombatWaypoint wpt = this.waypointTarget; Compass angletoWaypoint = new Compass(this.cmbt_loc, this.waypointTarget.cmbt_loc); //relitive to me. Tuple <Compass, bool?> nav = Nav(angletoWaypoint); Compass angletoturn = nav.Item1; bool? thrustToWaypoint = nav.Item2; //PointXd vectortowaypoint = this.cmbt_loc - this.waypointTarget.cmbt_loc; Fix16 acceleration = maxfowardThrust * cmbt_mass; Fix16 startV = NMath.distance(cmbt_vel, wpt.cmbt_vel); Fix16 distance = NMath.distance(cmbt_loc, wpt.cmbt_loc); // XXX - why is distance between (0,0,0) and (0,1000,0) equal to 181 in Combat_Helm0 test?! Fix16[] ttt = NMath.quadratic(acceleration, startV, distance); turnship(angletoturn, angletoWaypoint); thrustship(angletoturn, true); }
private static long Input() { var attempt = Attempts.Pop().Where(dir => !Visited.Contains(Compass.PositionAfterMovement(droidPosition, dir))).ToList(); if (attempt.Count == 0) { Backtracking = true; Attempt = Compass.Opposite(EnteredFrom[droidPosition]); } else { Backtracking = false; Attempt = attempt[0]; attempt.RemoveAt(0); Attempts.Push(attempt); } var backTrackingString = Backtracking ? " (BACKTRACKING)" : ""; Day15Debug.Write($"({droidPosition.x}),{droidPosition.y}) - {Compass.Name(Attempt)}{backTrackingString} : "); return(Compass.ToLong(Attempt)); }
public void Take(Instruction instruction) { switch (instruction.Action) { case 'L': Direction = Compass.TurnLeft(instruction.Value, Direction); break; case 'R': Direction = Compass.TurnRight(instruction.Value, Direction); break; case 'F': HandleDirection(Direction, instruction.Value); break; default: HandleDirection(instruction.Action, instruction.Value); break; } }
public MapPage(IGeocoderService geocoderService, IPositionCalculatorService calculatorService, PlacesDataStore dataStore) { _geocoderService = geocoderService; _dataStore = dataStore; _calculatorService = calculatorService; addresses = _dataStore.GetAllAddresses().ToList(); if (!Compass.IsMonitoring) { Compass.Start(SensorSpeed.UI, true); } Compass.ReadingChanged += Compass_ReadingChanged; Title = "Map"; Position position = new Position(50.450225, 30.461032); MapSpan mapSpan = new MapSpan(position, 0.01, 0.01); map = new Map(); map.IsShowingUser = true; map.HasScrollEnabled = true; map.HasZoomEnabled = true; map.MoveToRegion(mapSpan); start = new Button { Text = "Start" }; start.IsEnabled = true; go = new Button { Text = "Go" }; go.IsEnabled = false; start.Clicked += Start_Clicked; Content = new StackLayout { Margin = new Thickness(10), Children = { map } }; }
/// <summary> /// Resolves the sensor information. /// </summary> private void ResolveSensorInfo() { if (Windows.Devices.Sensors.Accelerometer.GetDefault() != null) { HasAccelerometerSensor = true; } if (Compass.GetDefault() != null) { HasCompass = true; } try { if (Gyrometer.GetDefault() != null) { HasGyroscopeSensor = true; } } catch (Exception e) { Debug.WriteLine(e.ToString()); } if (Windows.Devices.Sensors.Inclinometer.GetDefault() != null) { HasInclinometerSensor = true; } if (Windows.Devices.Sensors.OrientationSensor.GetDefault() != null) { HasOrientationSensor = true; } // ProximityDevice is NFC if (ProximityDevice.GetDefault() != null) { HasProximitySensor = true; } }
public override void ViewDidLoad() { base.ViewDidLoad(); mapView = new MapView() { Map = new Map(Basemap.CreateLightGrayCanvasVector()), TranslatesAutoresizingMaskIntoConstraints = false }; this.View.AddSubview(mapView); compass = new Compass() { GeoView = mapView, AutoHide = false, TranslatesAutoresizingMaskIntoConstraints = false }; this.View.AddSubview(compass); slider = new UISlider() { TranslatesAutoresizingMaskIntoConstraints = false, MaxValue = 100, MinValue = 10, Value = 50 }; this.View.AddSubview(slider); slider.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor).Active = true; slider.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor, 20).Active = true; slider.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor, -20).Active = true; mapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active = true; mapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true; mapView.TopAnchor.ConstraintEqualTo(slider.BottomAnchor).Active = true; mapView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor).Active = true; compass.TrailingAnchor.ConstraintEqualTo(mapView.TrailingAnchor, -20).Active = true; compass.TopAnchor.ConstraintEqualTo(mapView.TopAnchor, 20).Active = true; (widthConstraint = compass.WidthAnchor.ConstraintEqualTo(50)).Active = true; (heightConstraint = compass.HeightAnchor.ConstraintEqualTo(50)).Active = true; }
static Compass UserDirection(Compass heading, int difficulty) { if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); // Console.WriteLine("Read key: " + key.KeyChar); switch (key.KeyChar.ToString()) { case ("w"): if (heading != Compass.South) { heading = Compass.North; } break; case ("a"): if (heading != Compass.East) { heading = Compass.West; } break; case ("s"): if (heading != Compass.North) { heading = Compass.South; } break; case ("d"): if (heading != Compass.West) { heading = Compass.East; } break; } } Thread.Sleep(500 / difficulty); return(heading); }
void CompassStart() { if (!Compass.IsSupported) { Deployment.Current.Dispatcher.BeginInvoke(() => { this.webBrowser1.InvokeScript("eval", "compass.onCompassFail('Compass not available.')"); }); return; } if (_compass == null) { _compass = new Compass(); _compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(100); _compass.CurrentValueChanged += new EventHandler <SensorReadingEventArgs <CompassReading> >(_compass_CurrentValueChanged); try { _compass.Start(); } catch (InvalidOperationException) { this.webBrowser1.InvokeScript("eval", "compass.onCompassFail('Could not start the compass.')"); } } }
public DeviceMotionService() { try { accelerometer = Accelerometer.GetDefault(); gyrometer = Gyrometer.GetDefault(); compass = Compass.GetDefault(); magnetometer = Magnetometer.GetDefault(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } sensorStatus = new Dictionary <MotionSensorType, bool>() { { MotionSensorType.Accelerometer, false }, { MotionSensorType.Gyroscope, false }, { MotionSensorType.Magnetometer, false }, { MotionSensorType.Compass, false } }; }
void Start() { #region Inicialização e verificação de permissões instance = this; northCalibrated = false; compassService = UnityEngine.Input.compass; compassService.enabled = true; mainCamera = GetComponentInChildren <Camera>(); if (!Permission.HasUserAuthorizedPermission(Permission.FineLocation)) { Permission.RequestUserPermission(Permission.FineLocation); } #endregion locationService = UnityEngine.Input.location; locationService.Start(10, 0.01f); nextTime = Time.time; }
public Scenario2() { this.InitializeComponent(); _compass = Compass.GetDefault(); if (_compass != 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 = _compass.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 compass found", NotifyType.StatusMessage); } }
public void ToggleCompass(string obj) { try { if (Compass.IsMonitoring) { Compass.Stop(); } else { Compass.Start(speed); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device. } catch (Exception ex) { // Other error has occurred. } }
private void ConfigureCompass() { // Get the reference to the sensor and see if it is available _compass = Compass.GetDefault(); if (_compass == null) { return; } _sensorSettings.IsCompassAvailable = true; // Set the minimum report interval. Care must be taken to ensure // it is not set to a value smaller than the device minimum var minInterval = _compass.MinimumReportInterval; _compass.ReportInterval = Math.Max(_sensorSettings.SensorReportInterval, minInterval); _compass.ReadingChanged += CompassOnReadingChanged; // Read the initial sensor value _sensorSettings.LatestCompassReading = _compass.GetCurrentReading(); }
public void ToggleCompass() { try { if (Compass.IsMonitoring) { Compass.Stop(); } else { Compass.Start(speed); } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device } catch (Exception ex) { // Some other exception has occurred } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (Fixed.IsPhone) { HardwareButtons.BackPressed += HardwareButtons_BackPressed; } else { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; SystemNavigationManager.GetForCurrentView().BackRequested += (s, args) => { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; Frame.Navigate(typeof(Home)); }; } ucitano = false; _compass = Windows.Devices.Sensors.Compass.GetDefault(); if (_compass == null) { NoCompass_Grid.Visibility = Visibility.Visible; return; } else { _compass.ReadingChanged += _compass_ReadingChanged; try { Postavi_Stranicu(Memory.location, Data.data.coordinates[Memory.location].ime, Data.data.coordinates[Memory.location].latitude, Data.data.coordinates[Memory.location].longitude); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Greška pri postavljanju stranice " + " (" + ex.Message + ")"); } } }
public MovementSource() { Position = GeoCoordinate.Unknown; compass = Compass.GetDefault(); if (compass != null) { compass.ReadingChanged += Compass_ReadingChanged; } if (!DesignerProperties.IsInDesignTool) // Cider hates GeoCoordinateWatcher { #if DEBUG watcher = new FakeGeoPositionWatcher(0.0, 0.0); #else watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); #endif watcher.PositionChanged += Watcher_PositionChanged; watcher.StatusChanged += Watcher_StatusChanged; watcher.Start(); } }
public MapPage(ISample sample, Func <MapView?, MapClickedEventArgs, bool>?c = null) { InitializeComponent(); Refs.AddRef(this); Refs.AddRef(mapView); Title = sample.Name; mapView.RotationLock = false; mapView.UnSnapRotationDegrees = 30; mapView.ReSnapRotationDegrees = 5; mapView.PinClicked += OnPinClicked; mapView.MapClicked += OnMapClicked; Compass.ReadingChanged += Compass_ReadingChanged; mapView.MyLocationLayer.UpdateMyLocation(new UI.Forms.Position()); mapView.MyLocationLayer.CalloutText = "My location!\n"; mapView.MyLocationLayer.Clicked += MyLocationClicked; mapView.Info += MapView_Info; mapView.Renderer.WidgetRenders[typeof(CustomWidget.CustomWidget)] = new CustomWidgetSkiaRenderer(); Task.Run(() => StartGPS()); try { if (!Compass.IsMonitoring) { Compass.Start(SensorSpeed.Default); } } catch (Exception) { } sample.Setup(mapView); Clicker = c; }
protected void thrustship(Compass angletoturn, bool?thrustToWaypoint) { this.cmbt_thrust.ZEROIZE(); strafeship(thrustToWaypoint); //main foward thrust - still needs some work, ie it doesnt know when to turn it off when close to a waypoint. Fix16 thrustby = (Fix16)0; if (thrustToWaypoint != null) { if (angletoturn.Degrees >= (Fix16)0 && angletoturn.Degrees < (Fix16)90) { thrustby = (Fix16)this.maxfowardThrust * GetThrustEfficiency(angletoturn); } else if (angletoturn.Degrees > (Fix16)270 && angletoturn.Degrees < (Fix16)360) { Compass angle = new Compass((Fix16)360 - angletoturn.Degrees); angle.normalize(); thrustby = (Fix16)this.maxfowardThrust * GetThrustEfficiency(angletoturn); } //PointXd fowardthrust = new PointXd(comObj.cmbt_face + thrustby); PointXd fowardthrust = new PointXd(Trig.sides_ab(thrustby, this.cmbt_head.Radians)); this.cmbt_thrust += fowardthrust; } else { //match velocity with waypoint PointXd wayptvel = this.waypointTarget.cmbt_vel; PointXd ourvel = this.cmbt_vel; thrustby = (Fix16)this.maxfowardThrust * GetThrustEfficiency(angletoturn); PointXd fowardthrust = new PointXd(Trig.intermediatePoint(ourvel, wayptvel, thrustby)); this.cmbt_thrust += fowardthrust; } #if DEBUG Console.WriteLine("Thrust By " + thrustby); #endif }
public FindPathGameScreen(IAI tankAI) { BaseGame.CoordinMgr.SetScreenViewRect(scrnRect); camera = new Camera(2, cameraStartPos, 0f); compass = new Compass(new Vector2(740, 540)); camera.Enable(); InitialBackGround(); InitialScene(); InitialAI(tankAI); camera.Focus(tank, true); GameTimer timer = new GameTimer(5, delegate() { TextEffectMgr.AddRiseFadeInScrnCoordin("test FadeUp in Scrn!", new Vector2(100, 100), 1f, Color.Black, LayerDepth.Text, GameFonts.Lucida, 300, 0.5f); TextEffectMgr.AddRiseFade("test FadeUp in Login!", new Vector2(100, 100), 1f, Color.White, LayerDepth.Text, GameFonts.Lucida, 300, 0.5f); }); }
void Start() { this._sensingData.ID = "charlie"; this._sensingData.DeviceName = DeviceInfo.Name; if (!Compass.IsMonitoring) { Compass.ReadingChanged += Compass_ReadingChanged; Compass.Start(SensorSpeed.Fastest); } if (!Accelerometer.IsMonitoring) { Accelerometer.ReadingChanged += Accelerometer_Essentials_ReadingChanged; Accelerometer.Start(SensorSpeed.Fastest); } if (!Gyroscope.IsMonitoring) { Gyroscope.ReadingChanged += Gyroscope_ReadingChanged; Gyroscope.Start(SensorSpeed.Fastest); } if (!Magnetometer.IsMonitoring) { Magnetometer.ReadingChanged += Magnetometer_ReadingChanged; Magnetometer.Start(SensorSpeed.Fastest); } // device-specific sensor readings if (Device.RuntimePlatform.Equals((Device.Android))) { MessagingCenter.Subscribe <Sensors.Android.LinearAcceleration>(this, Sensors.Android.SubscriberMessage.LinearAcceleration, (linear_acceleration) => { this.LinearAccelerometer_Android_ReadingChanged(linear_acceleration); }); } }
public bool SearchOctant( Map map, Compass compass, int start, SearchDirection direction, Tour tour ) { SearchSet oc = m_Octants[(int)compass]; int incr = direction == SearchDirection.Outwards ? 1 : -1; for (int i = start;; i += incr) { if (i < 0 || i > m_Radius) { return(false); } EntrySet entrySet = oc.GetEntrySet(i); if (entrySet == null) { continue; } List <Entry> entries = entrySet.Entries; foreach (OctantEntry entry in entries) { if (tour(map, entry.X, entry.Y)) { return(true); } } return(false); } }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); try { await StartCamera(); _orientationSensor = SimpleOrientationSensor.GetDefault(); if (_orientationSensor != null) { _orientationSensor.OrientationChanged += SimpleOrientationSensorReadingChanged; UpdateOrientation(_orientationSensor.GetCurrentOrientation()); } _compass = Compass.GetDefault(); if (_compass != null) { _compass.ReadingChanged += CompassReadingChanged; CompassChanged(_compass.GetCurrentReading()); } _gps = new Geolocator(); _gps.MovementThreshold = _movementThreshold; _gps.PositionChanged += GpsPositionChanged; if (_gps.LocationStatus == PositionStatus.Ready) { var pos = await _gps.GetGeopositionAsync(); if (pos != null && pos.Coordinate != null && pos.Coordinate.Point != null) { GpsChanged(pos.Coordinate.Point.Position); } } } catch { } }
// the values in the sensorArgs are currently not used by the FormulaEditorViewModel, // because the FormulaEvaluator uses the Get-Functions to get the current readings void _compass_ReadingChanged(Compass sender, CompassReadingChangedEventArgs args) { try { CompassReading reading = args.Reading; if (reading != null) { SensorEventArgs sensorArgs = new SensorEventArgs(reading.HeadingMagneticNorth); if (SensorReadingChanged != null) { SensorReadingChanged(sender, sensorArgs); } } } catch (Exception) { _compassEnabled = false; } _compassChecked = true; }
public DistanceViewModel(GeoCoordinate target) { this.target = target; lastKnownPosition = target; Distance = -1; DistanceUnit = "???"; Degree = 0; //start GPS _watcher = new GeoCoordinateWatcher() { MovementThreshold = 10}; c = new Compass(); _watcher.StatusChanged += delegate(Object sender, GeoPositionStatusChangedEventArgs a) { if (a.Status == GeoPositionStatus.Ready) CalcDistance(); }; c.CurrentValueChanged +=delegate(object sender, SensorReadingEventArgs<CompassReading> e) { CalcCourse(); }; c.Start(); _watcher.Start(); }
static int get_trueHeading(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); if (o == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name trueHeading"); } else { LuaDLL.luaL_error(L, "attempt to index trueHeading on a nil value"); } } Compass obj = (Compass)o; LuaScriptMgr.Push(L, obj.trueHeading); return(1); }
public async void NewCom(Compass sender, CompassReadingChangedEventArgs args) { var reading = args == null?sender?.GetCurrentReading() : args.Reading; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { this[COMPASS] = reading == null ? this[COMPASS].New(0, 0, 0, 0) : this[COMPASS].New(reading.HeadingMagneticNorth, reading.HeadingTrueNorth ?? 0, 0, 0); if (this[COMPASS].IsChanged) { OnPropertyChanged(new PropertyChangedEventArgs("ItemsList")); OnSensorUpdated?.Invoke(this[COMPASS]); } }); if (SensorSwitches.M.HasValue && (SensorSwitches.M.Value == 1 || SensorSwitches.M.Value == 3)) { SensorSwitches.M = 0; } }
public void GoLive() { if (Compass.IsSupported) { compass = new Compass(); compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(10); compass.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<CompassReading>>(compass_CurrentValueChanged); compass.Start(); } else { noDir.Text = "compass not supported by your device!"; } if (appSettings.Contains("allowGps") && appSettings["allowGps"] as Boolean? == true) { _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default) { MovementThreshold = 500 }; _watcher.PositionChanged += delegate(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e) { Dispatcher.BeginInvoke(() => RecalcPosition()); }; _watcher.Start(false); } }
public void Reset(Vector3 pos, Compass compass) { num = 0; this.compass = compass; this.pos = pos; if(compass == Compass.north) { pos.z += 2; } else if(compass == Compass.south) { pos.z -= 2; } else if(compass == Compass.east) { pos.x += 2; } else if(compass == Compass.west) { pos.x -= 2; } transform.position = pos; }
protected override void InitInstanceOverride() { // Creates and starts the location service. _GeoWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); _GeoWatcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(GeoWatcher_StatusChanged); _GeoWatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(GeoWatcher_PositionChanged); _GeoWatcher.Start(); // Creates and starts the compass service. if (Compass.IsSupported) { _Compass = new Compass(); _Compass.TimeBetweenUpdates = TimeSpan.FromMilliseconds(250); _Compass.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<CompassReading>>(Compass_CurrentValueChanged); _Compass.Calibrate += new EventHandler<CalibrationEventArgs>(OnCompassCalibrate); //_Compass.Start(); } // Deploys handlers. RegisterCoreEventHandlers(); }
protected override void DisposeOverride(bool disposeManagedResources) { if (disposeManagedResources) { DisposeLogger(); if (_Compass != null) { _Compass.Dispose(); _Compass = null; } if (_GeoWatcher != null) { _GeoWatcher.Dispose(); _GeoWatcher = null; } } }