Added the togglePin method to the library

This commit is contained in:
Anatole SCHRAMM 2019-05-02 17:20:52 +02:00
parent 8ab1f45013
commit cfa7192f5f
2 changed files with 14 additions and 0 deletions

View File

@ -51,6 +51,19 @@ void PCF8574::digitalWrite(Pin pin, boolean mode)
_twc.endTransmission();
}
void PCF8574::togglePin(Pin pin)
{
//We first check that the pin is an output
if((_pddr & pin) == 0)
return;
_pinConfig = (_pinConfig & pin) == 0 ? _pinConfig | pin : _pinConfig & ~pin;
_twc.beginTransmission(_address);
_twc.write(_pinConfig);
_twc.endTransmission();
}
boolean PCF8574::digitalRead(Pin pin)
{
uint8_t reg = 0b00000000;

View File

@ -22,6 +22,7 @@ class PCF8574
void digitalReadAll(boolean array[]);
boolean getPinMode(Pin pin);
void getPinModeAll(boolean array[]);
void togglePin(Pin pin);
private:
TwoWire &_twc;
uint8_t _address;