mattjlewis / diozero

Java Device I/O library that is portable across Single Board Computers and microcontrollers. Tested with Raspberry Pi, Odroid C2, BeagleBone Black, Next Thing CHIP, Asus Tinker Board and Arduinos / Pico. Supports GPIO, I2C, SPI as well as Serial communication. Also known to work with Udoo Quad.
https://www.diozero.com
MIT License
261 stars 59 forks source link

Do not set all pins on MCP23xxx to zero when initialising #99

Closed jozala closed 1 year ago

jozala commented 2 years ago

I would like to avoid setting all pins of MCP23xxx on application start. It is possible to set pins values to zero if needed, after initialisation. However, when all pins are set to off during initialisation, it may cause some side effects (like lights blinking) on application restart. In my case, on application restart, lights are turned on (relays) and window shutters get open. I would like to avoid this behaviour by removing this code from initialisation.

Alternatively, I could prepare a separate constructor for MCP23017 to let the developer decide if he wants to turn off all pins on initialisation.

What do you think?