Propeller IO access object
Erik "SPIN" J.
Posts: 7
Hi everyone,
I made a little object that lets you transparently access both the Prop's internal IO pins, and IO pins connected through an I2C expander by simply numbering the pins higher (Pin 32 becomes the first pin on the first connected IO expander). I currently have support for the MCP23017, with PCA9555 support coming soon.
It's available on github here: https://github.com/ve4edj/propeller-io
Comments and criticism welcomed.
Erik
I made a little object that lets you transparently access both the Prop's internal IO pins, and IO pins connected through an I2C expander by simply numbering the pins higher (Pin 32 becomes the first pin on the first connected IO expander). I currently have support for the MCP23017, with PCA9555 support coming soon.
It's available on github here: https://github.com/ve4edj/propeller-io
Comments and criticism welcomed.
Erik
Comments
value &= 1 in PUB write and dir &= 1 in PUB direction are pretty much useless and just slow things down. PUB direction can use if dir ... else ... instead of if dir == INPUT ... if dir == OUTPUT. getExpIdx and getExpPin can be optimized by subtracting N_PROPPINS once as soon as it is determined that pin doesn't refer to a real pin in the calling function and then the / and // can be inlined into the calling function. I would also inline propPin and validPin. Also, the if validPin(pin) check should probably be removed from release code but is nice for debug code.
David
Like others, I think it's a great idea to virtualize pins beyond 31. Nicely done.