The SX1509 class interfaces with the SX1509 IO expander. It sits on the I2C bus and data can be directed to the connected devices via its I2C address. Interrupts from the devices can be fed back to the imp via the configured imp hardware pin.
The constructor requires the i2c bus, the address on that bus and the hardware pin to use for interrupts. These should all be configured before calling the constructor.
Write registers to default values
Returns the register numbers for the bank that the given gpio is on
Configure whether edges trigger an interrupt for specified GPIO
Resets all the IRQs
Read all the IRQs as a single 16-bit bitmap
Sets the clock
Enable or disable the LED drivers
Sets the Time On value for the LED register
Sets the On Intensity level LED register
Sets the Time Off value for the LED register
Sets the Rise Time value for the LED register
Sets the Fall Time value for the LED register
Set or clear a selected GPIO pin, 0-16
Configure specified GPIO pin as input(0) or output(1)
Enable or disable input buffers
Enable or disable open drain
Enable or disable internal pull up resistor for specified GPIO
Enable or disable internal pull down resistor for specified GPIO
Configure whether specified GPIO will trigger an interrupt
Clear interrupt on specified GPIO
Get state of specified GPIO
Resets the device with a software reset
Configure which callback should be called for each pin transition
The ExpGPIO class is a convenience class that simplifies the configuration of a IO Expander GPIO port. You can use it in a similar manner to hardware.pin with two main differences:
- There is a new pin type: LED_OUT, for controlling LED brightness (basically PWM_OUT with "breathing")
- The pin events will include the pin state as the one parameter to the callback
Constructor requires the IO Expander class and the pin number to aquire
Configure pin by passing in a mode constant. Supported modes are: DIGITAL_OUT, ExpGPIO.LED_OUT, DIGITAL_IN, or DIGITAL_IN_PULLUP. Optional param is either the initial state of the pin (defaults to 0 just like the imp) if configured as an output, or a callback function if mode is configured as an input.
Reads the status of the configured pin
Sets the state of the configured pin
Set the intensity of an LED OUT pin. Don't use for other pin types
Set the blink rate of an LED OUT pin. Don't use for other pin types
Enable or disable fading (breathing)
This code is licensed under the MIT License.