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 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.
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 - usingread(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 withread
/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.