It's a good approach to scan only after an interrupt happened.
Regarding the setting and reading of pins, array is of help. Unfortunately, setting pin modes has to happen pin by pin. I once had asked @Gordon to also consider the array for setting pin mode the same way as reading and writing to pins goes.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@27percent,
I'm sure you already read thru the conversation about Exploring adding setWatch/clearWatch (interrupt handling) to MCP23017 (MCP2308) Portexpander Ports
and its related conversations.
It's a good approach to scan only after an interrupt happened.
Regarding the setting and reading of pins, array is of help. Unfortunately, setting pin modes has to happen pin by pin. I once had asked @Gordon to also consider the array for setting pin mode the same way as reading and writing to pins goes.
I used similar approach - setWatch() and scanning after event - for resistive touch screen without driver (Espruino is directly driving and reading the 4 electrodes of a resistive touch screen: Resistive Touchscreen directly (no touch controller)). I later used it in the UI modules http://www.espruino.com/ui (how come is in conversation: Modular and extensible UI framework and ui elements.).