My Project
 All Classes Functions Variables Pages
PCF8575.h
1 /*
2  * PCF8575.h
3  *
4  * Created on: Jan 27, 2018
5  * Author: kolban
6  */
7 
8 #ifndef COMPONENTS_CPP_UTILS_PCF8575_H_
9 #define COMPONENTS_CPP_UTILS_PCF8575_H_
10 #include "I2C.h"
11 
20 class PCF8575 {
21 public:
22  PCF8575(uint8_t address);
23  virtual ~PCF8575();
24  void init(gpio_num_t sdaPin = I2C::DEFAULT_SDA_PIN, gpio_num_t clkPin = I2C::DEFAULT_CLK_PIN);
25  uint16_t read();
26  bool readBit(uint16_t bit);
27  void setInvert(bool value);
28  void write(uint16_t value);
29  void writeBit(uint16_t bit, bool value);
30 
31 private:
32  I2C* i2c;
33  uint16_t m_lastWrite;
34  bool invert = false;
35 };
36 
37 #endif /* COMPONENTS_CPP_UTILS_PCF8575_H_ */
bool readBit(uint16_t bit)
Read the logic level on a given pin.
Definition: PCF8575.cpp:56
void write(uint16_t value)
Set the output values of the device.
Definition: PCF8575.cpp:68
static const gpio_num_t DEFAULT_SDA_PIN
The default SDA pin.
Definition: I2C.h:24
void writeBit(uint16_t bit, bool value)
Change the output value of a specific pin.
Definition: PCF8575.cpp:89
Encapsulate a PCF8575 device.
Definition: PCF8575.h:20
void setInvert(bool value)
Invert the bit values. Normally setting a pin's value to 1 means that a high signal is generated and ...
Definition: PCF8575.cpp:110
static const gpio_num_t DEFAULT_CLK_PIN
The default Clock pin.
Definition: I2C.h:29
void init(gpio_num_t sdaPin=I2C::DEFAULT_SDA_PIN, gpio_num_t clkPin=I2C::DEFAULT_CLK_PIN)
Initialize the PCF8575 device.
Definition: PCF8575.cpp:121
uint16_t read()
Read all the input bits from the device.
Definition: PCF8575.cpp:40
Interface to I2C functions.
Definition: I2C.h:19
virtual ~PCF8575()
Class instance destructor.
Definition: PCF8575.cpp:31
PCF8575(uint8_t address)
Class constructor.
Definition: PCF8575.cpp:21