mirror of
https://github.com/xreef/PCF8574_library.git
synced 2024-08-30 18:12:18 +00:00
digitalWriteAll
This commit is contained in:
parent
5a60c45ed9
commit
b7655a7735
61
PCF8574.cpp
61
PCF8574.cpp
@ -679,4 +679,65 @@ bool PCF8574::digitalWrite(uint8_t pin, uint8_t value){
|
||||
return this->isLastTransmissionSuccess();
|
||||
};
|
||||
|
||||
#ifndef PCF8574_LOW_MEMORY
|
||||
/**
|
||||
* Read value of all INPUT pin
|
||||
* Debounce read more fast than 10millis, non managed for interrupt mode
|
||||
* @return
|
||||
*/
|
||||
void PCF8574::setVal(uint8_t pin, uint8_t value){
|
||||
if (value==HIGH){
|
||||
writeByteBuffered = writeByteBuffered | bit(pin);
|
||||
byteBuffered = writeByteBuffered | bit(pin);
|
||||
}else{
|
||||
writeByteBuffered = writeByteBuffered & ~bit(pin);
|
||||
byteBuffered = writeByteBuffered & ~bit(pin);
|
||||
}
|
||||
|
||||
}
|
||||
bool PCF8574::digitalWriteAll(PCF8574::DigitalInput digitalInput){
|
||||
|
||||
setVal(0, digitalInput.p0);
|
||||
setVal(1, digitalInput.p1);
|
||||
setVal(2, digitalInput.p2);
|
||||
setVal(3, digitalInput.p3);
|
||||
setVal(4, digitalInput.p4);
|
||||
setVal(5, digitalInput.p5);
|
||||
setVal(6, digitalInput.p6);
|
||||
setVal(7, digitalInput.p7);
|
||||
|
||||
return digitalWriteAllBytes(writeByteBuffered);
|
||||
}
|
||||
#else
|
||||
bool PCF8574::digitalWriteAll(byte digitalInput){
|
||||
return digitalWriteAllBytes(digitalInput);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool PCF8574::digitalWriteAllBytes(byte allpins){
|
||||
_wire->beginTransmission(_address); //Begin the transmission to PCF8574
|
||||
|
||||
// writeByteBuffered = writeByteBuffered & (~writeMode & byteBuffered);
|
||||
writeByteBuffered = allpins;
|
||||
byteBuffered = (writeByteBuffered & writeMode) | (resetInitial & readMode);
|
||||
|
||||
// byteBuffered = (writeByteBuffered & writeMode) | (byteBuffered & readMode);
|
||||
DEBUG_PRINT(" byteBuffered ");
|
||||
DEBUG_PRINTLN(byteBuffered, BIN);
|
||||
|
||||
DEBUG_PRINT("Going to write data ");
|
||||
DEBUG_PRINTLN(writeByteBuffered, BIN);
|
||||
|
||||
_wire->write(byteBuffered);
|
||||
|
||||
byteBuffered = (writeByteBuffered & writeMode) | (initialBuffer & readMode);
|
||||
|
||||
// byteBuffered = (writeByteBuffered & writeMode) & (byteBuffered & readMode);
|
||||
DEBUG_PRINTLN("Start end trasmission if stop here check pullup resistor.");
|
||||
|
||||
this->transmissionStatus = _wire->endTransmission();
|
||||
|
||||
return this->isLastTransmissionSuccess();
|
||||
|
||||
}
|
||||
|
@ -144,8 +144,11 @@ public:
|
||||
|
||||
|
||||
DigitalInput digitalReadAll(void);
|
||||
|
||||
bool digitalWriteAll(PCF8574::DigitalInput digitalInput);
|
||||
#else
|
||||
byte digitalReadAll(void);
|
||||
bool digitalWriteAll(byte digitalInput);
|
||||
#endif
|
||||
bool digitalWrite(uint8_t pin, uint8_t value);
|
||||
|
||||
@ -215,6 +218,9 @@ private:
|
||||
byte validCCW = B11100001;
|
||||
|
||||
uint8_t transmissionStatus = 0;
|
||||
|
||||
void setVal(uint8_t pin, uint8_t value);
|
||||
bool digitalWriteAllBytes(byte allpins);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user