Skip to content

Override wire begin for ESP8266 to provide PINs #38

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
17 changes: 17 additions & 0 deletions Adafruit_MCP23017.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ void Adafruit_MCP23017::begin(uint8_t addr) {
writeRegister(MCP23017_IODIRB,0xff);
}

/**
* Initializes the MCP23017 given its HW selected address, see datasheet for Address selection.
*/
void Adafruit_MCP23017::begin(uint8_t addr, uint8_t sda_pin, uint8_t scl_pin) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't pass in pins. Instead, pass in a Wire object. See comment here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why pass wire object? then wire needs to be exposed to calling library also, now this can be hidden when only pins are provided.
given the multiple pull requests & issues opened i think this is the more preffered way of the community.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we wont' accept it, you must make the Wire object and pass it in, thats is the official Arduino library methodology

if (addr > 7) {
addr = 7;
}
i2caddr = addr;

Wire.begin(sda_pin, scl_pin);

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

/**
* Initializes the default MCP23017, with 000 for the configurable part of the address
*/
Expand Down
1 change: 1 addition & 0 deletions Adafruit_MCP23017.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
class Adafruit_MCP23017 {
public:
void begin(uint8_t addr);
void begin(uint8_t addr, uint8_t sda_pin, uint8_t scl_pin);
void begin(void);

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