Skip to content

Commit 0c034cf

Browse files
authored
Merge pull request #44 from caternuson/iss38
Add I2C address parameter
2 parents 14f220d + 15bf2a8 commit 0c034cf

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

adafruit_character_lcd/character_lcd_i2c.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151

5252
class Character_LCD_I2C(Character_LCD_Mono):
53-
# pylint: disable=too-few-public-methods
53+
# pylint: disable=too-few-public-methods, too-many-arguments
5454
"""Character LCD connected to I2C/SPI backpack using its I2C connection.
5555
This is a subclass of Character_LCD and implements all of the same
5656
functions and functionality.
@@ -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)