當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。