void Initialize() { Console.WriteLine("Initialize hardware..."); display = new Ssd1309(Device.CreateI2cBus()); Console.WriteLine("Display created"); graphics = new GraphicsLibrary(display); graphics.CurrentFont = new Font8x8(); Console.WriteLine("Graphics library created"); //COM4 - Pins D00 & D01 on the Meadow F7 port = Device.CreateSerialMessagePort( Device.SerialPortNames.Com4, suffixDelimiter: Encoding.ASCII.GetBytes("\r\n"), preserveDelimiter: true, 9600); Console.WriteLine("Serial port created"); port.MessageReceived += (object sender, SerialMessageData e) => { nmea.ProcessNmeaMessage(e.GetMessageString(Encoding.ASCII)); }; nmea = new NmeaSentenceProcessor(); var ggaParser = new GgaDecoder(); ggaParser.PositionReceived += GgaParser_OnPositionReceived; nmea.RegisterDecoder(ggaParser); // open serial port.Open(); }
/// <summary> /// Main constructor /// </summary> /// <param name="p">Serial port to use for communication</param> public ComCommunication(ISerialMessagePort p) { locker = new object(); port = p; port.Open(); port.MessageReceived += Port_MessageReceived; SendMessage("Waiting for connection..."); }
private void GgaParser_OnPositionReceived(object sender, Meadow.Peripherals.Sensors.Location.Gnss.GnssPositionInfo location) { port.Close(); graphics.Clear(); graphics.DrawText(0, 0, "Latitude:"); graphics.DrawText(0, 11, $"{location.Position.Latitude?.Degrees} {location.Position.Latitude?.Direction}"); graphics.DrawText(0, 22, "Longitude:"); graphics.DrawText(0, 33, $"{location.Position.Longitude?.Degrees} {location.Position.Longitude?.Direction}"); graphics.DrawText(0, 44, "Altitude:"); graphics.DrawText(0, 55, $"{location.Position.Altitude}m"); graphics.Show(); port.Open(); }
void Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); bus = Device.CreateI2cBus(); display = new CharacterDisplay(bus, 39, 2, 16); port = Device.CreateSerialMessagePort(Device.SerialPortNames.Com4, suffixDelimiter: new byte[] { 10 }, preserveDelimiter: true, 921600, 8, Parity.None, StopBits.One); port.Open(); port.MessageReceived += Port_MessageReceived; }
public void StartUpdating() { // open the serial connection serialPort.Open(); Console.WriteLine("serial port opened."); //==== setup commands // get release and version Console.WriteLine("Asking for release and version."); this.serialPort.Write(Encoding.ASCII.GetBytes(Commands.PMTK_Q_RELEASE)); // get atntenna info Console.WriteLine("Start output antenna info"); this.serialPort.Write(Encoding.ASCII.GetBytes(Commands.PGCMD_ANTENNA)); // turn on all data Console.WriteLine("Turning on all data"); this.serialPort.Write(Encoding.ASCII.GetBytes(Commands.PMTK_SET_NMEA_OUTPUT_ALLDATA)); }
void Start() { Console.WriteLine("Starting."); HeartBeat(); serialPort.Open(); }