Skip to content
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

Constructor bus/address arguments not used #1

Open
ionothanus opened this issue Aug 13, 2020 · 1 comment · May be fixed by #2
Open

Constructor bus/address arguments not used #1

ionothanus opened this issue Aug 13, 2020 · 1 comment · May be fixed by #2

Comments

@ionothanus
Copy link

FYI I was trying to use this for a project and ran into a small issue.

Specifying bus and address arguments on the CharLCD constructor does not work - the defaults of 8 and 0x20 are always used.

CharLCD/src/CharLCD.cpp

Lines 30 to 31 in de50068

CharLCD::CharLCD(int bus, int address) {
MCP23017 _i2c(bus, address);

This does not initialize CharLCD::_i2c (the member variable), but instead creates a local named _i2c that is discarded when the constructor returns. The member variable is then default-initialized using the default MCP23017 constructor, which specifies bus 8 and address 0x20.

This resolves the issue:

 CharLCD::CharLCD(int bus, int address)
    : _i2c(bus, address)
 {
    //...

I can make a pull request if you'd like, just let me know.

@dehavenm
Copy link
Owner

I would appreciate that, thank you.

@ionothanus ionothanus linked a pull request Sep 24, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants