diff --git a/adafruit_featherwing/alphanum_featherwing.py b/adafruit_featherwing/alphanum_featherwing.py index 06b0409..6c425f1 100755 --- a/adafruit_featherwing/alphanum_featherwing.py +++ b/adafruit_featherwing/alphanum_featherwing.py @@ -31,8 +31,8 @@ __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git" +import board import adafruit_ht16k33.segments as segments -from adafruit_featherwing import shared from adafruit_featherwing.led_segments import Segments class AlphaNumFeatherWing(Segments): @@ -40,7 +40,9 @@ class AlphaNumFeatherWing(Segments): `_. Automatically uses the feather's I2C bus.""" - def __init__(self, address=0x70): + def __init__(self, address=0x70, i2c=None): super().__init__() - self._segments = segments.Seg14x4(shared.I2C_BUS, address) + if i2c is None: + i2c = board.I2C() + self._segments = segments.Seg14x4(i2c, address) self._segments.auto_write = False diff --git a/adafruit_featherwing/ina219_featherwing.py b/adafruit_featherwing/ina219_featherwing.py index c762b79..b6c7abb 100644 --- a/adafruit_featherwing/ina219_featherwing.py +++ b/adafruit_featherwing/ina219_featherwing.py @@ -31,17 +31,18 @@ __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git" +import board import adafruit_ina219 -from adafruit_featherwing import shared - class INA219FeatherWing: """Class representing an `Adafruit INA219 FeatherWing `_. Automatically uses the feather's I2C bus.""" - def __init__(self): - self._ina219 = adafruit_ina219.INA219(shared.I2C_BUS) + def __init__(self, i2c=None): + if i2c is None: + i2c = board.I2C() + self._ina219 = adafruit_ina219.INA219(i2c) @property def bus_voltage(self): diff --git a/adafruit_featherwing/joy_featherwing.py b/adafruit_featherwing/joy_featherwing.py index 7189962..9625686 100644 --- a/adafruit_featherwing/joy_featherwing.py +++ b/adafruit_featherwing/joy_featherwing.py @@ -31,9 +31,9 @@ __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git" +import board from micropython import const import adafruit_seesaw.seesaw -from adafruit_featherwing import shared BUTTON_A = const(1 << 6) BUTTON_B = const(1 << 7) @@ -46,8 +46,10 @@ class JoyFeatherWing: """Class representing an `Adafruit Joy FeatherWing `_. Automatically uses the feather's I2C bus.""" - def __init__(self): - self._seesaw = adafruit_seesaw.seesaw.Seesaw(shared.I2C_BUS) + def __init__(self, i2c=None): + if i2c is None: + i2c = board.I2C() + self._seesaw = adafruit_seesaw.seesaw.Seesaw(i2c) self._seesaw.pin_mode_bulk(BUTTON_A | BUTTON_B | BUTTON_Y | BUTTON_X | BUTTON_SELECT, self._seesaw.INPUT_PULLUP) diff --git a/adafruit_featherwing/matrix_featherwing.py b/adafruit_featherwing/matrix_featherwing.py index a2afe33..2c54d68 100755 --- a/adafruit_featherwing/matrix_featherwing.py +++ b/adafruit_featherwing/matrix_featherwing.py @@ -32,16 +32,18 @@ __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git" +import board import adafruit_ht16k33.matrix as matrix -from adafruit_featherwing import shared class MatrixFeatherWing: """Class representing an `Adafruit 8x16 LED Matrix FeatherWing `_. Automatically uses the feather's I2C bus.""" - def __init__(self, address=0x70): - self._matrix = matrix.Matrix16x8(shared.I2C_BUS, address) + def __init__(self, address=0x70, i2c=None): + if i2c is None: + i2c = board.I2C() + self._matrix = matrix.Matrix16x8(i2c, address) self._matrix.auto_write = False self.columns = 16 self.rows = 8 diff --git a/adafruit_featherwing/rtc_featherwing.py b/adafruit_featherwing/rtc_featherwing.py index 246263a..fe6af74 100755 --- a/adafruit_featherwing/rtc_featherwing.py +++ b/adafruit_featherwing/rtc_featherwing.py @@ -34,16 +34,18 @@ import time from collections import namedtuple +import board import adafruit_ds3231 -from adafruit_featherwing import shared class RTCFeatherWing: """Class representing an `DS3231 Precision RTC FeatherWing `_. Automatically uses the feather's I2C bus.""" - def __init__(self): - self._rtc = adafruit_ds3231.DS3231(shared.I2C_BUS) + def __init__(self, i2c=None): + if i2c is None: + i2c = board.I2C() + self._rtc = adafruit_ds3231.DS3231(i2c) def __setitem__(self, index, value): """ diff --git a/adafruit_featherwing/sevensegment_featherwing.py b/adafruit_featherwing/sevensegment_featherwing.py index 00d0e74..0d02f27 100755 --- a/adafruit_featherwing/sevensegment_featherwing.py +++ b/adafruit_featherwing/sevensegment_featherwing.py @@ -31,8 +31,8 @@ __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git" +import board import adafruit_ht16k33.segments as segments -from adafruit_featherwing import shared from adafruit_featherwing.led_segments import Segments class SevenSegmentFeatherWing(Segments): @@ -40,7 +40,9 @@ class SevenSegmentFeatherWing(Segments): `_. Automatically uses the feather's I2C bus.""" - def __init__(self, address=0x70): + def __init__(self, address=0x70, i2c=None): super().__init__() - self._segments = segments.Seg7x4(shared.I2C_BUS, address) + if i2c is None: + i2c = board.I2C() + self._segments = segments.Seg7x4(i2c, address) self._segments.auto_write = False diff --git a/adafruit_featherwing/shared.py b/adafruit_featherwing/shared.py deleted file mode 100644 index f0a3f68..0000000 --- a/adafruit_featherwing/shared.py +++ /dev/null @@ -1,35 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2017 Scott Shawcroft for Adafruit Industries LLC -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -""" -`adafruit_featherwing.shared` -==================================================== - -Objects shared amongst all FeatherWings. - -* Author(s): Scott Shawcroft -""" - -import board -import busio - -I2C_BUS = busio.I2C(board.SCL, board.SDA) diff --git a/docs/examples.rst b/docs/examples.rst index 7ae3b67..285a02c 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -39,8 +39,8 @@ Ensure your device works with this simple test. :caption: examples/featherwing_matrix_simpletest.py :linenos: -Other Tests ------------- +Other Examples +--------------- .. literalinclude:: ../examples/featherwing_dotstar_palette_example.py :caption: examples/featherwing_dotstar_palette_example.py