本文整理汇总了C#中Microsoft.SPOT.Hardware.InterruptPort.Read方法的典型用法代码示例。如果您正苦于以下问题:C# InterruptPort.Read方法的具体用法?C# InterruptPort.Read怎么用?C# InterruptPort.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.SPOT.Hardware.InterruptPort
的用法示例。
在下文中一共展示了InterruptPort.Read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DigitalInputPin
public DigitalInputPin (Cpu.Pin pin, bool glitchFilter = false)
{
port = new InterruptPort (pin, glitchFilter, HWPort.ResistorMode.Disabled, HWPort.InterruptMode.InterruptEdgeBoth);
var initialValue = port.Read () ? 1 : 0;
Output = AddPort ("Output", Units.Digital, initialValue);
port.OnInterrupt += port_OnInterrupt;
}
示例2: RotaryEncoder
public RotaryEncoder(Cpu.Pin aQuad, Cpu.Pin bQuad, Cpu.Pin momentaryPushbutton)
{
//Keyboard kb = Keyboard.Instance;
//kb.Clear();
Keyboard2.Clear();
_aQuad = new InterruptPort(aQuad, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
_bQuad = new InterruptPort(bQuad, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
_momentaryPushbutton = new InterruptPort(momentaryPushbutton, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
if (_momentaryPushbutton.Read() == false)
{
using (var rtc = new RTC())
{
rtc.ClearCalibration();
}
}
_distanceTraveled = 0;
_currentDirection = Direction.RotateLeft;
_sequencePos = 1;
_ready = true;
try
{
_momentaryPushbutton.OnInterrupt += MomentaryPushbuttonOnInterrupt;
//_momentaryPushbutton.EnableInterrupt();
_aQuad.OnInterrupt += AQuadOnInterrupt;
//_aQuad.EnableInterrupt();
_bQuad.OnInterrupt += BQuadOnInterrupt;
//_bQuad.EnableInterrupt();
}
catch
{
DebugHelper.Print("Button Interrupt Init Failed");
}
}
示例3: Axis
public Axis(string axisID, Cpu.Pin stepPin, Cpu.Pin directionPin, Cpu.Pin limitSwitchPin, bool invertDirectionPinOutput = false)
{
this.ID = axisID;
StepPort = new OutputPort(stepPin, false);
DirectionPort = new OutputPort(directionPin, false);
LimitReached = LimitSwitch.None;
if (limitSwitchPin != Cpu.Pin.GPIO_NONE)
{
LimitSwitchPort = new InterruptPort(limitSwitchPin, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLevelLow);
LimitSwitchPort.OnInterrupt += new NativeEventHandler(LimitSwitchPin_OnInterrupt);
// Since we're sharing a port for the Min/Max limit switches on each axis, we can only determine which switch is tripped
// while there is motion (based on direction). If we initialize the axis and find that the switch is tripped, then we don't
// know which end it is at and the user will need to move the axis off of the switch before the machine can be homed.
if (LimitSwitchPort.Read() == false) LimitReached = LimitSwitch.Unknown;
}
InvertDirectionPinOutput = invertDirectionPinOutput;
Location = 0;
LocationUnitsPerStep = 4; //Should be overwritten when machine sets the resolution
StepDirection = true;
}