C# Класс CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider

This GPIO provider implements the PCF8574 I2C GPIO expansion board as native Pi4J GPIO pins. More information about the board can be found here: http://www.ti.com/lit/ds/symlink/pcf8574.pdf

The PCF8574 is connected via I2C connection to the Raspberry Pi and provides 8 GPIO pins that can be used for either digital input or digital output pins.
Наследование: IDisposable
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
PinPollFailed PinPollFailEventHandler
PinStateChanged PinStateChangeEventHandler

Открытые методы

Метод Описание
Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Call Dispose when you are finished using the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider. The Dispose method leaves the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider was occupying.

GetPinMode ( IPCF8574Pin pin ) : PinMode

Gets the mode of the specified pin.

GetPinState ( IPCF8574Pin pin ) : PinState

Gets the current state of the specified pin in the pin cache.

InterruptPoll ( ) : void

Interrupts a poll cycle (if running).

PCF8574GpioProvider ( II2CBus device, Int32 address ) : System

Initializes a new instance of the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider class with the I2C bus device that is the connection to the PCF8574, and the bus address of the device.

PCF8574GpioProvider ( Int32 address ) : System

Initializes a new instance of the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider class with the bus address of the device. This overload assumes a Rev 2 or higher board and creates a default I2C connection instance.

Poll ( ) : void

Polls the state of the all the pins once every ~50ms.

SetPinMode ( IPCF8574Pin pin, PinMode mode ) : void

Sets the mode of the specified pin.

SetPinState ( IPCF8574Pin pin, PinState state ) : void

Sets the state of the specified pin.

Защищенные методы

Метод Описание
OnPinPollFailed ( PinPollFailEventArgs e ) : void

Raises the PinPollFailed event.

OnPinStateChanged ( PinStateChangeEventArgs e ) : void

Raises the PinStateChanged event.

Приватные методы

Метод Описание
BackgroundExecutePoll ( ) : void

Executes the poll cycle on a background thread.

ExecutePoll ( ) : void

Polls all the pins on the PCF8574 every ~50ms and refreshes their states. This will fire a state change event for any and all pins that have changed state since the last check. This will also fire a failure event if any exceptions are thrown.

Описание методов

Dispose() публичный Метод

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Call Dispose when you are finished using the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider. The Dispose method leaves the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider was occupying.
public Dispose ( ) : void
Результат void

GetPinMode() публичный Метод

Gets the mode of the specified pin.
/// cannot be null. /// /// This instance has been disposed and can no longer be used. /// /// The specified pin does not exist in the pin cache. ///
public GetPinMode ( IPCF8574Pin pin ) : PinMode
pin IPCF8574Pin /// A pin in the pin cache to get the mode from. ///
Результат PinMode

GetPinState() публичный Метод

Gets the current state of the specified pin in the pin cache.
/// cannot be null. /// /// This instance has been disposed and can no longer be used. /// /// The specified pin does not exist in the pin cache. ///
public GetPinState ( IPCF8574Pin pin ) : PinState
pin IPCF8574Pin /// The pin to get the state from. ///
Результат PinState

InterruptPoll() публичный Метод

Interrupts a poll cycle (if running).
public InterruptPoll ( ) : void
Результат void

OnPinPollFailed() защищенный Метод

Raises the PinPollFailed event.
protected OnPinPollFailed ( PinPollFailEventArgs e ) : void
e PinPollFailEventArgs /// The event arguments. ///
Результат void

OnPinStateChanged() защищенный Метод

Raises the PinStateChanged event.
protected OnPinStateChanged ( PinStateChangeEventArgs e ) : void
e PinStateChangeEventArgs /// The event arguments. ///
Результат void

PCF8574GpioProvider() публичный Метод

Initializes a new instance of the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider class with the I2C bus device that is the connection to the PCF8574, and the bus address of the device.
public PCF8574GpioProvider ( II2CBus device, Int32 address ) : System
device II2CBus /// The I2C bus device that is the connection to the PCF8574. ///
address System.Int32 /// The bus address of the device. ///
Результат System

PCF8574GpioProvider() публичный Метод

Initializes a new instance of the CyrusBuilt.MonoPi.IO.PCF.PCF8574GpioProvider class with the bus address of the device. This overload assumes a Rev 2 or higher board and creates a default I2C connection instance.
public PCF8574GpioProvider ( Int32 address ) : System
address System.Int32 /// The bus address of the device. ///
Результат System

Poll() публичный Метод

Polls the state of the all the pins once every ~50ms.
/// This instance has been disposed and can no longer be used. ///
public Poll ( ) : void
Результат void

SetPinMode() публичный Метод

Sets the mode of the specified pin.
/// cannot be null. /// /// This instance has been disposed and can no longer be used. /// /// The specified pin does not exist in the pin cache. ///
public SetPinMode ( IPCF8574Pin pin, PinMode mode ) : void
pin IPCF8574Pin /// The pin to alter. ///
mode PinMode /// The mode to set. ///
Результат void

SetPinState() публичный Метод

Sets the state of the specified pin.
/// cannot be null. /// /// This instance has been disposed and can no longer be used. /// /// The specified pin does not exist in the pin cache. /// /// Failed to write the new state to the device. ///
public SetPinState ( IPCF8574Pin pin, PinState state ) : void
pin IPCF8574Pin /// The pin to alter. ///
state PinState /// The state of the pin to set. ///
Результат void

Описание свойств

PinPollFailed публичное свойство

Occurs if device polling fails.
public PinPollFailEventHandler PinPollFailed
Результат PinPollFailEventHandler

PinStateChanged публичное свойство

Occurs when a pin state changes.
public PinStateChangeEventHandler PinStateChanged
Результат PinStateChangeEventHandler