当前位置: 首页>>代码示例>>C#>>正文


C# OutputPort.Dispose方法代码示例

本文整理汇总了C#中Microsoft.SPOT.Hardware.OutputPort.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# OutputPort.Dispose方法的具体用法?C# OutputPort.Dispose怎么用?C# OutputPort.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.SPOT.Hardware.OutputPort的用法示例。


在下文中一共展示了OutputPort.Dispose方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main()
        {
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
            led.Write(true);

            VoltageDivider voltageReader = new VoltageDivider(Pins.GPIO_PIN_A1, 470000, 4700);
            Acs712 currentReader = new Acs712(Pins.GPIO_PIN_A2, Acs712.Range.ThirtyAmps);

            EmonCmsProxy.Start();
            MpptOptimizer.Start();

            led.Write(false);
            led.Dispose();
            GC.WaitForPendingFinalizers();

            //Random r = new Random((int) DateTime.Now.Ticks);
            while (true)
            {
                double current = //r.NextDouble() / double.MaxValue * 10;
                    currentReader.Read();
                double voltage = //r.NextDouble() / double.MaxValue * 3;
                    voltageReader.Read();

                EmonCmsProxy.Push(current, voltage);
                MpptOptimizer.Push(current, voltage);

                Thread.Sleep(50);
            }
        }
开发者ID:dedalebeda,项目名称:emoncms-power-reader,代码行数:29,代码来源:Program.cs

示例2: PowerUpDisplay

 public static void PowerUpDisplay() {
     // Ensure that the GPIO pin in low to prevent the display module to start in bootloader mode
     var goBusGPIO = new OutputPort(Pins.GPIO_PIN_D8, false);
     // Power up the display module
     PowerTransistor.Write(false);
     // Always wait 250ms after power-up to ensure that the display module is fully initialized before sending commands
     Thread.Sleep(250);
     goBusGPIO.Dispose();
 }
开发者ID:einart74,项目名称:NetduinoHelpers,代码行数:9,代码来源:Program.cs

示例3: Main

        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");
        }
开发者ID:GerardSoleCa,项目名称:IOSharp-netmf-Linux,代码行数:19,代码来源:BlinkingLedExample.cs

示例4: Main

        static void Main(string[] args)
        {
            SPI SPIport = new Microsoft.SPOT.Hardware.SPI(new Microsoft.SPOT.Hardware.SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 2000, SPI.SPI_module.SPI1));
            OutputPort nCE = new OutputPort(Cpu.Pin.GPIO_Pin2, true);
            InterruptPort nINT = new InterruptPort(Cpu.Pin.GPIO_Pin4, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);

            NRF24L01Plus n = new NRF24L01Plus();
            n.Initialize(SPIport, nCE, nINT);

            byte[] address = n.GetAddress(AddressSlot.Zero, 5);
            Console.WriteLine("First Address: " + ByteArrayToHexString(address));

            byte[] b = new byte[] { 0x04, 0x09, 0x02, 0x03, 0x04 };
            n.SetAddress(AddressSlot.Zero, b, false);

            address = n.GetAddress(AddressSlot.Zero, 5);
            Console.WriteLine("Second Address: " + ByteArrayToHexString(address));

            nCE.Dispose();
            nINT.Dispose();
        }
开发者ID:GerardSoleCa,项目名称:IOSharp-netmf-Linux,代码行数:21,代码来源:SimpleNordicWriteAddress.cs

示例5: Main

        //public static void Main()
        //{
        //    using (var a1 = new AnalogInput(Cpu.AnalogChannel.ANALOG_1))
        //    {
        //        var last = 0.0d;
        //        while (Debugger.IsAttached)
        //        {
        //            var reading = a1.Read();
        //            if (reading != last)
        //            {
        //                Debug.Print(reading.ToString());
        //                last = reading;
        //            }
        //        }
        //    }
        //}
        public static void Main()
        {
            var wiiChuck = new WiiChuck(true);
            var debugMode = Debugger.IsAttached;

            _redLed = new OutputPort(Pins.GPIO_PIN_D13, false);
            _greenLed = new OutputPort(Pins.GPIO_PIN_A0, false);

            _pot = new AnalogInput(Cpu.AnalogChannel.ANALOG_1);

            //_speaker = new PWM(Pins.GPIO_PIN_D9);

            //_speakerThread = new Thread(PlaySound);
            //_speakerThread.Start();
            //_servo1 = new ServoController(Mshield.Servo1, 600, 2400, startDegree: 90);
            _robot = new TankRobot();

            while (!debugMode || Debugger.IsAttached)
            {
                // try to read the data from nunchucku
                if (wiiChuck.GetData())
                {

                    CheckButtons(wiiChuck.CButtonDown, wiiChuck.ZButtonDown);

                    if (Recording)
                    {
                        _iteration++;
                        SetMotorSpeed(_robot, wiiChuck);

                    }
                    else if (PlayingBack)
                    {

                        if (_currentPlaybackIndex >= _record.Count)
                        {
                            PlayingBack = false;
                            _currentPlaybackIndex = 0;

                        }
                        else
                        {
                            _iteration++;

                            var record = (DataPoint) _record[_currentPlaybackIndex];

                            if (record.Iterations == _iteration)
                            {
                                _currentPlaybackIndex++;
                                _robot.Move(record.LeftSpeed, record.RightSpeed);

                            }
                        }

                    }
                    else
                    {
                        SetMotorSpeed(_robot, wiiChuck);
                    }
                    //var degrees = ((int) (90+(-90*wiiChuck.AccelerationXGs))/2)*2;

                    //if (degrees < 0)
                    //    degrees = 0;
                    //else if (degrees > 180)
                    //    degrees = 180;

                    //_servo1.Rotate(degrees);
                    //Debug.Print("AccelX = " + wiiChuck.AccelerationXGs + "   AccelY=" + wiiChuck.AccelerationYGs);
                }
            }

            wiiChuck.Dispose();

            _robot.Dispose();

            //_speaker.Dispose();
            //_speaker = null;

            //_servo1.Dispose();

            _redLed.Dispose();
            _greenLed.Dispose();

            _pot.Dispose();
//.........这里部分代码省略.........
开发者ID:coolkev,项目名称:Netduino,代码行数:101,代码来源:Program.cs

示例6: Start

        /// <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();
            }
        }
开发者ID:JakeLardinois,项目名称:NetMF.Toolbox,代码行数:86,代码来源:NetduinoPlus.cs

示例7: PromiSDBTDriver

        private bool m_disposed;                // Whether or not the driver is disposed

        //--//

        /// <summary>
        /// Creates a new instance of PromiSDBTDriver by initializing
        /// the Serial connection and checking if the SD is present.
        /// </summary>
        /// <param name="comNum">
        /// Number of the COM port to use
        /// </param>
        /// <param name="baudRate">
        /// Baud rate of the COM port to use
        /// </param>
        /// <param name="powerPin">
        /// GPIO to turn the bluetooth power off
        /// </param>
        /// <remarks>
        /// GPIO pin for the N6D should be GPIO22_VTU_TIO3A, if there is no GPIO for power control
        /// then use GPIO_NONE.
        /// </remarks>
        public PromiSDBTDriver(string com, BaudRate baud, Cpu.Pin powerPin)
        {
            bool success = false;

            m_com = com;
            m_baud = baud;

            try
            {
                if (!CreateSerialConnection(m_com, m_baud)) throw new SystemException("Error booting SD");

                m_power = (powerPin == Cpu.Pin.GPIO_NONE) ? null : new OutputPort(powerPin, false);
                m_powerState = PowerState.Off;
                m_state = BTDeviceState.OFF;

                PowerState state = PowerState.On;
                if (!SetPowerState(ref state) || !CheckDevicePresent()) throw new SystemException("Error booting SD");

                success = true;

                UpdateDeviceStatus();

                m_disposed = false;
            }
            finally
            {
                if (!success)
                {
                    if (null != m_power)
                    {
                        m_power.Dispose();
                        m_power = null;
                    }

                    m_disposed = true;
                }
            }
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:59,代码来源:PromiSDBTDriver.cs


注:本文中的Microsoft.SPOT.Hardware.OutputPort.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。