private void GetPosition(Position position) { Latitude = position.Latitude; Longitude = position.Longitude; Pin p = new Pin { Position = new Position(Latitude, Longitude), Label = Lable, Address = Description }; MyPins.Clear(); MyPins.Add(p); }
private bool InitPins() { //SpiConnectionSettings(0) MyPins[] pins = (MyPins[])Enum.GetValues(typeof(MyPins)); var gpio = GpioController.GetDefault(); mapZoneToPinNo.Add(1, MyPins.Led6); mapZoneToPinNo.Add(2, MyPins.Led5); mapZoneToPinNo.Add(3, MyPins.Led25); mapZoneToPinNo.Add(4, MyPins.Led24); mapZoneToPinNo.Add(5, MyPins.Led23); mapZoneToPinNo.Add(6, MyPins.Led22); mapZoneToPinNo.Add(7, MyPins.Led18); mapZoneToPinNo.Add(8, MyPins.Led17); mapZoneToPinNo.Add(9, MyPins.Led12); mapZoneToPinNo.Add(10, MyPins.Led13); mapZoneToPinNo.Add(11, MyPins.Led19); mapZoneToPinNo.Add(12, MyPins.Led26); mapZoneToPinNo.Add(13, MyPins.Led16); mapZoneToPinNo.Add(14, MyPins.Led20); mapZoneToPinNo.Add(15, MyPins.Led21); foreach (int zone in mapZoneToPinNo.Keys) { MyPins id = mapZoneToPinNo[zone]; try { GpioPin pin = gpio.OpenPin((int)id); GpioPinValue pinValue = GpioPinValue.High; pin.Write(pinValue); pin.SetDriveMode(GpioPinDriveMode.Output); mapZoneToPin.Add(zone, pin); zoneOffOnList[zone - 1] = false; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Unable to open pin: " + id); System.Diagnostics.Debug.WriteLine(ex.StackTrace); } } return(true); }
public static void Set(ref IService <DirectionsParameters, DirectionsResult> service, MyPins pins, bool optimize = true, TrafficModels?trafficModels = null) { service.Parameters.Origin.Latitude = pins.StartPin.Coordinate.Latitude; service.Parameters.Origin.Longitude = pins.StartPin.Coordinate.Longitude; service.Parameters.Destination.Latitude = pins.EndPin.Coordinate.Latitude; service.Parameters.Destination.Longitude = pins.EndPin.Coordinate.Longitude; service.Parameters.Key = "AIzaSyA3YhAyyckDAMFGuVR7yRI-fG_NATvL8Yk"; service.Parameters.Optimize = optimize; foreach (var pin in pins.WaypointsPin) { var location = new Location(pin.Coordinate.Latitude, pin.Coordinate.Longitude); service.Parameters.Waypoints.Add(location); } if (trafficModels == null || trafficModels.Value == TrafficModels.BestGuess) { return; } service.Parameters.TrafficModel = trafficModels; service.Parameters.DepartureTime = DateTime.Now.AddMinutes(1); }