Skip to content

Commit

Permalink
Merge pull request #29 from pimoroni/repackage
Browse files Browse the repository at this point in the history
Tidyup and prep for v1.0.0
  • Loading branch information
Gadgetoid committed Nov 15, 2023
2 parents b6c2609 + a1f94cc commit 45beb4d
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 96 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
@@ -1,7 +1,7 @@
1.0.0
-----

* Repackage to pyproject.toml
* Repackage to hatch/pyproject.toml
* Require i2cdevice>=1.0.0 (smbus2)

0.1.1
Expand Down
7 changes: 2 additions & 5 deletions examples/all-values.py
Expand Up @@ -2,10 +2,7 @@

import time

try:
from smbus2 import SMBus
except ImportError:
from smbus import SMBus
from smbus2 import SMBus

from bme280 import BME280

Expand All @@ -25,5 +22,5 @@
temperature = bme280.get_temperature()
pressure = bme280.get_pressure()
humidity = bme280.get_humidity()
print("{:05.2f}*C {:05.2f}hPa {:05.2f}%".format(temperature, pressure, humidity))
print(f"{temperature:05.2f}°C {pressure:05.2f}hPa {humidity:05.2f}%")
time.sleep(1)
9 changes: 3 additions & 6 deletions examples/compensated-temperature.py
Expand Up @@ -3,12 +3,9 @@
import time
from subprocess import PIPE, Popen

from bme280 import BME280
from smbus2 import SMBus

try:
from smbus2 import SMBus
except ImportError:
from smbus import SMBus
from bme280 import BME280

print(
"""compensated-temperature.py - Use the CPU temperature to compensate temperature
Expand Down Expand Up @@ -49,6 +46,6 @@ def get_cpu_temperature():
raw_temp = bme280.get_temperature()
comp_temp = raw_temp - ((smoothed_cpu_temp - raw_temp) / factor)

print("Compensated temperature: {:05.2f} *C".format(comp_temp))
print(f"Raw: {raw_temp:05.2f}°C, Compensated: {comp_temp:05.2f}°C")

time.sleep(1.0)
9 changes: 4 additions & 5 deletions examples/dump-calibration.py
@@ -1,9 +1,8 @@
#!/usr/bin/env python

try:
from smbus2 import SMBus
except ImportError:
from smbus import SMBus

from smbus2 import SMBus

from bme280 import BME280

print(
Expand All @@ -21,4 +20,4 @@
for key in dir(bme280.calibration):
if key.startswith("dig_"):
value = getattr(bme280.calibration, key)
print("{} = {}".format(key, value))
print(f"{key} = {value}")
22 changes: 15 additions & 7 deletions examples/local_altitude.py
Expand Up @@ -2,10 +2,8 @@

import time

try:
from smbus2 import SMBus
except ImportError:
from smbus import SMBus
from smbus2 import SMBus

from bme280 import BME280

print(
Expand All @@ -22,10 +20,20 @@

# asks the user for their local QNH value and confirms it
local_qnh = input(
"""Please enter your local QNH value.
You can find this by searching for a local METAR on the internet.
"""Please enter your local QNH value (air pressure at the mean sea level).
You can find this by searching for a local METAR report,
eg: "Cambridge METAR"
And looking for the number prefixed with a "Q",
eg: Q1015
>"""
)

# remove a Q prefix if there is one
if local_qnh.startswith("Q") or local_qnh.startswith("q"):
local_qnh = local_qnh[1:]

print("You have told us the QNH is", local_qnh)

# converts the input into a floating point number
Expand All @@ -39,5 +47,5 @@

while True:
altitude = bme280.get_altitude(qnh=local_qnh)
print(round(altitude), "metres above sea level")
print(f"{altitude:0.0f} metres above sea level")
time.sleep(2)
10 changes: 4 additions & 6 deletions examples/relative-altitude.py
Expand Up @@ -2,10 +2,8 @@

import time

try:
from smbus2 import SMBus
except ImportError:
from smbus import SMBus
from smbus2 import SMBus

from bme280 import BME280

print(
Expand All @@ -23,7 +21,7 @@
baseline_values = []
baseline_size = 100

print("Collecting baseline values for {:d} seconds. Do not move the sensor!\n".format(baseline_size))
print(f"Collecting baseline values for {baseline_size:d} seconds. Do not move the sensor!\n")

# Collect some values to calculate a baseline pressure
for i in range(baseline_size):
Expand All @@ -36,5 +34,5 @@

while True:
altitude = bme280.get_altitude(qnh=baseline)
print("Relative altitude: {:05.2f} metres".format(altitude))
print(f"Relative altitude: {altitude:05.2f} metres")
time.sleep(1)
7 changes: 2 additions & 5 deletions examples/temperature-compare.py
Expand Up @@ -2,10 +2,7 @@

import time

try:
from smbus2 import SMBus
except ImportError:
from smbus import SMBus
from smbus2 import SMBus

from bme280 import BME280

Expand Down Expand Up @@ -33,5 +30,5 @@
while True:
temperatureA = bme280A.get_temperature()
temperatureB = bme280B.get_temperature()
print("Forced: {:05.2f}*C Normal: {:05.2f}*C D: {:05.2f}".format(temperatureA, temperatureB, abs(temperatureA - temperatureB)))
print(f"Forced: {temperatureA:05.2f}°C Normal: {temperatureB:05.2f}°C D: {abs(temperatureA - temperatureB):05.2f}°C")
time.sleep(1)
7 changes: 2 additions & 5 deletions examples/temperature-forced-mode.py
Expand Up @@ -2,10 +2,7 @@

import time

try:
from smbus2 import SMBus
except ImportError:
from smbus import SMBus
from smbus2 import SMBus

from bme280 import BME280

Expand All @@ -21,5 +18,5 @@

while True:
temperature = bme280.get_temperature()
print("{:05.2f}*C".format(temperature))
print(f"{temperature:05.2f}°C")
time.sleep(1)
5 changes: 4 additions & 1 deletion pyproject.toml
Expand Up @@ -115,4 +115,7 @@ ignore = [
[tool.pimoroni]
apt_packages = []
configtxt = []
commands = []
commands = [
"printf \"Setting up i2c...\n\"",
"sudo raspi-config nonint do_i2c 0"
]
55 changes: 0 additions & 55 deletions setup.cfg

This file was deleted.

0 comments on commit 45beb4d

Please sign in to comment.