Skip to content

Add support for 50Hz filter #18

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

Merged
merged 6 commits into from
Mar 22, 2020
Merged
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
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