Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed Shared i2C bus from a bunch of FeatherWings #36

Merged
merged 2 commits into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions adafruit_featherwing/alphanum_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@
__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):
"""Class representing an `Adafruit 14-segment AlphaNumeric FeatherWing
<https://www.adafruit.com/product/3139>`_.

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
9 changes: 5 additions & 4 deletions adafruit_featherwing/ina219_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
<https://www.adafruit.com/product/3650>`_.

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):
Expand Down
8 changes: 5 additions & 3 deletions adafruit_featherwing/joy_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -46,8 +46,10 @@ class JoyFeatherWing:
"""Class representing an `Adafruit Joy FeatherWing <https://www.adafruit.com/product/3632>`_.

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)

Expand Down
8 changes: 5 additions & 3 deletions adafruit_featherwing/matrix_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
<https://www.adafruit.com/product/3155>`_.

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
Expand Down
8 changes: 5 additions & 3 deletions adafruit_featherwing/rtc_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
<https://www.adafruit.com/product/3028>`_.

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):
"""
Expand Down
8 changes: 5 additions & 3 deletions adafruit_featherwing/sevensegment_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@
__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):
"""Class representing an `Adafruit 7-Segment LED HT16K33 FeatherWing
<https://www.adafruit.com/product/3140>`_.

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
35 changes: 0 additions & 35 deletions adafruit_featherwing/shared.py

This file was deleted.

4 changes: 2 additions & 2 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down