Skip to content

Commit

Permalink
- 01/02/2024: v2.3.7 Add the possibility to insert address at begin()
Browse files Browse the repository at this point in the history
  • Loading branch information
xreef committed Feb 1, 2024
1 parent f281abe commit a3db6cd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
14 changes: 12 additions & 2 deletions PCF8575.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,18 @@ PCF8575::PCF8575(uint8_t address, uint8_t interruptPin, void (*interruptFunctio
};
#endif

bool PCF8575::begin(uint8_t address){
_address = address;
return PCF8575::begin();
}


/**
* wake up i2c controller
*/
void PCF8575::begin(){
bool PCF8575::begin(){
this->transmissionStatus = 4;

#if !defined(__AVR) && !defined(ARDUINO_ARCH_SAMD) && !defined(TEENSYDUINO) && !defined(ARDUINO_ARCH_RENESAS)
DEBUG_PRINT(F("begin(sda, scl) -> "));DEBUG_PRINT(_sda);DEBUG_PRINT(F(" "));DEBUG_PRINTLN(_scl);
// _wire->begin(_sda, _scl);
Expand Down Expand Up @@ -196,7 +204,7 @@ void PCF8575::begin(){
_wire->write((uint8_t) (~(usedPin >> 8)));

DEBUG_PRINTLN("Start end trasmission if stop here check pullup resistor.");
_wire->endTransmission();
this->transmissionStatus = _wire->endTransmission();
}

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

// inizialize last read
lastReadMillis = millis();

return this->isLastTransmissionSuccess();
}

/**
Expand Down
11 changes: 10 additions & 1 deletion PCF8575.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ class PCF8575 {
PCF8575(TwoWire *pWire, uint8_t address, int sda, int scl, uint8_t interruptPin, void (*interruptFunction)());
#endif

void begin();
bool begin();
bool begin(uint8_t address);
void pinMode(uint8_t pin, uint8_t mode);

void readBuffer(bool force = true);
Expand Down Expand Up @@ -182,6 +183,11 @@ class PCF8575 {
uint16_t digitalReadAll(void);
#endif
void digitalWrite(uint8_t pin, uint8_t value);
bool isLastTransmissionSuccess(){
DEBUG_PRINT(F("STATUS --> "));
DEBUG_PRINTLN(transmissionStatus);
return transmissionStatus==0;
}

private:
uint8_t _address;
Expand Down Expand Up @@ -225,6 +231,9 @@ class PCF8575 {

uint16_t writeByteBuffered = 0;

uint8_t transmissionStatus = 0;


};

#endif
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

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

- 01/02/2024: v1.1.2 Add the possibility to insert address at begin() function and return status of begin operation
- 10/07/2023: v1.1.1 Add support for Arduino UNO R4
- 16/02/2023: v1.1.0
- Fix STM32 support and add support for Raspberry Pi Pico and other rp2040 boards
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "PCF8575 library",
"version": "1.1.1",
"version": "1.1.2",
"keywords": "digital, i2c, encoder, expander, pcf8575, pcf8575a, esp32, esp8266, stm32, SAMD, Arduino, wire, Raspberry, rp2040",
"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.",
"homepage": "https://www.mischianti.org/2019/07/22/pcf8575-i2c-16-bit-digital-i-o-expander/",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=PCF8575 library
version=1.1.1
version=1.1.2
author=Renzo Mischianti <[email protected]>
maintainer=Renzo Mischianti <[email protected]>
sentence=PCF8575, library for Arduino, Raspberry Pi Pico and rp2040 boards, esp32, SMT32 and ESP8266.
Expand Down

0 comments on commit a3db6cd

Please sign in to comment.