Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update to Altitude setter
  • Loading branch information
Andrew Smith authored and Andrew Smith committed May 13, 2023
commit 30f3f8fbde9e37bfa38d6ddaad97b2044d2518e6
9 changes: 3 additions & 6 deletions adafruit_bmp280.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,10 @@ def altitude(self) -> float:
p = self.pressure # in Si units for hPascal
return 44330 * (1.0 - math.pow(p / self.sea_level_pressure, 0.1903))

@property
def p0(self, altitude_m=0.0) -> float:
"""The calculated sea level pressure based on altitude (:attr:`altitude`)
- which you must enter ahead of time)"""
@altitude.setter
def altitude(self, value: float) -> None:
p = self.pressure # in Si units for hPascal
p0 = p / math.pow(1.0 - altitude_m/44330.0, 5.255)
return p0
self.sea_level_pressure = p / math.pow(1.0 - value/44330.0, 5.255)

####################### Internal helpers ################################
def _read_coefficients(self) -> None:
Expand Down