I've started using that pattern on new modules - basically having two connect... functions, and passing read and write functions into the constructor. I believe it's actually faster than the previous method as well.
In that case I'd keep the I2C function called just connect so it doesn't break existing code, but you could change the implementation such that the optional address could be supplied - which is always a nice bonus.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I'd suggest doing what's done here: https://github.com/espruino/EspruinoDocs/blob/master/devices/LIS2DH12.js#L135
I've started using that pattern on new modules - basically having two
connect...
functions, and passing read and write functions into the constructor. I believe it's actually faster than the previous method as well.In that case I'd keep the I2C function called just
connect
so it doesn't break existing code, but you could change the implementation such that the optional address could be supplied - which is always a nice bonus.