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


C# Hardware.InterruptPort类代码示例

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


InterruptPort类属于Microsoft.SPOT.Hardware命名空间,在下文中一共展示了InterruptPort类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public static void Run()
        {
            var servo = new ServoController(Pins.GPIO_PIN_D9, 600, 3000);

            var button = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
            button.OnInterrupt += (data1, data2, time) =>
            {

                //servo.Duration = 1500;
                if (data2 == 1)
                    servo.Rotate(100);
                else
                {
                    servo.Rotate(0);

                }
            };

            while (Debugger.IsAttached)
            {
                Thread.Sleep(1000);

            }

            button.Dispose();
            servo.Dispose();
        }
开发者ID:coolkev,项目名称:Netduino,代码行数:27,代码来源:ServoRangeTest.cs

示例2: LightTrigger

        // Use IButton (interface of button) as the type of the passed button in constructor
        public LightTrigger(int clicks)
        {
            this.TriggerAfter = clicks;

            Led = new OutputPort(Pins.ONBOARD_LED, false);

            // In larger applications, create a class that encapsulates the hardware components. It should
            // configure the hardware once and behind the scenes so that the rest of the program doesn't have those details.
            // (E.g. set what pins are being used). Also, it makes for sense for the rest of the program to
            // refer to a "button" object instead of an InterruptPort object
            // Define a button interface, create a class for a particular button, instantiate button in main and pass it to
            // the constructor of the managing class (Dependency injection)
            // Configuration is done up top, passed into the application
            Button = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);

            // PullUp resistor setting causes netduino to create a voltage at the pin
            // PullDown resistor setting is used when you supply a voltage to the pin
            Reset = new InterruptPort(Pins.GPIO_PIN_D13, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);

            //Type typeOfOutputPort = led.GetType();

            // Hold an instance of this delegate in a name so you can subscribre or unsubscribe easily and neatly
            // Set handler for trigger button
            var handlerDelegate = new NativeEventHandler(button_onInterrupt);
            // NativeEventHandler h = button_onInterrupt;

            Button.OnInterrupt += handlerDelegate;

            // Set handler for reset button
            var del = new NativeEventHandler(reset_onInterrupt);
            Reset.OnInterrupt += del;
        }
开发者ID:binary10,项目名称:Netduino,代码行数:33,代码来源:LightTrigger.cs

示例3: Main

        public static void Main()
        {
            //set current date and time + 1 or 2 minutes
            var newDateTime = new DateTime(2012, 09, 04, 21, 30, 45);

            Debug.Print("Wait for " + newDateTime);

            using (var userButton = new InterruptPort(Stm32F4Discovery.ButtonPins.User,
                                                      false, Port.ResistorMode.PullDown,
                                                      Port.InterruptMode.InterruptEdgeLow))
            {
                var ds1307 = new DS1307();
                byte[] storeData = Reflection.Serialize(newDateTime, typeof (DateTime));
                ds1307.WriteRam(storeData);

                //push userbutton when time comes
                userButton.OnInterrupt += (d1, d2, t) =>
                                              {
                                                  ds1307.SetDateTime(newDateTime);
                                                  Debug.Print("Initialized");
                                              };

                Thread.Sleep(Timeout.Infinite);
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:25,代码来源:Program.cs

示例4: InputList

 public InputList(int count)
 {
     _syncRoot = new object();
     _array = new InterruptPort[count];
     _currentMax = count;
     _currentIndex = 0;
 }
开发者ID:jquintus,项目名称:NetduinoTutorial,代码行数:7,代码来源:InputList.cs

示例5: Main

        public static void Main()
        {
            _outDig0 = new OutputPort(Pins.GPIO_PIN_D0, false);
            _outDig1 = new OutputPort(Pins.GPIO_PIN_D1, false);
            _outDig2 = new OutputPort(Pins.GPIO_PIN_D2, false);

            _isOn = false;
            _count = 0;

            InterruptPort mySwicht = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
            mySwicht.OnInterrupt += new NativeEventHandler(mySwicht_OnInterrupt);

            while (true)
            {
                if( (_isOn) && (_count < 8))
                {
                    SetLights(ToBinary(_count));
                    Thread.Sleep(1000);
                    _count++;
                }
                else
                {
                    _outDig0.Write(false);
                    _outDig1.Write(false);
                    _outDig2.Write(false);
                    _count = 0;
                }
            }
        }
开发者ID:davamix,项目名称:Blog,代码行数:29,代码来源:Program.cs

示例6: Main

        public static void Main()
        {
            // Setup GoBus ports
            led1 = new NetduinoGo.RgbLed(GoSockets.Socket8);
            led2 = new NetduinoGo.RgbLed(GoSockets.Socket7);
            led3 = new NetduinoGo.RgbLed(GoSockets.Socket6);
            button1 = new NetduinoGo.Button(GoSockets.Socket1);
            button2 = new NetduinoGo.Button(GoSockets.Socket3);
            InterruptPort settingButton = new InterruptPort(Pins.Button, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);
            settingButton.OnInterrupt += new NativeEventHandler(settingButton_OnInterrupt);
            OutputPort powerlight = new OutputPort(Pins.PowerLed, false);

            #if !mute
            buzzer = new NetduinoGo.PiezoBuzzer();
            #endif

            // Set Scale
            SetScale();

            // Register Buttons
            button1.ButtonPressed += new NetduinoGo.Button.ButtonEventHandler(button1_ButtonPressed);
            button2.ButtonPressed += new NetduinoGo.Button.ButtonEventHandler(button2_ButtonPressed);
            led2.SetColor(0, 0, 255);
            // Main thread sleep time
            Thread.Sleep(Timeout.Infinite);
        }
开发者ID:BlackLamb,项目名称:GameTimer,代码行数:26,代码来源:Program.cs

示例7: Connect

 public void Connect(Cpu.Pin pinTrig, Cpu.Pin pinEcho)
 {
     _portOut = new OutputPort(pinTrig, false);
     _interIn = new InterruptPort(pinEcho, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);
     _interIn.OnInterrupt += new NativeEventHandler(interIn_OnInterrupt);
     Reset();
 }
开发者ID:WesDaniels,项目名称:ColdBeer,代码行数:7,代码来源:Ping.cs

示例8: RotaryEncoder

 /// <summary>
 /// Initiates a rotary encoder
 /// </summary>
 /// <param name="PinA">Pin A</param>
 /// <param name="PinB">Pin B</param>
 public RotaryEncoder(Cpu.Pin PinA, Cpu.Pin PinB)
 {
     this._PinA = new InterruptPort(PinA, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
     this._PinB = new InterruptPort(PinB, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
     this._PinA.OnInterrupt += new NativeEventHandler(_Pin_OnInterrupt);
     this._PinB.OnInterrupt += new NativeEventHandler(_Pin_OnInterrupt);
 }
开发者ID:JakeLardinois,项目名称:NetMF.Toolbox,代码行数:12,代码来源:RotaryEncoder.cs

示例9: IrReceiver

        public IrReceiver(Cpu.Pin pin)
        {
            _timeoutTimer = new Timer(ReceiverTimeout, null, Timeout.Infinite, Timeout.Infinite);

            _interrputPort = new InterruptPort(pin, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
            _interrputPort.OnInterrupt += interrputPort_OnInterrupt;
        }
开发者ID:BookSwapSteve,项目名称:LightSwitch,代码行数:7,代码来源:IrReceiver.cs

示例10: Enable

		/// <summary>
		/// Enables the key functionality if it was disabled.
		/// </summary>
        public static void Enable()
		{
			if (Key.IsEnabled)
				return;

			Key.Up = new InterruptPort(Key.UP_PIN, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLow);
			Key.Left = new InterruptPort(Key.LEFT_PIN, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLow);
			Key.Down = new InterruptPort(Key.DOWN_PIN, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLow);
			Key.Right = new InterruptPort(Key.RIGHT_PIN, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLow);

			Key.A = new InterruptPort(Key.A_PIN, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLow);
			Key.B = new InterruptPort(Key.B_PIN, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLow);
			Key.C = new InterruptPort(Key.C_PIN, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLow);
			Key.Power = new InterruptPort(Key.POWER_PIN, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLow);
			Key.Start = new InterruptPort(Key.START_PIN, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLow);

			Key.Up.OnInterrupt += new NativeEventHandler(OnKeyPress);
			Key.Left.OnInterrupt += new NativeEventHandler(OnKeyPress);
			Key.Down.OnInterrupt += new NativeEventHandler(OnKeyPress);
			Key.Right.OnInterrupt += new NativeEventHandler(OnKeyPress);

			Key.A.OnInterrupt += new NativeEventHandler(OnKeyPress);
			Key.B.OnInterrupt += new NativeEventHandler(OnKeyPress);
			Key.C.OnInterrupt += new NativeEventHandler(OnKeyPress);
			Key.Power.OnInterrupt += new NativeEventHandler(OnKeyPress);
			Key.Start.OnInterrupt += new NativeEventHandler(OnKeyPress);

			Key.Enabled = true;
        }
开发者ID:errolt,项目名称:NETMF4.3_Community,代码行数:32,代码来源:Key.cs

示例11: Window

 public Window(Cpu.Pin pin, bool pulseOnClose, string name)
 {
     _pulseOnClose = pulseOnClose;
     Name = name;
     _port = new InterruptPort(pin, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
     _port.OnInterrupt += PortOnInterrupt;
 }
开发者ID:johnnybegood,项目名称:MinnoxAlarm,代码行数:7,代码来源:Window.cs

示例12: ContactSensor

        public ContactSensor(Cpu.Pin sensorPin)
        {
            this.sensorPin = sensorPin;

            sensorPort = new InterruptPort(sensorPin, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLevelLow);
            sensorPort.OnInterrupt += new NativeEventHandler(OnInterrupt);
        }
开发者ID:gflerm,项目名称:NetCNC,代码行数:7,代码来源:ContactSensor.cs

示例13: UltrasonicDistance

        public UltrasonicDistance(Cpu.Pin trigger, Cpu.Pin echo)
        {
            Trigger = new OutputPort(trigger, false);

            Echo = new InterruptPort(echo, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);
            Echo.OnInterrupt += Echo_OnInterrupt;
        }
开发者ID:pettijohn,项目名称:PidController,代码行数:7,代码来源:UltrasonicDistance.cs

示例14: PIRSens

 public PIRSens(Cpu.Pin kojPin, Predmet stoPred)
 {
     _kakovSum = TipSenzor.PIR;
     _kadeSum = stoPred;
     pirSens  = new InterruptPort(kojPin, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
     pirSens.OnInterrupt += new NativeEventHandler(NekojVleze);
 }
开发者ID:markomitr,项目名称:NetDuino-.Net-MicroFramwork-HomeSecuritySystem-Sensors,代码行数:7,代码来源:PIRSens.cs

示例15: Main

        public static void Main()
        {
            InterruptPort button = new InterruptPort(Pins.ONBOARD_BTN,
            false,
            Port.ResistorMode.Disabled,
            Port.InterruptMode.InterruptEdgeLow);
            button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);

            InterruptPort hr = new InterruptPort(Pins.GPIO_PIN_D2,
                false,
                Port.ResistorMode.Disabled,
                Port.InterruptMode.InterruptEdgeLow);
            hr.OnInterrupt += new NativeEventHandler(hr_OnInterrupt);

            Thread.Sleep(Timeout.Infinite);
            //var led = new OutputPort(Pins.ONBOARD_LED, false);
            //var rotatary = new AnalogInput(AnalogChannels.ANALOG_PIN_A0);

            //while (true)
            //{
            //    led.Write(!led.Read());

            //    Thread.Sleep((int) rotatary.ReadRaw());
            //}
        }
开发者ID:jladuval,项目名称:CodeCampRobots,代码行数:25,代码来源:Program.cs


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