Skip to content

Commit 5ea0eb4

Browse files
authored
Merge pull request #36 from makermelissa/master
Removed Shared i2C bus from a bunch of FeatherWings
2 parents a2282db + bab12c9 commit 5ea0eb4

8 files changed

+32
-56
lines changed

adafruit_featherwing/alphanum_featherwing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@
3131
__version__ = "0.0.0-auto.0"
3232
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
3333

34+
import board
3435
import adafruit_ht16k33.segments as segments
35-
from adafruit_featherwing import shared
3636
from adafruit_featherwing.led_segments import Segments
3737

3838
class AlphaNumFeatherWing(Segments):
3939
"""Class representing an `Adafruit 14-segment AlphaNumeric FeatherWing
4040
<https://www.adafruit.com/product/3139>`_.
4141
4242
Automatically uses the feather's I2C bus."""
43-
def __init__(self, address=0x70):
43+
def __init__(self, address=0x70, i2c=None):
4444
super().__init__()
45-
self._segments = segments.Seg14x4(shared.I2C_BUS, address)
45+
if i2c is None:
46+
i2c = board.I2C()
47+
self._segments = segments.Seg14x4(i2c, address)
4648
self._segments.auto_write = False

adafruit_featherwing/ina219_featherwing.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,18 @@
3131
__version__ = "0.0.0-auto.0"
3232
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
3333

34+
import board
3435
import adafruit_ina219
35-
from adafruit_featherwing import shared
36-
3736

3837
class INA219FeatherWing:
3938
"""Class representing an `Adafruit INA219 FeatherWing
4039
<https://www.adafruit.com/product/3650>`_.
4140
4241
Automatically uses the feather's I2C bus."""
43-
def __init__(self):
44-
self._ina219 = adafruit_ina219.INA219(shared.I2C_BUS)
42+
def __init__(self, i2c=None):
43+
if i2c is None:
44+
i2c = board.I2C()
45+
self._ina219 = adafruit_ina219.INA219(i2c)
4546

4647
@property
4748
def bus_voltage(self):

adafruit_featherwing/joy_featherwing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
__version__ = "0.0.0-auto.0"
3232
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
3333

34+
import board
3435
from micropython import const
3536
import adafruit_seesaw.seesaw
36-
from adafruit_featherwing import shared
3737

3838
BUTTON_A = const(1 << 6)
3939
BUTTON_B = const(1 << 7)
@@ -46,8 +46,10 @@ class JoyFeatherWing:
4646
"""Class representing an `Adafruit Joy FeatherWing <https://www.adafruit.com/product/3632>`_.
4747
4848
Automatically uses the feather's I2C bus."""
49-
def __init__(self):
50-
self._seesaw = adafruit_seesaw.seesaw.Seesaw(shared.I2C_BUS)
49+
def __init__(self, i2c=None):
50+
if i2c is None:
51+
i2c = board.I2C()
52+
self._seesaw = adafruit_seesaw.seesaw.Seesaw(i2c)
5153
self._seesaw.pin_mode_bulk(BUTTON_A | BUTTON_B | BUTTON_Y | BUTTON_X | BUTTON_SELECT,
5254
self._seesaw.INPUT_PULLUP)
5355

adafruit_featherwing/matrix_featherwing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,18 @@
3232
__version__ = "0.0.0-auto.0"
3333
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
3434

35+
import board
3536
import adafruit_ht16k33.matrix as matrix
36-
from adafruit_featherwing import shared
3737

3838
class MatrixFeatherWing:
3939
"""Class representing an `Adafruit 8x16 LED Matrix FeatherWing
4040
<https://www.adafruit.com/product/3155>`_.
4141
4242
Automatically uses the feather's I2C bus."""
43-
def __init__(self, address=0x70):
44-
self._matrix = matrix.Matrix16x8(shared.I2C_BUS, address)
43+
def __init__(self, address=0x70, i2c=None):
44+
if i2c is None:
45+
i2c = board.I2C()
46+
self._matrix = matrix.Matrix16x8(i2c, address)
4547
self._matrix.auto_write = False
4648
self.columns = 16
4749
self.rows = 8

adafruit_featherwing/rtc_featherwing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,18 @@
3434

3535
import time
3636
from collections import namedtuple
37+
import board
3738
import adafruit_ds3231
38-
from adafruit_featherwing import shared
3939

4040
class RTCFeatherWing:
4141
"""Class representing an `DS3231 Precision RTC FeatherWing
4242
<https://www.adafruit.com/product/3028>`_.
4343
4444
Automatically uses the feather's I2C bus."""
45-
def __init__(self):
46-
self._rtc = adafruit_ds3231.DS3231(shared.I2C_BUS)
45+
def __init__(self, i2c=None):
46+
if i2c is None:
47+
i2c = board.I2C()
48+
self._rtc = adafruit_ds3231.DS3231(i2c)
4749

4850
def __setitem__(self, index, value):
4951
"""

adafruit_featherwing/sevensegment_featherwing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@
3131
__version__ = "0.0.0-auto.0"
3232
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
3333

34+
import board
3435
import adafruit_ht16k33.segments as segments
35-
from adafruit_featherwing import shared
3636
from adafruit_featherwing.led_segments import Segments
3737

3838
class SevenSegmentFeatherWing(Segments):
3939
"""Class representing an `Adafruit 7-Segment LED HT16K33 FeatherWing
4040
<https://www.adafruit.com/product/3140>`_.
4141
4242
Automatically uses the feather's I2C bus."""
43-
def __init__(self, address=0x70):
43+
def __init__(self, address=0x70, i2c=None):
4444
super().__init__()
45-
self._segments = segments.Seg7x4(shared.I2C_BUS, address)
45+
if i2c is None:
46+
i2c = board.I2C()
47+
self._segments = segments.Seg7x4(i2c, address)
4648
self._segments.auto_write = False

adafruit_featherwing/shared.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

docs/examples.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Ensure your device works with this simple test.
3939
:caption: examples/featherwing_matrix_simpletest.py
4040
:linenos:
4141

42-
Other Tests
43-
------------
42+
Other Examples
43+
---------------
4444

4545
.. literalinclude:: ../examples/featherwing_dotstar_palette_example.py
4646
:caption: examples/featherwing_dotstar_palette_example.py

0 commit comments

Comments
 (0)