Skip to content

Commit

Permalink
Merge pull request #18 from ben-lewis/patch-1
Browse files Browse the repository at this point in the history
Add support for 50Hz filter
  • Loading branch information
tannewt committed Mar 22, 2020
2 parents 1809692 + 1668ba5 commit 90f3f0d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions adafruit_max31865.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,27 @@ class MAX31865:
# thread safe!
_BUFFER = bytearray(3)

def __init__(self, spi, cs, *, rtd_nominal=100, ref_resistor=430.0, wires=2):
def __init__(
self, spi, cs, *, rtd_nominal=100, ref_resistor=430.0,
wires=2, filter_frequency=60
):
self.rtd_nominal = rtd_nominal
self.ref_resistor = ref_resistor
self._device = spi_device.SPIDevice(
spi, cs, baudrate=500000, polarity=0, phase=1
)
# Set 50Hz or 60Hz filter.
if filter_frequency not in (50, 60):
raise ValueError("Filter_frequency must be a value of 50 or 60!")
config = self._read_u8(_MAX31865_CONFIG_REG)
if filter_frequency == 50:
config |= _MAX31865_CONFIG_FILT50HZ
else:
config &= ~_MAX31865_CONFIG_FILT50HZ

# Set wire config register based on the number of wires specified.
if wires not in (2, 3, 4):
raise ValueError("Wires must be a value of 2, 3, or 4!")
config = self._read_u8(_MAX31865_CONFIG_REG)
if wires == 3:
config |= _MAX31865_CONFIG_3WIRE
else:
Expand Down

0 comments on commit 90f3f0d

Please sign in to comment.