Class Pcx857x
Base class for PCx857x GPIO expanders
public abstract class Pcx857x : GpioDriver
- Inheritance
-
GpioDriverPcx857x
- Derived
Constructors
Pcx857x(I2cDevice, int, GpioController, bool)
Remote I/O expander for I2C-bus with interrupt.
public Pcx857x(I2cDevice device, int interrupt = -1, GpioController gpioController = null, bool shouldDispose = true)
Parameters
device
I2cDeviceThe I2C device.
interrupt
intThe interrupt pin number, if present.
gpioController
GpioControllerThe GPIO controller for the
interrupt
. If not specified, the default controller will be used.shouldDispose
boolTrue to dispose the Gpio Controller
Properties
Device
I2C device used for communication with the device
protected I2cDevice Device { get; }
Property Value
Methods
AddCallbackForPinValueChangedEvent(int, PinEventTypes, PinChangeEventHandler)
Adds a handler for a pin value changed event.
protected override void AddCallbackForPinValueChangedEvent(int pinNumber, PinEventTypes eventTypes, PinChangeEventHandler callback)
Parameters
pinNumber
intThe pin number in the driver's logical numbering scheme.
eventTypes
PinEventTypesThe event types to wait for.
callback
PinChangeEventHandlerDelegate that defines the structure for callbacks when a pin value changed event occurs.
ClosePin(int)
Closes an open pin.
protected override void ClosePin(int pinNumber)
Parameters
pinNumber
intThe pin number in the driver's logical numbering scheme.
ConvertPinNumberToLogicalNumberingScheme(int)
Converts a board pin number to the driver's logical numbering scheme.
protected override int ConvertPinNumberToLogicalNumberingScheme(int pinNumber)
Parameters
pinNumber
intThe board pin number to convert.
Returns
- int
The pin number in the driver's logical numbering scheme.
Dispose(bool)
Disposes this instance
protected override void Dispose(bool disposing)
Parameters
disposing
boolTrue if explicitly disposing, false if in finalizer
GetPinMode(int)
Gets the mode of a pin.
protected override PinMode GetPinMode(int pinNumber)
Parameters
pinNumber
intThe pin number in the driver's logical numbering scheme.
Returns
- PinMode
The mode of the pin.
InternalReadUInt16()
Reads 16-bit unsigned integer from the device
protected ushort InternalReadUInt16()
Returns
- ushort
16-bit unsigned integer read from the device
InternalWriteUInt16(ushort)
Writes 16-bit unsigned integer to the device
protected void InternalWriteUInt16(ushort value)
Parameters
value
ushort16-vit unsigned integer to be written to the device
IsPinModeSupported(int, PinMode)
Checks if a pin supports a specific mode.
protected override bool IsPinModeSupported(int pinNumber, PinMode mode)
Parameters
pinNumber
intThe pin number in the driver's logical numbering scheme.
mode
PinModeThe mode to check.
Returns
- bool
The status if the pin supports the mode.
OpenPin(int)
Opens a pin in order for it to be ready to use. The driver attempts to open the pin without changing its mode or value.
protected override void OpenPin(int pinNumber)
Parameters
pinNumber
intThe pin number in the driver's logical numbering scheme.
Read(PinValuePair[])
Reads multiple pins from the device
public void Read(PinValuePair[] pinValues)
Parameters
pinValues
PinValuePair[]Pins and values to be read
Read(int)
Reads the current value of a pin.
protected override PinValue Read(int pinNumber)
Parameters
pinNumber
intThe pin number in the driver's logical numbering scheme.
Returns
- PinValue
The value of the pin.
ReadByte()
Reads byte from the device
public byte ReadByte()
Returns
- byte
Byte read from the device
RemoveCallbackForPinValueChangedEvent(int, PinChangeEventHandler)
Removes a handler for a pin value changed event.
protected override void RemoveCallbackForPinValueChangedEvent(int pinNumber, PinChangeEventHandler callback)
Parameters
pinNumber
intThe pin number in the driver's logical numbering scheme.
callback
PinChangeEventHandlerDelegate that defines the structure for callbacks when a pin value changed event occurs.
SetPinMode(int, PinMode)
Sets the mode to a pin.
protected override void SetPinMode(int pinNumber, PinMode mode)
Parameters
pinNumber
intThe pin number in the driver's logical numbering scheme.
mode
PinModeThe mode to be set.
Write(PinValuePair[])
Writes a value to a set of pins.
public void Write(PinValuePair[] pinValues)
Parameters
pinValues
PinValuePair[]
Write(int, PinValue)
Writes a value to a pin.
protected override void Write(int pinNumber, PinValue value)
Parameters
pinNumber
intThe pin number in the driver's logical numbering scheme.
value
PinValueThe value to be written to the pin.
WriteByte(byte)
Writes byte to the device
public void WriteByte(byte value)
Parameters
value
byteByte to be written to the device