Added the togglePin method to the library
This commit is contained in:
parent
8ab1f45013
commit
cfa7192f5f
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user