diff --git a/.gitignore b/.gitignore index fa45562..94c5c2b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ library/debian/ .coverage .pytest_cache .tox +.idea/ diff --git a/library/mcp9600/__init__.py b/library/mcp9600/__init__.py index 88d6bae..0ce419f 100644 --- a/library/mcp9600/__init__.py +++ b/library/mcp9600/__init__.py @@ -6,6 +6,7 @@ __version__ = '0.0.4' CHIP_ID = 0x40 +CHIP_ID2 = 0x41 I2C_ADDRESSES = list(range(0x60, 0x68)) I2C_ADDRESS_DEFAULT = 0x66 I2C_ADDRESS_ALTERNATE = 0x67 @@ -61,6 +62,7 @@ def __init__(self, i2c_addr=I2C_ADDRESS_DEFAULT, i2c_dev=None): Register('STATUS', 0x04, fields=( BitField('burst_complete', 0b10000000), BitField('updated', 0b01000000), + BitField('short_circuit', 0b00100000), BitField('input_range', 0b00010000), BitField('alert_4', 0b00001000), BitField('alert_3', 0b00000100), @@ -192,7 +194,7 @@ def __init__(self, i2c_addr=I2C_ADDRESS_DEFAULT, i2c_dev=None): try: chip = self._mcp9600.get('CHIP_ID') - if chip.id != CHIP_ID: + if chip.id != CHIP_ID and chip.id != CHIP_ID2: raise RuntimeError("Unable to find mcp9600 on 0x{:02x}, CHIP_ID returned {:02x}".format(self._i2c_addr, chip.id)) except IOError: raise RuntimeError("Unable to find mcp9600 on 0x{:02x}, IOError".format(self._i2c_addr)) @@ -228,6 +230,18 @@ def get_temperature_delta(self): """Return the difference between hot and cold junction temperatures.""" return self._mcp9600.get('DELTA').value + def is_shorted(self): + """Check if status flag indicates if tc is shorted""" + status = self._mcp9600.get('STATUS') + return status.short_circuit + + def is_in_range(self): + status = self._mcp9600.get('STATUS') + return status.input_range + + def is_disconnected(self): + return self.is_in_range() + def check_alerts(self): """Check status flags of all alert registers.""" status = self._mcp9600.get('STATUS') diff --git a/library/setup.cfg b/library/setup.cfg index 87263ff..79fcd99 100644 --- a/library/setup.cfg +++ b/library/setup.cfg @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- [metadata] name = mcp9600 -version = 0.0.4 +version = 0.0.5 author = Philip Howard author_email = phil@pimoroni.com description = Python library for the MCP9600 thermocouple temperature sensor