IO Extender PCF8574X

Posted on
  • Please feel free to comment or revise this module for the PCF8574X

    Thanks in advanced for all your comments and suggestions to make this module robust and complete to find it's way into the huge hall of modules ;-)

  • 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.

  • I agree with @Gordon here - port expanders are much more useful if they all have a consistent API and provided pin objects with read/write/set/reset/mode methods so they worked with the standard functions.

    That sort of thing is one of the ways that Espruino is a lot more friendly than Arduino.

    On a related note - is there a method of a pin object for analogRead/analogWrite? It doesn't look like there is - maybe there should be? It would be neat for those PWM-capable port expanders, and external ADC chips.... though maybe the complexities and limitations of those parts would make this less useful than it seems at first glance.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

IO Extender PCF8574X

Posted by Avatar for MaBe @MaBe

Actions