本文整理汇总了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();
}
示例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;
}
示例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);
}
}
示例4: InputList
public InputList(int count)
{
_syncRoot = new object();
_array = new InterruptPort[count];
_currentMax = count;
_currentIndex = 0;
}
示例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;
}
}
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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());
//}
}