Looks good - would it be possible to tweak the names a little (and add a connect function) so it had a similar API to http://www.espruino.com/MCP23xxx - using read(pin) etc? It'd just be nice for users to be able to swap between different port expanders without changing code.
Also, if you were able to add fields for A0..A7 which themselves were instances of a class with read/write fields then you could actually pass them into quite a few other modules as if they were normal Pins.
For example digitalWrite(expander.A0, 1) would just magically work.
© Espruino, powered by microcosm.
Report a problem