My Project
 All Classes Functions Variables Pages
Public Member Functions | List of all members
PCF8575 Class Reference

Encapsulate a PCF8575 device. More...

#include <PCF8575.h>

Public Member Functions

 PCF8575 (uint8_t address)
 Class constructor. More...
 
virtual ~PCF8575 ()
 Class instance destructor.
 
void init (gpio_num_t sdaPin=I2C::DEFAULT_SDA_PIN, gpio_num_t clkPin=I2C::DEFAULT_CLK_PIN)
 Initialize the PCF8575 device. More...
 
uint16_t read ()
 Read all the input bits from the device. More...
 
bool readBit (uint16_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 (uint16_t value)
 Set the output values of the device. More...
 
void writeBit (uint16_t bit, bool value)
 Change the output value of a specific pin. More...
 

Detailed Description

Encapsulate a PCF8575 device.

The PCF8575 is a 16 bit GPIO expander attached to I2C. It can read and write 16 bits of data and hence has 16 pins that can be used for input or output.

See Also
PCF8575 home page

Constructor & Destructor Documentation

PCF8575::PCF8575 ( 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]addressThe I2C address of the device on the I2C bus.

Member Function Documentation

void PCF8575::init ( gpio_num_t  sdaPin = I2C::DEFAULT_SDA_PIN,
gpio_num_t  clkPin = I2C::DEFAULT_CLK_PIN 
)

Initialize the PCF8575 device.

Parameters
[in]sdaPinThe pin to use for the I2C SDA functions.
[in]clkPinThe pin to use for the I2C CLK functions.
uint16_t PCF8575::read ( )

Read all the input bits from the device.

Returns
A 16 bit value representing the values on each of the input pins.
bool PCF8575::readBit ( uint16_t  bit)

Read the logic level on a given pin.

Parameters
[in]bitThe input pin of the device to read. Values are 0-15.
Returns
True if the pin is high, false otherwise. Undefined if there is no signal on the pin.
void PCF8575::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]valueTrue if we wish to invert the signals and false otherwise.
void PCF8575::write ( uint16_t  value)

Set the output values of the device.

Parameters
[in]valueThe bit pattern to set on the output.
void PCF8575::writeBit ( uint16_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]bitThe pin to have its value changed. The pin may be 0-15.
[in]valueThe logic level to appear on the identified output pin.

The documentation for this class was generated from the following files: