Skip to content

Add support for Wire library for ESP-01 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Adafruit_MCP23017.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/***************************************************
/***************************************************
This is a library for the MCP23017 i2c port expander

These displays use I2C to communicate, 2 pins are required to
Expand Down Expand Up @@ -124,6 +124,22 @@ void Adafruit_MCP23017::begin(uint8_t addr) {
writeRegister(MCP23017_IODIRB,0xff);
}

#ifdef ESP8266
void Adafruit_MCP23017::begin(uint8_t addr, uint8_t sda, uint8_t sdc) {
if (addr > 7) {
addr = 7;
}
i2caddr = addr;

Wire.begin(sda, sdc);

// set defaults!
// all inputs on port A and B
writeRegister(MCP23017_IODIRA,0xff);
writeRegister(MCP23017_IODIRB,0xff);
}
#endif

/**
* Initializes the default MCP23017, with 000 for the configurable part of the address
*/
Expand Down Expand Up @@ -287,5 +303,3 @@ uint8_t Adafruit_MCP23017::getLastInterruptPinValue(){

return MCP23017_INT_ERR;
}


13 changes: 8 additions & 5 deletions Adafruit_MCP23017.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/***************************************************
/***************************************************
This is a library for the MCP23017 i2c port expander

These displays use I2C to communicate, 2 pins are required to
These displays use I2C to communicate, 2 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/

Expand All @@ -24,6 +24,9 @@
class Adafruit_MCP23017 {
public:
void begin(uint8_t addr);
#ifdef ESP8266
void begin(uint8_t addr, uint8_t sda, uint8_t sdc);
#endif
void begin(void);

void pinMode(uint8_t p, uint8_t d);
Expand Down