protected void Dispose(bool disposing) { if (null != _fifoPort) { _fifoPort.Dispose(); _fifoPort = null; } if (null != _fifopInterrupt) { _fifopInterrupt.Dispose(); _fifopInterrupt = null; } if (null != _sfdInterrupt) { _sfdInterrupt.Dispose(); _sfdInterrupt = null; } if (null != _resetPort) { _resetPort.Dispose(); _resetPort = null; } if (null != _ccaPort) { _ccaPort.Dispose(); _ccaPort = null; } if (null != _powerPort) { _powerPort.Dispose(); _powerPort = null; } if (null != _spi) { lock (_spi) { _spi.Dispose(); _spi = null; } } }
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); } } }
public void Dispose() { if (trigger != null) { trigger.Dispose(); } if (echo != null) { echo.Dispose(); } }
public void Dispose() { myInputPort.Dispose(); myInterruptPort.Dispose(); myOutputPort.Dispose(); myI2CDevice.Dispose(); mySPI.Dispose(); myTristatePort.Dispose(); mySerialPort.Dispose(); Dispose(true); GC.SuppressFinalize(this); }
/// <summary> /// Disposes the Sony IR object. /// </summary> public override void Dispose() { _runningThread = false; _disposing = true; _mainThread.Join(1000); while (_mainThread.IsAlive) { Thread.Sleep(250); } _irPort.Dispose(); }
static void Main(string[] args) { OutputPort o = new OutputPort(Cpu.Pin.GPIO_Pin17, true); for (int i = 0; i < 5; i++) { o.Write(true); Console.WriteLine("Read: " + o.Read()); Thread.Sleep(500); o.Write(false); Console.WriteLine("Read: " + o.Read()); Thread.Sleep(500); } o.Dispose(); InputPort input = new InputPort(Cpu.Pin.GPIO_Pin17, true, Port.ResistorMode.Disabled); Console.WriteLine("Read: " + input.Read()); input.Dispose(); Console.WriteLine("Finishing"); }
internal GoHub() { // initialize our sockets _sockets = new GoSocket[_socketCount]; _socketLeds = new OutputPort[_socketCount]; for (int iSocket = 0; iSocket < _socketCount; iSocket++) { _sockets[iSocket] = new GoSocket(iSocket + 1); _socketLeds[iSocket] = new OutputPort(GetSocketLedPin(iSocket + 1), false); _sockets[iSocket].SetHub(this); _sockets[iSocket].SetPowerState(true); } // TODO: do this in native code during clr startup, to ensure the pullup state. // put uart RX pins in input, pull-up mode by creating and then disposing of them. InputPort uart1rx = new InputPort((Cpu.Pin) 0x01, false, Port.ResistorMode.PullUp); InputPort uart2rx = new InputPort((Cpu.Pin) 0x03, false, Port.ResistorMode.PullUp); uart1rx.Dispose(); uart2rx.Dispose(); // enable our power output _powerEnable = new OutputPort((Cpu.Pin) 0x0A, false); }
/// <summary> /// Actually starts the demo /// </summary> /// <param name="Server">Reference to the Telnet Server</param> public static void Start(TelnetServer Server) { // Configures the onboard button. If this fails, it's probably already in use by another app. InputPort Button = null; try { Button = new InputPort(ONBOARD_SW1, false, Port.ResistorMode.Disabled); } catch (Exception e) { Server.Color(TelnetServer.Colors.LightRed); Server.Print("Exception " + e.Message + " given. Were the onboard Button already configured?"); Server.Color(TelnetServer.Colors.White); return; } // Configures the onboard LED. If this fails, it's probably already in use by another app. OutputPort Led = null; try { Led = new OutputPort(ONBOARD_LED, false); } catch (Exception e) { Button.Dispose(); // The button is already defined Server.Color(TelnetServer.Colors.LightRed); Server.Print("Exception " + e.Message + " given. Were the onboard LED already configured?"); Server.Color(TelnetServer.Colors.White); return; } // Disables echoing of keypresses Server.EchoEnabled = false; // Clears the screen Server.ClearScreen(); // Draws a Netduino Plus in ANSI/ASCII art Server.Print("\xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf"); Server.Print("\xb3 \xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe \xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xb3"); Server.Print("\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb \xdc \xb3"); Server.Print("\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb NETDUINO \xb3"); Server.Print("\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb PLUS \xb3"); Server.Print("\xb3 ..\xb3"); Server.Print("\xdb\xdb \xdb\xdb ::\xb3"); Server.Print("\xb3 \xdb\xdb\xdb\xdb\xdb\xdb \xb3"); Server.Print("\xdb\xdb\xdb\xdb\xdb \xdb\xdb\xdb\xdb\xdb\xdb \xb3"); Server.Print("\xdb\xdb\xdb\xdb\xdb \xdb\xdb\xdb\xdb\xdb\xdb \xfe\xfe\xfe\xfe\xfe\xfe \xfe\xfe\xfe\xfe\xfe\xfe\xb3"); Server.Print("\xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xdb\xdb\xdb\xdb\xdb\xdb\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9"); Server.Print("", true); Server.Print("Push the Netduino Plus onboard button, or press a key to close this app"); // We only update the screen if the LastState is different from the current state bool LastState = false; while (Server.IsConnected && Server.Input(1, false) == "") { // We need to update if (Button.Read() == LastState) { // Lets record the last state LastState = !Button.Read(); Led.Write(LastState); // Draws the button if (LastState) { Server.Color(TelnetServer.Colors.HighIntensityWhite); } else { Server.Color(TelnetServer.Colors.Gray); } Server.Locate(7, 26, true); Server.Print("\xdb\xdb", true, true); // Draws the LED if (LastState) { Server.Color(TelnetServer.Colors.LightBlue); } else { Server.Color(TelnetServer.Colors.Gray); } Server.Locate(3, 29, true); Server.Print("\xdc", true); // Brings back the cursor to the last line Server.Locate(14, 1); } } // Releases the pins Button.Dispose(); Led.Dispose(); // Enables echo again and clears the screen if (Server.IsConnected) { Server.EchoEnabled = true; Server.ClearScreen(); } }
public override void Dispose() { _irPort.Dispose(); Debug.Print("NEC Receiver is Disposed"); }
protected override void DisposeManagedResources() { _input.Dispose(); }
public override void Dispose() { _port.Dispose(); }