Skip to content

Commit

Permalink
Merge pull request #39 from caternuson/iss36
Browse files Browse the repository at this point in the history
Updates for new MCP230xx
  • Loading branch information
brentru authored May 31, 2019
2 parents d0fc756 + e786afa commit 2b1dbc2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 30 deletions.
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ Dependencies
This driver depends on:

* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
* `Adafruit CircuitPython BusDevice <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
* `Adafruit CircuitPython MCP230xx <https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx>`_
* `Adafruit CircuitPython 74HC595 <https://github.com/adafruit/Adafruit_CircuitPython_74HC595>`_

I2C & SPI displays also depend on:

Expand Down
22 changes: 11 additions & 11 deletions adafruit_character_lcd/character_lcd_i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
40 changes: 21 additions & 19 deletions adafruit_character_lcd/character_lcd_rgb_i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,34 @@ 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]

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):
Expand Down

0 comments on commit 2b1dbc2

Please sign in to comment.