Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 00e72ec

Browse files
committed
adding altitude setter
1 parent 6d3cc80 commit 00e72ec

6 files changed

Lines changed: 17 additions & 23 deletions

File tree

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
MicroPython DPS310 Library
2+
===============================
3+
14
.. automodule:: micropython_dps310
25
:members:
36

docs/conf.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
42
#
53
# SPDX-License-Identifier: MIT
@@ -32,7 +30,6 @@
3230
extensions = [
3331
"sphinx.ext.autodoc",
3432
"sphinx.ext.intersphinx",
35-
"sphinx.ext.napoleon",
3633
"sphinx.ext.viewcode",
3734
"sphinx_immaterial",
3835
]
@@ -187,10 +184,6 @@
187184
},
188185
]
189186

190-
python_type_aliases = {
191-
"DigitalInOut": "digitalio.DigitalInOut",
192-
}
193-
194187
object_description_options = [
195188
("py:.*", dict(generate_synopses="first_sentence")),
196189
]

examples/dps310_simpletest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99

1010
while True:
1111
print(f"Pressure: {dps.pressure}HPa")
12+
print()
1213
time.sleep(1)

examples/dps310_temperature.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
dps = dps310.DPS310(i2c)
99

1010
while True:
11-
print(f"Temperature {dps.temperature}C")
11+
print(f"Temperature {dps.temperature}°C")
12+
print()
1213
time.sleep(1)

micropython_dps310/dps310.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
MicroPython Driver for the DP310 Barametric Sensor
99
1010
11-
* Author(s): Jose D. Montoya
11+
* Author: Jose D. Montoya
1212
1313
Implementation Notes
1414
--------------------
@@ -548,10 +548,14 @@ def altitude(self) -> float:
548548
The altitude in meters based on the sea level pressure
549549
(:attr:`sea_level_pressure`) - which you must enter ahead of time
550550
"""
551-
return 44330 * (
551+
return 44330.0 * (
552552
1.0 - math.pow(self.pressure / self._sea_level_pressure, 0.1903)
553553
)
554554

555+
@altitude.setter
556+
def altitude(self, value: float) -> None:
557+
self.sea_level_pressure = self.pressure / (1.0 - value / 44330.0) ** 5.255
558+
555559
@property
556560
def temperature(self) -> float:
557561
"""The current temperature reading in Celsius"""

pyproject.toml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
1-
# SPDX-FileCopyrightText: 2022 Alec Delaney, written for Adafruit Industries
21
# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
32
#
43
# SPDX-License-Identifier: MIT
54

65
[build-system]
7-
requires = [
8-
"setuptools",
9-
"wheel",
10-
"setuptools-scm",
11-
]
6+
requires = ["setuptools", "wheel", "setuptools-scm"]
127

138
[project]
149
name = "micropython-dps310"
1510
description = "MicroPython Driver for the DPS310 sensor"
1611
version = "0.0.0+auto.0"
1712
readme = "README.rst"
18-
authors = [
19-
{name = "Jose D. Montoya", email = "dps310@mailmeto.mozmail.com"}
20-
]
21-
urls = {Homepage = "https://github.com/jposada202020/MicroPython_dps310"}
13+
authors = [{ name = "Jose D. Montoya", email = "dps310@mailmeto.mozmail.com" }]
14+
urls = { Homepage = "https://github.com/jposada202020/MicroPython_dps310" }
2215
keywords = [
2316
"micropython",
24-
"dps310",
2517
"DPS310",
2618
"sensor",
2719
"temperature",
2820
"pressure",
2921
"altitude",
3022
]
31-
license = {text = "MIT"}
23+
license = { text = "MIT" }
3224
classifiers = [
3325
"Intended Audience :: Developers",
3426
"Topic :: Software Development :: Libraries",
@@ -43,4 +35,4 @@ dynamic = ["dependencies", "optional-dependencies"]
4335
packages = ["micropython_dps310"]
4436

4537
[tool.setuptools.dynamic]
46-
dependencies = {file = ["requirements.txt"]}
38+
dependencies = { file = ["requirements.txt"] }

0 commit comments

Comments
 (0)