Make sure we turn ambient pressure to an int.#7
Conversation
|
ping @caternuson |
|
@tannewt yep. on it. just got one yesterday :) |
|
@rpavlik What about doing this in user code instead? scd.ambient_pressure = int(clue.pressure)This would help reinforce the fact that the setting really is only integer resolution: It would also make things more symetric in terms of getting the same value back when you read |
|
Actually, I'm going to be like a politician and flip-flip on this. I'm cool with it. I think the trade off of allowing simpler user code vs. the potential issues of the automagic behavior is minimal. @rpavlik Want to do something similar for |
|
Ah, I hadn't thought of altitude since my thought process was literally "hey, I can have it compensate for pressure, this clue has a bmp280, I shall take the value from bmp280 and apply to scd30". Sure, I can get to that tonight probably. |
|
There you go! |
|
BTW, we probably want to bump major version soon on this because of the eCO2 -> CO2 rename? |
|
Looks good. Tested real quick on a MatrixPortal. The parameter is still Adafruit CircuitPython 6.1.0 on 2021-01-21; Adafruit Matrix Portal M4 with samd51j19
>>> import board
>>> import adafruit_scd30
>>> scd30 = adafruit_scd30.SCD30(board.I2C())
>>> scd30.eCO2
755.951
>>> scd30.ambient_pressure
0
>>> scd30.ambient_pressure = 1010.5
>>> scd30.ambient_pressure
1010
>>> scd30.altitude
0
>>> scd30.altitude = 300.5
>>> scd30.altitude
300
>>> scd30.eCO2
779.802
>>> |
Yep. Looks like that was done a couple of days ago with the 2.0.0 release: |
|
awesome thanks! |
Updating https://github.com/adafruit/Adafruit_CircuitPython_SCD30 to 2.0.1 from 2.0.0: > Merge pull request adafruit/Adafruit_CircuitPython_SCD30#7 from rpavlik/pressure-type Updating https://github.com/adafruit/Adafruit_CircuitPython_Seesaw to 1.7.0 from 1.6.4: > Merge pull request adafruit/Adafruit_CircuitPython_seesaw#58 from adafruit/dherrada-patch-1 > Merge pull request adafruit/Adafruit_CircuitPython_seesaw#59 from rsbohn/master Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.12.1 from 2.11.2: > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#112 from jposada202020/updating-docs > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#110 from FoamyGuy/bitmap_label_ascent_descent Updating https://github.com/adafruit/Adafruit_CircuitPython_Slideshow to 1.5.5 from 1.5.4: > Merge pull request adafruit/Adafruit_CircuitPython_Slideshow#35 from adafruit/dherrada-patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Added the following libraries: Adafruit_CircuitPython_SimpleMath

I noticed that there was this feature to set the pressure for better results, and since I was using a CLUE, I figured I'd set it on startup. Of course, the BMP280 returns a float, not an int, so I got an error about trying to shift a float. This fixes the error, by turning whatever we're given in the setter of
ambient_pressureinto an int, so you can just: