diff --git a/Adafruit_MCP9808/MCP9808.py b/Adafruit_MCP9808/MCP9808.py index 081286d..8c0a088 100644 --- a/Adafruit_MCP9808/MCP9808.py +++ b/Adafruit_MCP9808/MCP9808.py @@ -18,10 +18,10 @@ # 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. + import logging import math -import Adafruit_GPIO.I2C as I2C # Default I2C address for device. MCP9808_I2CADDR_DEFAULT = 0x18 @@ -52,13 +52,17 @@ class MCP9808(object): board. """ - def __init__(self, address=MCP9808_I2CADDR_DEFAULT, busnum=I2C.get_default_bus()): + def __init__(self, address=MCP9808_I2CADDR_DEFAULT, i2c=None, **kwargs): """Initialize MCP9808 device on the specified I2C address and bus number. Address defaults to 0x18 and bus number defaults to the appropriate bus for the hardware. """ self._logger = logging.getLogger('Adafruit_MCP9808.MCP9808') - self._device = I2C.Device(address, busnum) + if i2c is None: + import Adafruit_GPIO.I2C as I2C + i2c = I2C + self._device = i2c.get_i2c_device(address, **kwargs) + def begin(self): """Start taking temperature measurements. Returns True if the device is diff --git a/setup.py b/setup.py index 82a6566..c0394b2 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ use_setuptools() from setuptools import setup, find_packages setup(name = 'Adafruit_MCP9808', - version = '1.0.0', + version = '1.5.0', author = 'Tony DiCola', author_email = 'tdicola@adafruit.com', description = 'Library for accessing the MCP9808 precision temperature sensor on a Raspberry Pi or Beaglebone Black.', license = 'MIT', url = 'https://github.com/adafruit/Adafruit_Python_MCP9808/', - dependency_links = ['https://github.com/adafruit/Adafruit_Python_GPIO/tarball/master#egg=Adafruit-GPIO-0.5.0'], - install_requires = ['Adafruit-GPIO>=0.5.0'], + dependency_links = ['https://github.com/adafruit/Adafruit_Python_GPIO/tarball/master#egg=Adafruit-GPIO-0.6.5'], + install_requires = ['Adafruit-GPIO>=0.6.5'], packages = find_packages())