-
Notifications
You must be signed in to change notification settings - Fork 40
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
Possible to use TwoWire as software I2C #7
Comments
Hi @ScholliYT Then simply pass your instance in the constructor. So my guess would be : #include "SoftwareI2C.h"
SoftwareI2C softwarei2c;
MCP23017 mcp = MCP23017(0x24, softwarei2c);
void setup()
{
softwarei2c.begin(3, 2); // sda, scl
} |
Thank you 👍 I've got my problem fixed without software serial but I will try it out anyway. |
Hi @ScholliYT . Have you had the opportunity to test the library with SoftwareI2C yet ? |
Nope, sorry. Didn't have any time to test it. But it's still on my ToDo-List. Maybe you can give it a try yourself. |
I moved home recently and I haven't had the opportunity to do some devs/electronics since then. No rush though :) Thanks |
Unfortunately this nice feature of this library cannot be used at the moment, due to a shortcoming of the original Wire.h library. I have opened this issue on a Software I2C library to detail the exact issue, so please see there. There is already an open issue on the Arduino Core. Everybody who is interested in this please add a thumbs up there. |
Arf, that's a shame ! This as s kinda strange cause I didn't came with this idea out of the blue of course. I actually took it from another library, but I can't remember which one. I'm not sure, but wouldn't a templated version of the library solve this issue ? |
I've also realized it could be made to work using a template, but I see it more as a workaround rather than the proper solution. So I would first try to get this solved in Wire.h by voting and commenting the issue I've linked above. Then, if we get nowhere with that, we can switch to a template. For my own needs, I have temporarily modified this library so that it uses that software implementation, and I can live with that for a while. |
Wooldn‘t it be nice being more general. The chip also has a SPI interface in the mcp23S17 version. When we think about software serial there could be also the hardware and software SPI option too; either in different constructors or a special class. |
That could be interesting, but I think it should be filed as a different Feature Request. At the moment this is a library for the i2c version of the chip, you are asking to turn it into one for both the i2c and SPI versions. It's also quite a bit of work, actually :). |
Sure, but if we talk about concepts, we should have that in focus... |
Until ArduinoCore API #31 is solved, nothing can be done here. A templated class isn't a solution either cause Arduino C++ does not support type constraints based on concepts. Feel free to reopen the day something new has occured about this :) |
Can you give an example on how to use your lib with software i2c? In my project I got the i2c blocked for other parts and want to use your lib to controll a mcp23017. I'm using an ESP32 Dev Board.
arduino-mcp23017/src/MCP23017.cpp
Line 3 in 346e14d
The text was updated successfully, but these errors were encountered: