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.

  • I can understand where

    all have a consistent API and provided pin objects with read/write/set/reset/mode methods so they worked with the standard functions

    is coming from.

    For enhanced functionality though, I cannot really go for it, because having hardware moved out into a chip, and try in the module to ignore that make the module completely inflated and cumbersome. It is a pain to impose an architecture on an a different one - structurally and behaviorally.

    Said so does not include having both: support the expander efficiently in its architecture and to support Pin behavior for simple input and output as Espruino does it.

    I can see my position revised when the portexpander ins integrated natively where things such as digital read and write to pin arrays and clear/setWatch are handled with the knowledge of these capabilities. Why? If you have to setup a complete serial communication multiple times when you can do it in one makes not much sense and worsens the performance experience.

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

IO Extender PCF8574X

Posted by Avatar for MaBe @MaBe

Actions