Encapsulate a PCF8574 device.
More...
#include <PCF8574.h>
|
| | PCF8574 (uint8_t address) |
| | Class constructor. More...
|
| |
|
virtual | ~PCF8574 () |
| | Class instance destructor.
|
| |
| void | init (gpio_num_t sdaPin=I2C::DEFAULT_SDA_PIN, gpio_num_t clkPin=I2C::DEFAULT_CLK_PIN) |
| | Initialize the PCF8574 device. More...
|
| |
| uint8_t | read () |
| | Read all the input bits from the device. More...
|
| |
| bool | readBit (uint8_t bit) |
| | Read the logic level on a given pin. More...
|
| |
| void | setInvert (bool value) |
| | Invert the bit values. Normally setting a pin's value to 1 means that a high signal is generated and a 0 means a low signal is generated. Setting the inversion to true, inverts that meaning. More...
|
| |
| void | write (uint8_t value) |
| | Set the output values of the device. More...
|
| |
| void | writeBit (uint8_t bit, bool value) |
| | Change the output value of a specific pin. More...
|
| |
Encapsulate a PCF8574 device.
The PCF8574 is a 8 bit GPIO expander attached to I2C. It can read and write 8 bits of data and hence has 8 pins that can be used for input or output.
- See Also
- PCF8574 home page
| PCF8574::PCF8574 |
( |
uint8_t |
address | ) |
|
Class constructor.
The address is the address of the device on the I2C bus. This is the value 0x20 plus the value of the device input pins A0, A1 and A2. This means that the address should be between 0x20 and 0x27.
- Parameters
-
| [in] | address | The I2C address of the device on the I2C bus. |
Initialize the PCF8574 device.
- Parameters
-
| [in] | sdaPin | The pin to use for the I2C SDA functions. |
| [in] | clkPin | The pin to use for the I2C CLK functions. |
| uint8_t PCF8574::read |
( |
| ) |
|
Read all the input bits from the device.
- Returns
- An 8 bit value representing the values on each of the input pins.
| bool PCF8574::readBit |
( |
uint8_t |
bit | ) |
|
Read the logic level on a given pin.
- Parameters
-
| [in] | bit | The input pin of the device to read. Values are 0-7. |
- Returns
- True if the pin is high, false otherwise. Undefined if there is no signal on the pin.
| void PCF8574::setInvert |
( |
bool |
value | ) |
|
Invert the bit values. Normally setting a pin's value to 1 means that a high signal is generated and a 0 means a low signal is generated. Setting the inversion to true, inverts that meaning.
- Parameters
-
| [in] | value | True if we wish to invert the signals and false otherwise. |
| void PCF8574::write |
( |
uint8_t |
value | ) |
|
Set the output values of the device.
- Parameters
-
| [in] | value | The bit pattern to set on the output. |
| void PCF8574::writeBit |
( |
uint8_t |
bit, |
|
|
bool |
value |
|
) |
| |
Change the output value of a specific pin.
The other bits beyond the one setting retain their values from the previous call to write() or previous calls to writeBit().
- Parameters
-
| [in] | bit | The pin to have its value changed. The pin may be 0-7. |
| [in] | value | The logic level to appear on the identified output pin. |
The documentation for this class was generated from the following files: