Skip to content

Commit a3db6cd

Browse files
committed
- 01/02/2024: v2.3.7 Add the possibility to insert address at begin()
1 parent f281abe commit a3db6cd

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

PCF8575.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,18 @@ PCF8575::PCF8575(uint8_t address, uint8_t interruptPin, void (*interruptFunctio
154154
};
155155
#endif
156156

157+
bool PCF8575::begin(uint8_t address){
158+
_address = address;
159+
return PCF8575::begin();
160+
}
161+
162+
157163
/**
158164
* wake up i2c controller
159165
*/
160-
void PCF8575::begin(){
166+
bool PCF8575::begin(){
167+
this->transmissionStatus = 4;
168+
161169
#if !defined(__AVR) && !defined(ARDUINO_ARCH_SAMD) && !defined(TEENSYDUINO) && !defined(ARDUINO_ARCH_RENESAS)
162170
DEBUG_PRINT(F("begin(sda, scl) -> "));DEBUG_PRINT(_sda);DEBUG_PRINT(F(" "));DEBUG_PRINTLN(_scl);
163171
// _wire->begin(_sda, _scl);
@@ -196,7 +204,7 @@ void PCF8575::begin(){
196204
_wire->write((uint8_t) (~(usedPin >> 8)));
197205

198206
DEBUG_PRINTLN("Start end trasmission if stop here check pullup resistor.");
199-
_wire->endTransmission();
207+
this->transmissionStatus = _wire->endTransmission();
200208
}
201209

202210
// If using interrupt set interrupt value to pin
@@ -208,6 +216,8 @@ void PCF8575::begin(){
208216

209217
// inizialize last read
210218
lastReadMillis = millis();
219+
220+
return this->isLastTransmissionSuccess();
211221
}
212222

213223
/**

PCF8575.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ class PCF8575 {
132132
PCF8575(TwoWire *pWire, uint8_t address, int sda, int scl, uint8_t interruptPin, void (*interruptFunction)());
133133
#endif
134134

135-
void begin();
135+
bool begin();
136+
bool begin(uint8_t address);
136137
void pinMode(uint8_t pin, uint8_t mode);
137138

138139
void readBuffer(bool force = true);
@@ -182,6 +183,11 @@ class PCF8575 {
182183
uint16_t digitalReadAll(void);
183184
#endif
184185
void digitalWrite(uint8_t pin, uint8_t value);
186+
bool isLastTransmissionSuccess(){
187+
DEBUG_PRINT(F("STATUS --> "));
188+
DEBUG_PRINTLN(transmissionStatus);
189+
return transmissionStatus==0;
190+
}
185191

186192
private:
187193
uint8_t _address;
@@ -225,6 +231,9 @@ class PCF8575 {
225231

226232
uint16_t writeByteBuffered = 0;
227233

234+
uint8_t transmissionStatus = 0;
235+
236+
228237
};
229238

230239
#endif

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
Library to use i2c analog IC with arduino and esp8266. Can read and write digital value with only 2 wire (perfect for ESP-01).
1717

18+
- 01/02/2024: v1.1.2 Add the possibility to insert address at begin() function and return status of begin operation
1819
- 10/07/2023: v1.1.1 Add support for Arduino UNO R4
1920
- 16/02/2023: v1.1.0
2021
- Fix STM32 support and add support for Raspberry Pi Pico and other rp2040 boards

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "PCF8575 library",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"keywords": "digital, i2c, encoder, expander, pcf8575, pcf8575a, esp32, esp8266, stm32, SAMD, Arduino, wire, Raspberry, rp2040",
55
"description": "PCF8575 library. i2c digital expander for i2c digital expander for Arduino, Raspberry Pi Pico and rp2040 boards, esp32, SMT32 and ESP8266. Can read write digital values with only 2 wire. Very simple to use and encoder support.",
66
"homepage": "https://www.mischianti.org/2019/07/22/pcf8575-i2c-16-bit-digital-i-o-expander/",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=PCF8575 library
2-
version=1.1.1
2+
version=1.1.2
33
author=Renzo Mischianti <[email protected]>
44
maintainer=Renzo Mischianti <[email protected]>
55
sentence=PCF8575, library for Arduino, Raspberry Pi Pico and rp2040 boards, esp32, SMT32 and ESP8266.

0 commit comments

Comments
 (0)