@@ -96,16 +96,27 @@ class MAX31865:
96
96
# thread safe!
97
97
_BUFFER = bytearray (3 )
98
98
99
- def __init__ (self , spi , cs , * , rtd_nominal = 100 , ref_resistor = 430.0 , wires = 2 ):
99
+ def __init__ (
100
+ self , spi , cs , * , rtd_nominal = 100 , ref_resistor = 430.0 ,
101
+ wires = 2 , filter_frequency = 60
102
+ ):
100
103
self .rtd_nominal = rtd_nominal
101
104
self .ref_resistor = ref_resistor
102
105
self ._device = spi_device .SPIDevice (
103
106
spi , cs , baudrate = 500000 , polarity = 0 , phase = 1
104
107
)
108
+ # Set 50Hz or 60Hz filter.
109
+ if filter_frequency not in (50 , 60 ):
110
+ raise ValueError ("Filter_frequency must be a value of 50 or 60!" )
111
+ config = self ._read_u8 (_MAX31865_CONFIG_REG )
112
+ if filter_frequency == 50 :
113
+ config |= _MAX31865_CONFIG_FILT50HZ
114
+ else :
115
+ config &= ~ _MAX31865_CONFIG_FILT50HZ
116
+
105
117
# Set wire config register based on the number of wires specified.
106
118
if wires not in (2 , 3 , 4 ):
107
119
raise ValueError ("Wires must be a value of 2, 3, or 4!" )
108
- config = self ._read_u8 (_MAX31865_CONFIG_REG )
109
120
if wires == 3 :
110
121
config |= _MAX31865_CONFIG_3WIRE
111
122
else :
0 commit comments