Skip to content

Commit bab1686

Browse files
committed
updates for new MCP230xx
1 parent d0fc756 commit bab1686

File tree

2 files changed

+31
-32
lines changed

2 files changed

+31
-32
lines changed

adafruit_character_lcd/character_lcd_i2c.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ def __init__(self, i2c, columns, lines, backlight_inverted=False):
7171
on the specified I2C bus with the specified number of columns and
7272
lines on the display. Optionally specify if backlight is inverted.
7373
"""
74-
import adafruit_mcp230xx
75-
self._mcp = adafruit_mcp230xx.MCP23008(i2c)
76-
reset = self._mcp.get_pin(1)
77-
enable = self._mcp.get_pin(2)
78-
db4 = self._mcp.get_pin(3)
79-
db5 = self._mcp.get_pin(4)
80-
db6 = self._mcp.get_pin(5)
81-
db7 = self._mcp.get_pin(6)
82-
backlight_pin = self._mcp.get_pin(7)
83-
super().__init__(reset, enable, db4, db5, db6, db7, columns, lines,
84-
backlight_pin=backlight_pin, backlight_inverted=backlight_inverted)
74+
from adafruit_mcp230xx.mcp23008 import MCP23008
75+
mcp = MCP23008(i2c)
76+
super().__init__(mcp.get_pin(1),
77+
mcp.get_pin(2),
78+
mcp.get_pin(3),
79+
mcp.get_pin(4),
80+
mcp.get_pin(5),
81+
mcp.get_pin(6),
82+
columns, lines,
83+
backlight_pin=mcp.get_pin(7),
84+
backlight_inverted=backlight_inverted)

adafruit_character_lcd/character_lcd_rgb_i2c.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,32 +83,31 @@ def __init__(self, i2c, columns, lines):
8383
on the specified I2C bus with the specified number of columns and lines
8484
on the display.
8585
"""
86-
import adafruit_mcp230xx
87-
self._mcp = adafruit_mcp230xx.MCP23017(i2c)
88-
reset = self._mcp.get_pin(15)
89-
read_write = self._mcp.get_pin(14)
90-
enable = self._mcp.get_pin(13)
91-
db4 = self._mcp.get_pin(12)
92-
db5 = self._mcp.get_pin(11)
93-
db6 = self._mcp.get_pin(10)
94-
db7 = self._mcp.get_pin(9)
95-
red = self._mcp.get_pin(6)
96-
green = self._mcp.get_pin(7)
97-
blue = self._mcp.get_pin(8)
98-
self._left_button = self._mcp.get_pin(4)
99-
self._up_button = self._mcp.get_pin(3)
100-
self._down_button = self._mcp.get_pin(2)
101-
self._right_button = self._mcp.get_pin(1)
102-
self._select_button = self._mcp.get_pin(0)
86+
from adafruit_mcp230xx.mcp23017 import MCP23017
87+
mcp = MCP2317(i2c)
88+
89+
self._left_button = mcp.get_pin(4)
90+
self._up_button = mcp.get_pin(3)
91+
self._down_button = mcp.get_pin(2)
92+
self._right_button = mcp.get_pin(1)
93+
self._select_button = mcp.get_pin(0)
10394

10495
self._buttons = [self._left_button, self._up_button, self._down_button, self._right_button,
10596
self._select_button]
10697

107-
for pin in self._buttons:
108-
pin.switch_to_input(pull=digitalio.Pull.UP)
98+
super().__init__(mcp.get_pin(15),
99+
mcp.get_pin(13),
100+
mcp.get_pin(12),
101+
mcp.get_pin(11),
102+
mcp.get_pin(10),
103+
mcp.get_pin(9),
104+
columns,
105+
lines,
106+
mcp.get_pin(6),
107+
mcp.get_pin(7),
108+
mcp.get_pin(8),
109+
mcp.get_pin(14))
109110

110-
super().__init__(reset, enable, db4, db5, db6, db7, columns, lines, red, green, blue,
111-
read_write)
112111

113112
@property
114113
def left_button(self):

0 commit comments

Comments
 (0)