Class Pin
The GPIO pin model: levels, interrupt edges, and active polarity.
public static class Pin
- Inheritance
-
Pin
- Inherited Members
Remarks
Active-low wiring is everywhere in cheap hardware: a button to ground with a pull-up reads low when pressed, and many relay boards energise when driven low. PinPolarity maps between "asserted" and the physical level so that mapping lives in one place instead of in scattered inversions.
Methods
Invert(PinLevel)
Returns the opposite level.
public static PinLevel Invert(PinLevel level)
Parameters
levelPinLevelThe level to invert.
Returns
- PinLevel
The other level.
IsAsserted(PinPolarity, PinLevel)
Reports whether a physical level means the signal is asserted.
public static bool IsAsserted(PinPolarity polarity, PinLevel level)
Parameters
polarityPinPolarityHow the signal is wired.
levelPinLevelThe level read on the pin.
Returns
- bool
Whether the signal is asserted.
LevelFor(PinPolarity, bool)
Returns the physical level that represents a logical state.
public static PinLevel LevelFor(PinPolarity polarity, bool asserted)
Parameters
polarityPinPolarityHow the signal is wired.
assertedboolWhether the signal should be asserted.
Returns
- PinLevel
The level to drive, inverted for active-low wiring.
LevelFrom(bool)
Returns the level a boolean names.
public static PinLevel LevelFrom(bool high)
Parameters
highbooltruefor high,falsefor low.
Returns
- PinLevel
The level.
Triggers(PinEdge, PinLevel, PinLevel)
Reports whether a transition fires an interrupt trigger.
public static bool Triggers(PinEdge edge, PinLevel from, PinLevel to)
Parameters
edgePinEdgeThe trigger configured on the pin.
fromPinLevelThe level before the change.
toPinLevelThe level after it.
Returns
- bool
Whether the trigger fires.