-
Notifications
You must be signed in to change notification settings - Fork 9
Feat: multi-sample averaging and 50Hz mains filtering #20
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
Conversation
hi please create functions to set/get the freq filter (none, 50, 60?) and oversampling rather than setting once in init :) |
09df6a1
to
aa5240c
Compare
Thanks for the feedback! I've created functions |
Code logic looks generally OK. But instead of actual function functions, CP lib style is to use Python property feature: Look at the With that form, the following syntax is how they would get used in user code to set: thermocouple.averaging = 16
thermocouple.noise_rejection = True and to query (get): print("Averaging =", thermocouple.averaging)
print("Noise Rejection =", thermocouple.noise_rejection) In the above example code snippets, |
Yes I see. Thanks for the advice! I've implemented it using property getter/setters now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One spelling fix.
LGTM. Nice job switching to property approach! Functionally tested, without a TC connected, on Itsy M0: Adafruit CircuitPython 7.3.2 on 2022-07-20; Adafruit ItsyBitsy M0 Express with samd21g18
>>> import board
>>> import adafruit_max31856
>>> import digitalio
>>> cs = digitalio.DigitalInOut(board.D10)
>>> cs.switch_to_output()
>>> max = adafruit_max31856.MAX31856(board.SPI(), cs)
>>> max.reference_temperature
24.375
>>> max.averaging
1
>>> max.averaging = 16
>>> max.averaging
16
>>> max.averaging = 42
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "adafruit_max31856.py", line 190, in averaging
ValueError: Num_samples must be one of 1,2,4,8,16
>>> max.noise_rejection
60
>>> max.noise_rejection = 50
>>> max.noise_rejection
50
>>> max.noise_rejection = 23
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "adafruit_max31856.py", line 218, in noise_rejection
ValueError: Frequency must be 50 or 60
>>> |
Co-authored-by: Dan Halbert <[email protected]>
Thanks all, I've enjoyed contributing to this library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, verified the open change requested was completed.
Thanks for the improvement @eirinnm
Updating https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground to 5.2.7 from 5.2.6: > Merge pull request adafruit/Adafruit_CircuitPython_CircuitPlayground#120 from dhalbert/no-pwmout-for-pulseout Updating https://github.com/adafruit/Adafruit_CircuitPython_IRRemote to 4.1.8 from 4.1.7: > Merge pull request adafruit/Adafruit_CircuitPython_IRRemote#54 from dhalbert/no-pwmout Updating https://github.com/adafruit/Adafruit_CircuitPython_MAX31856 to 0.11.0 from 0.10.1: > Merge pull request adafruit/Adafruit_CircuitPython_MAX31856#20 from eirinnm/selectable_mains_filtering Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 6.2.6 from 6.2.5: > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#123 from dhalbert/no-auto-brightness Updating https://github.com/adafruit/Adafruit_CircuitPython_TFmini to 1.2.12 from 1.2.11: > Merge pull request adafruit/Adafruit_CircuitPython_TFmini#13 from okennedy/patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_NTP to 3.0.4 from 3.0.3: > Merge pull request adafruit/Adafruit_CircuitPython_NTP#22 from regulatre/main Updating https://github.com/adafruit/Adafruit_CircuitPython_PortalBase to 1.14.0 from 1.13.6: > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#78 from colonwq/is_connected Updating https://github.com/adafruit/Adafruit_CircuitPython_PYOA to 2.5.9 from 2.5.8: > Merge pull request adafruit/Adafruit_CircuitPython_PYOA#36 from dhalbert/no-auto-brightness
This PR implements two features from the datasheet: