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.
© Espruino, powered by microcosm.
Report a problem