#ifndef PCF8574_H
#define PCF8574_H
#include <Arduino.h>
#include <Wire.h>

/***
* A very simple class to drive a PCF8574 chip
* 
* Anatole SCHRAMM-HENRY -- Th3maz1ng
***/

class PCF8574
{
  public:
    enum Pin{P0 = 1, P1 = 2, P2 = 4, P3 = 8, P4 = 16, P5 = 32, P6 = 64, P7 = 128};
    
    PCF8574(uint8_t address, TwoWire &twc = Wire);
    boolean begin();
    void pinMode(Pin pin, boolean mode = INPUT);
    void digitalWrite(Pin pin, boolean mode);
    boolean digitalRead(Pin pin);
	void digitalReadAll(boolean array[]);
	boolean getPinMode(Pin pin);
	void getPinModeAll(boolean array[]);
	void togglePin(Pin pin);
  private:
    TwoWire &_twc;
    uint8_t _address;
    uint8_t _pinConfig;
	uint8_t _pddr;
  protected: 
};

#endif //PCF8574_H
