public void Go() { // turn of Netduino devices that we don't need PowerManagement.SetPeripheralState(Peripheral.Ethernet, false); PowerManagement.SetPeripheralState(Peripheral.PowerLED, false); PowerManagement.SetPeripheralState(Peripheral.SDCard, false); // initalize the serial ports m_serialPort = new SerialPort("COM1", 38400, Parity.None, 8, StopBits.One); m_serialPort.Open(); m_nmeaInputPort = new NmeaInputPort(m_serialPort); m_oled = new Newhaven25664OledDriver( chipSelect: Pins.GPIO_PIN_D10, reset: Pins.GPIO_PIN_D9, dc: Pins.GPIO_PIN_D8); m_oled.Initialize(); m_oled.ClearDisplay(); m_oled.TestPattern(); Thread.Sleep(1000); m_oled.ClearDisplay(); InputPort leftButton = new InputPort(Pins.GPIO_PIN_D7, false, Port.ResistorMode.PullUp); if (!leftButton.Read()) { // debug mode //m_nmeaInputPort.RawDataDebugEvent += new NmeaInputDebugEventHandler(m_nmeaInputPort_RawDataDebugEvent); m_nmeaInputPort.ParsedDataDebugEvent += new NmeaInputParsedDebugEventHandler(m_nmeaInputPort_ParsedDataDebugEvent); m_debugFont = new OledFont(SailboatComputer.Properties.Resources.BinaryResources.fixed5x7); m_nmeaInputPort.Initialize(); while (true) { Thread.Sleep(Int16.MaxValue); } } else { leftButton.Dispose(); leftButton = null; DebugLog.WriteLine("free memory (before fonts) = " + Microsoft.SPOT.Debug.GC(true)); m_ui = new SimpleUserInterface(m_oled, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D6); DebugLog.WriteLine("free memory (after fonts) = " + Microsoft.SPOT.Debug.GC(true)); // hook up NMEA events m_nmeaInputPort.WindEvent += new NmeaWindEventHandler(m_nmeaInputPort_WindEvent); m_nmeaInputPort.COGSOGEvent += new NmeaCOGSOGEventHandler(m_nmeaInputPort_CogSogEvent); m_nmeaInputPort.DepthEvent += new NmeaDepthEventHandler(m_nmeaInputPort_DepthEvent); m_nmeaInputPort.Initialize(); while (true) { Thread.Sleep(Int16.MaxValue); } } }
static void Main(string[] args) { userInterface = new SimpleUserInterface(); while (!userInterface.IsExiting) { userInterface.RunLoop(); } }