You are reading a single comment by @DrAzzy and its replies. Click here to read the full conversation.
  • Are you working on a module for this?

    I had a thought....

    Wouldn't it be cool if when you called MCP23017.connect() it would return an object with 16 members, each with set(), unset() etc methods, ie like this: http://www.espruino.com/Reference#Pin

    ie:

    {"A0":{"set":function.....},"A1"...}

    Then, you could use them just like any other pin...

    so:
    var pe=MCP23017.connect(I2C1);
    var lcd = require("HD44780").connect(pe.B7,pe.B5,p­e.B4,pe.B3,pe.B2,pe.B1);

    Right now though, the pin class doesn't have enough functionality to do that for all cases (though it's fine for this case).
    We would need a pin.mode() function on the normal pin class. (also, I'd like to see pin.write() do analogWrite for values between 0 and 1, though that's not relevant in this context - it would be cool - so you could use pin.whatever() instead of the arduino-style functions (which are sort of counter to the ideals of espruino anyway))

    But even with the current pin class (lacking pin.mode() ), this could be made really painless to use with this LCD display and a lot of other modules. The modifications to the HD44780 module should be almost trivial.

    Writing the MCP23017 module to return things that act like pins, not so trivial - but imo it's clearly the Right Way to do a module for a port expander.

About

Avatar for DrAzzy @DrAzzy started