From 0a0b72701e42f366789234a9de91b7ccfb58d95b Mon Sep 17 00:00:00 2001 From: Angus Logan Date: Fri, 23 Jun 2023 20:20:23 +0100 Subject: [PATCH 1/3] Match descriptive terms to Python f-string rounding --- micropython/examples/pico_enviro/enviro_all.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/micropython/examples/pico_enviro/enviro_all.py b/micropython/examples/pico_enviro/enviro_all.py index 21ca1e7a9..b8b48140b 100644 --- a/micropython/examples/pico_enviro/enviro_all.py +++ b/micropython/examples/pico_enviro/enviro_all.py @@ -63,6 +63,7 @@ def adjust_to_sea_pressure(pressure_hpa, temperature, altitude): def describe_pressure(pressure_hpa): """Convert pressure into barometer-type description.""" + pressure_hpa += 0.5 if pressure_hpa < 970: description = "storm" elif 970 <= pressure_hpa < 990: @@ -80,6 +81,7 @@ def describe_pressure(pressure_hpa): def describe_humidity(corrected_humidity): """Convert relative humidity into good/bad description.""" + corrected_humidity += 0.5 if 40 < corrected_humidity < 60: description = "good" else: @@ -89,6 +91,7 @@ def describe_humidity(corrected_humidity): def describe_light(lux): """Convert light level in lux to descriptive value.""" + lux += 0.5 if lux < 50: description = "dark" elif 50 <= lux < 100: From d25c6953d01077954389d74053862b1ae85ef0de Mon Sep 17 00:00:00 2001 From: Angus Logan Date: Fri, 23 Jun 2023 20:22:18 +0100 Subject: [PATCH 2/3] Correct comment for backlight button functionality --- micropython/examples/pico_enviro/enviro_all.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/micropython/examples/pico_enviro/enviro_all.py b/micropython/examples/pico_enviro/enviro_all.py index b8b48140b..fc27cb4df 100644 --- a/micropython/examples/pico_enviro/enviro_all.py +++ b/micropython/examples/pico_enviro/enviro_all.py @@ -189,7 +189,7 @@ def draw_hist(results_array): time.sleep(0.5) while True: - # turn off the backlight with A and turn it back on with B + # turn on the backlight with A and turn it back off with B # switch between sensor and equaliser mode with X and Y if button_a.is_pressed: display.set_backlight(BRIGHTNESS) From 1e6e68356a931f9eee556c182d55a611a807d19f Mon Sep 17 00:00:00 2001 From: Angus Logan Date: Fri, 23 Jun 2023 20:27:10 +0100 Subject: [PATCH 3/3] Add rounding to lux report to prevent unit being overwritten Correct unit for centigrade --- micropython/examples/pico_enviro/enviro_all.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/micropython/examples/pico_enviro/enviro_all.py b/micropython/examples/pico_enviro/enviro_all.py index fc27cb4df..8249bd4b7 100644 --- a/micropython/examples/pico_enviro/enviro_all.py +++ b/micropython/examples/pico_enviro/enviro_all.py @@ -266,7 +266,7 @@ def draw_hist(results_array): display.set_pen(RED) if corrected_temperature < 10: display.set_pen(CYAN) - display.text(f"{corrected_temperature:.1f}°c", 5, 15, WIDTH, scale=4) + display.text(f"{corrected_temperature:.1f}°C", 5, 15, WIDTH, scale=4) # draw temp max and min display.set_pen(CYAN) @@ -278,7 +278,7 @@ def draw_hist(results_array): display.set_pen(WHITE) display.text(f"rh {corrected_humidity:.0f}%", 0, 75, WIDTH, scale=3) display.text(f"{pressure_hpa:.0f}hPa", 0, 125, WIDTH, scale=3) - display.text(f"{lux} lux", 0, 175, WIDTH, scale=3) + display.text(f"{lux:.0f} lux", 0, 175, WIDTH, scale=3) # draw the second column of text display.text(f"{describe_humidity(corrected_humidity)}", 125, 75, WIDTH, scale=3)