本文整理汇总了C#中Microsoft.SPOT.Hardware.InterruptPort类的典型用法代码示例。如果您正苦于以下问题:C# InterruptPort类的具体用法?C# InterruptPort怎么用?C# InterruptPort使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InterruptPort类属于Microsoft.SPOT.Hardware命名空间,在下文中一共展示了InterruptPort类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Remote
public Remote()
{
_button0 = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di12, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);
_button1 = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di13, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);
_button2 = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di2, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);
_button3 = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di3, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);
_button0.OnInterrupt += OnButtonPush;
_button1.OnInterrupt += OnButtonPush;
_button2.OnInterrupt += OnButtonPush;
_button3.OnInterrupt += OnButtonPush;
Cpu.GlitchFilterTime = new TimeSpan(TimeSpan.TicksPerSecond / 2);
_leftJoystick = new AnalogJoystick((Cpu.Pin)FEZ_Pin.AnalogIn.An1, (Cpu.Pin)FEZ_Pin.AnalogIn.An0, -100, 100);
_leftJoystick.YCalibration.EndPoints.Low = -4;
_leftJoystick.YCalibration.EndPoints.High = 7;
_leftJoystick.XCalibration.EndPoints.Low = 0;
_leftJoystick.XCalibration.EndPoints.High = 3;
_leftJoystick.AngularCalibration = new Angle(Angle.ConvertDegreesToRadians(-90));
_rightJoystick = new AnalogJoystick((Cpu.Pin)FEZ_Pin.AnalogIn.An3, (Cpu.Pin)FEZ_Pin.AnalogIn.An2, -100, 100);
_rightJoystick.YCalibration.EndPoints.Low = -6;
_rightJoystick.YCalibration.EndPoints.High = 6;
_rightJoystick.XCalibration.EndPoints.Low = 0;
_rightJoystick.XCalibration.EndPoints.High = 9;
_rightJoystick.AngularCalibration = new Angle(Angle.ConvertDegreesToRadians(-90));
// ReSharper disable RedundantArgumentDefaultValue
_radio = new RCRadio("OM1", "COM1", 115200, Parity.None, 8, StopBits.One)
{Id = "OM1", PartnerId = "OC1", SendFrequency = 200};
// ReSharper restore RedundantArgumentDefaultValue
_radio.DataReceived += OnRadioDataReceived;
}
开发者ID:ianlee74,项目名称:Omnimote,代码行数:31,代码来源:Remote.cs
示例17: Main
public static void Main()
{
// write your code here
InterruptPort button = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);
PulseLed();
// Create a new I2C bus instance at startup.
I2CBus i2cBus = I2CBus.GetInstance();
_BlinkM = new BlinkM(0x09);
_ds1621 = new DS1621(0x48);
// write something to a register.
//_exampleSensor.WriteSomethingToSpecificRegister();
ShiftRegister _74HC595 = new ShiftRegister(Pins.GPIO_PIN_D2, Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1);
//_74HC595.WriteMap(1, 255);
_74HC595.WriteByte(0);
_74HC595.WriteByte(0);
_74HC595.ClockStorage();
_74HC595.WriteByte(255);
_74HC595.WriteByte(1);
_74HC595.ClockStorage();
while (true)
{
for (int j = 1; j <= 128; j = j * 2)
{
for (int i = 1; i <= 128; i = i * 2)
{
//Debug.Print("i[" + i + "] j[" + j);
_74HC595.WriteByte(0,false);
_74HC595.WriteByte(0,true);
_74HC595.WriteByte(i, false);
_74HC595.WriteByte(j, true);
_74HC595.ClockStorage();
Thread.Sleep(100);
}
}
/*
for (int j = 1; j <= 128; j = j * 2)
{
for (int i = 1; i <= 128; i = i * 2)
{
Debug.Print("i[" + i + "] j[" + j);
_74HC595.WriteByte(i);
_74HC595.WriteByte(j);
_74HC595.ClockStorage();
Thread.Sleep(200);
}
}
* */
}
//Bresenhams.Algorithms.Line(0,0,4,7,SetPixel);
//Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticIP("10.0.0.222", "255.255.255.0", "10.0.0.4");
//Debug.Print("IP=" + Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress);
Thread.Sleep(Timeout.Infinite);
}
开发者ID:omglolbah,项目名称:Netduino,代码行数:59,代码来源:Program.cs
示例18: UltraSonicSensor
public UltraSonicSensor(Cpu.Pin echoPin, Cpu.Pin triggerPin)
{
_echoPin = new InterruptPort(echoPin, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
_triggerPin = new OutputPort(triggerPin, false);
_echoPin.OnInterrupt += port_OnInterrupt;
_echoPin.DisableInterrupt();
}
开发者ID:coolkev,项目名称:Netduino,代码行数:8,代码来源:UltraSonicSensor.cs
示例19: TapDecoder
public TapDecoder(int reqDigits, Cpu.Pin tapSensePin)
{
requiredDigits = reqDigits;
tapSensePort = new InterruptPort(tapSensePin, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);
tapSensePort.OnInterrupt += new NativeEventHandler(port_OnInterrupt);
intrTimer = new Timer(new TimerCallback(intr_OnTimer), null, -1, -1);
Reset();
}
开发者ID:robdobsn,项目名称:RFIDDoorLock1,代码行数:8,代码来源:TapDecoder.cs
示例20: Current_OnButtonPress
static void Current_OnButtonPress(Buttons button, InterruptPort port, ButtonDirection direction, DateTime time)
{
if (direction == ButtonDirection.Up)
{
_buttonHitList.Add(button);
clickTimer.Change(MaxClickWaitTime, Timeout.Infinite);
}
}
开发者ID:nicksi,项目名称:AGENT.Contrib,代码行数:8,代码来源:Program.cs
注:本文中的Microsoft.SPOT.Hardware.InterruptPort类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论