My Project
 All Classes Functions Variables Pages
PCF8574.h
1 /*
2  * PCF8574.h
3  *
4  * Created on: Mar 2, 2017
5  * Author: kolban
6  */
7 
8 #ifndef COMPONENTS_CPP_UTILS_PCF8574_H_
9 #define COMPONENTS_CPP_UTILS_PCF8574_H_
10 #include "I2C.h"
11 
20 class PCF8574 {
21 public:
22  PCF8574(uint8_t address);
23  virtual ~PCF8574();
24  void init(gpio_num_t sdaPin = I2C::DEFAULT_SDA_PIN, gpio_num_t clkPin = I2C::DEFAULT_CLK_PIN);
25  uint8_t read();
26  bool readBit(uint8_t bit);
27  void setInvert(bool value);
28  void write(uint8_t value);
29  void writeBit(uint8_t bit, bool value);
30 
31 private:
32  I2C* i2c;
33  uint8_t lastWrite;
34  bool invert = false;
35 
36 };
37 
38 #endif /* COMPONENTS_CPP_UTILS_PCF8574_H_ */
static const gpio_num_t DEFAULT_SDA_PIN
The default SDA pin.
Definition: I2C.h:24
bool readBit(uint8_t bit)
Read the logic level on a given pin.
Definition: PCF8574.cpp:54
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: PCF8574.cpp:107
PCF8574(uint8_t address)
Class constructor.
Definition: PCF8574.cpp:20
void write(uint8_t value)
Set the output values of the device.
Definition: PCF8574.cpp:66
void init(gpio_num_t sdaPin=I2C::DEFAULT_SDA_PIN, gpio_num_t clkPin=I2C::DEFAULT_CLK_PIN)
Initialize the PCF8574 device.
Definition: PCF8574.cpp:118
static const gpio_num_t DEFAULT_CLK_PIN
The default Clock pin.
Definition: I2C.h:29
virtual ~PCF8574()
Class instance destructor.
Definition: PCF8574.cpp:30
Interface to I2C functions.
Definition: I2C.h:19
Encapsulate a PCF8574 device.
Definition: PCF8574.h:20
void writeBit(uint8_t bit, bool value)
Change the output value of a specific pin.
Definition: PCF8574.cpp:86
uint8_t read()
Read all the input bits from the device.
Definition: PCF8574.cpp:39