Skip to content

Commit 0de54c1

Browse files
committed
add address parameter
1 parent 14f220d commit 0de54c1

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

adafruit_character_lcd/character_lcd_i2c.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ class Character_LCD_I2C(Character_LCD_Mono):
6666
i2c = busio.I2C(board.SCL, board.SDA)
6767
lcd = Character_LCD_I2C(i2c, 16, 2)
6868
"""
69-
def __init__(self, i2c, columns, lines, backlight_inverted=False):
69+
def __init__(self, i2c, columns, lines, address=None, backlight_inverted=False):
7070
"""Initialize character LCD connected to backpack using I2C connection
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
"""
7474
from adafruit_mcp230xx.mcp23008 import MCP23008
75-
mcp = MCP23008(i2c)
75+
if address:
76+
mcp = MCP23008(i2c, address=address)
77+
else:
78+
mcp = MCP23008(i2c)
7679
super().__init__(mcp.get_pin(1),
7780
mcp.get_pin(2),
7881
mcp.get_pin(3),

adafruit_character_lcd/character_lcd_rgb_i2c.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,17 @@ class Character_LCD_RGB_I2C(Character_LCD_RGB):
7777
lcd = Character_LCD_RGB_I2C(i2c, 16, 2)
7878
7979
"""
80-
def __init__(self, i2c, columns, lines):
80+
def __init__(self, i2c, columns, lines, address=None):
8181
# pylint: disable=too-many-locals
8282
"""Initialize RGB character LCD connected to shield using I2C connection
8383
on the specified I2C bus with the specified number of columns and lines
8484
on the display.
8585
"""
8686
from adafruit_mcp230xx.mcp23017 import MCP23017
87-
mcp = MCP23017(i2c)
87+
if address:
88+
mcp = MCP23017(i2c, address=address)
89+
else:
90+
mcp = MCP23017(i2c)
8891

8992
self._left_button = mcp.get_pin(4)
9093
self._up_button = mcp.get_pin(3)

0 commit comments

Comments
 (0)