diff --git a/README.rst b/README.rst index 4647b3e..a97e0f5 100644 --- a/README.rst +++ b/README.rst @@ -49,6 +49,9 @@ Dependencies This driver depends on: * `Adafruit CircuitPython `_ +* `Adafruit CircuitPython BusDevice `_ +* `Adafruit CircuitPython MCP230xx `_ +* `Adafruit CircuitPython 74HC595 `_ I2C & SPI displays also depend on: diff --git a/adafruit_character_lcd/character_lcd_i2c.py b/adafruit_character_lcd/character_lcd_i2c.py index ec5d8a6..74cf0bb 100644 --- a/adafruit_character_lcd/character_lcd_i2c.py +++ b/adafruit_character_lcd/character_lcd_i2c.py @@ -71,14 +71,14 @@ def __init__(self, i2c, columns, lines, backlight_inverted=False): on the specified I2C bus with the specified number of columns and lines on the display. Optionally specify if backlight is inverted. """ - import adafruit_mcp230xx - self._mcp = adafruit_mcp230xx.MCP23008(i2c) - reset = self._mcp.get_pin(1) - enable = self._mcp.get_pin(2) - db4 = self._mcp.get_pin(3) - db5 = self._mcp.get_pin(4) - db6 = self._mcp.get_pin(5) - db7 = self._mcp.get_pin(6) - backlight_pin = self._mcp.get_pin(7) - super().__init__(reset, enable, db4, db5, db6, db7, columns, lines, - backlight_pin=backlight_pin, backlight_inverted=backlight_inverted) + from adafruit_mcp230xx.mcp23008 import MCP23008 + mcp = MCP23008(i2c) + super().__init__(mcp.get_pin(1), + mcp.get_pin(2), + mcp.get_pin(3), + mcp.get_pin(4), + mcp.get_pin(5), + mcp.get_pin(6), + columns, lines, + backlight_pin=mcp.get_pin(7), + backlight_inverted=backlight_inverted) diff --git a/adafruit_character_lcd/character_lcd_rgb_i2c.py b/adafruit_character_lcd/character_lcd_rgb_i2c.py index 1377131..c6cfe57 100644 --- a/adafruit_character_lcd/character_lcd_rgb_i2c.py +++ b/adafruit_character_lcd/character_lcd_rgb_i2c.py @@ -83,23 +83,14 @@ def __init__(self, i2c, columns, lines): on the specified I2C bus with the specified number of columns and lines on the display. """ - import adafruit_mcp230xx - self._mcp = adafruit_mcp230xx.MCP23017(i2c) - reset = self._mcp.get_pin(15) - read_write = self._mcp.get_pin(14) - enable = self._mcp.get_pin(13) - db4 = self._mcp.get_pin(12) - db5 = self._mcp.get_pin(11) - db6 = self._mcp.get_pin(10) - db7 = self._mcp.get_pin(9) - red = self._mcp.get_pin(6) - green = self._mcp.get_pin(7) - blue = self._mcp.get_pin(8) - self._left_button = self._mcp.get_pin(4) - self._up_button = self._mcp.get_pin(3) - self._down_button = self._mcp.get_pin(2) - self._right_button = self._mcp.get_pin(1) - self._select_button = self._mcp.get_pin(0) + from adafruit_mcp230xx.mcp23017 import MCP23017 + mcp = MCP23017(i2c) + + self._left_button = mcp.get_pin(4) + self._up_button = mcp.get_pin(3) + self._down_button = mcp.get_pin(2) + self._right_button = mcp.get_pin(1) + self._select_button = mcp.get_pin(0) self._buttons = [self._left_button, self._up_button, self._down_button, self._right_button, self._select_button] @@ -107,8 +98,19 @@ def __init__(self, i2c, columns, lines): for pin in self._buttons: pin.switch_to_input(pull=digitalio.Pull.UP) - super().__init__(reset, enable, db4, db5, db6, db7, columns, lines, red, green, blue, - read_write) + super().__init__(mcp.get_pin(15), + mcp.get_pin(13), + mcp.get_pin(12), + mcp.get_pin(11), + mcp.get_pin(10), + mcp.get_pin(9), + columns, + lines, + mcp.get_pin(6), + mcp.get_pin(7), + mcp.get_pin(8), + mcp.get_pin(14)) + @property def left_button(self):