Skip to content

Commit d93839d

Browse files
authored
Merge pull request #793 from awjlogan/enviro-tidy
Enviro Pico description generation did not match f-string rounding
2 parents e1527c4 + 1e6e683 commit d93839d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

micropython/examples/pico_enviro/enviro_all.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def adjust_to_sea_pressure(pressure_hpa, temperature, altitude):
6363

6464
def describe_pressure(pressure_hpa):
6565
"""Convert pressure into barometer-type description."""
66+
pressure_hpa += 0.5
6667
if pressure_hpa < 970:
6768
description = "storm"
6869
elif 970 <= pressure_hpa < 990:
@@ -80,6 +81,7 @@ def describe_pressure(pressure_hpa):
8081

8182
def describe_humidity(corrected_humidity):
8283
"""Convert relative humidity into good/bad description."""
84+
corrected_humidity += 0.5
8385
if 40 < corrected_humidity < 60:
8486
description = "good"
8587
else:
@@ -89,6 +91,7 @@ def describe_humidity(corrected_humidity):
8991

9092
def describe_light(lux):
9193
"""Convert light level in lux to descriptive value."""
94+
lux += 0.5
9295
if lux < 50:
9396
description = "dark"
9497
elif 50 <= lux < 100:
@@ -186,7 +189,7 @@ def draw_hist(results_array):
186189
time.sleep(0.5)
187190

188191
while True:
189-
# turn off the backlight with A and turn it back on with B
192+
# turn on the backlight with A and turn it back off with B
190193
# switch between sensor and equaliser mode with X and Y
191194
if button_a.is_pressed:
192195
display.set_backlight(BRIGHTNESS)
@@ -263,7 +266,7 @@ def draw_hist(results_array):
263266
display.set_pen(RED)
264267
if corrected_temperature < 10:
265268
display.set_pen(CYAN)
266-
display.text(f"{corrected_temperature:.1f}°c", 5, 15, WIDTH, scale=4)
269+
display.text(f"{corrected_temperature:.1f}°C", 5, 15, WIDTH, scale=4)
267270

268271
# draw temp max and min
269272
display.set_pen(CYAN)
@@ -275,7 +278,7 @@ def draw_hist(results_array):
275278
display.set_pen(WHITE)
276279
display.text(f"rh {corrected_humidity:.0f}%", 0, 75, WIDTH, scale=3)
277280
display.text(f"{pressure_hpa:.0f}hPa", 0, 125, WIDTH, scale=3)
278-
display.text(f"{lux} lux", 0, 175, WIDTH, scale=3)
281+
display.text(f"{lux:.0f} lux", 0, 175, WIDTH, scale=3)
279282

280283
# draw the second column of text
281284
display.text(f"{describe_humidity(corrected_humidity)}", 125, 75, WIDTH, scale=3)

0 commit comments

Comments
 (0)