diff --git a/badger_os/examples/icon-ieq.jpg b/badger_os/examples/icon-ieq.jpg new file mode 100644 index 0000000..35d3bd0 Binary files /dev/null and b/badger_os/examples/icon-ieq.jpg differ diff --git a/badger_os/examples/ieq.py b/badger_os/examples/ieq.py new file mode 100644 index 0000000..5c4b19b --- /dev/null +++ b/badger_os/examples/ieq.py @@ -0,0 +1,54 @@ +import time +import badger2040 +import badger_os +from breakout_bme68x import BreakoutBME68X +import pimoroni_i2c + +# Display Setup +display = badger2040.Badger2040() +display.led(128) +display.set_update_speed(2) + +WIDTH = badger2040.WIDTH +HEIGHT = badger2040.HEIGHT + +PINS_PICO_EXPLORER = {"sda": 4, "scl": 5} + +i2c = pimoroni_i2c.PimoroniI2C(**PINS_PICO_EXPLORER) +#bme = BreakoutBME68X(i2c,0x77) +bme = BreakoutBME68X(i2c) + +def draw_values(t,h,p): + + # Clear the display + display.set_pen(15) + display.clear() + display.set_pen(0) + display.set_font("sans") + + # Draw the page header + display.set_pen(15) + display.rectangle(0, 0, WIDTH, 20) + display.set_pen(0) + y=10 + display.text("IEQ", 0, 10, y, 0.5) + scale=100 + n=1 + offset=30 + display.text("T="+t+" C", 0 , y+offset, scale, n) + display.text("h="+h+" %", 0 , y+offset*2, scale, n) + display.text("p="+p+" hPa", 0 , y+offset*3, scale, n) + display.update() + + + +while True: + temperature, pressure, humidity, gas, status, _, _ = bme.read() + heater = "Stable" if status else "Unstable" # & STATUS_HEATER_STABLE + #print("{:0.2f}c, {:0.2f}Pa, {:0.2f}%, {:0.2f} Ohms, Heater: {}".format( + # temperature, pressure, humidity, gas, heater)) + temp = str(round(temperature,1)) + press = str(round(pressure/100,1)) + humid = str(round(humidity,1)) + draw_values(temp, humid, press) + time.sleep(10.0) diff --git a/badger_os/examples/qrgen.py b/badger_os/examples/qrgen.py index f1d7ff8..0814c50 100644 --- a/badger_os/examples/qrgen.py +++ b/badger_os/examples/qrgen.py @@ -3,6 +3,7 @@ import time import os import badger_os +import re # Check that the qrcodes directory exists, if not, make it try: @@ -76,6 +77,9 @@ def draw_qr_file(n): code_text = lines.pop(0) title_text = lines.pop(0) detail_text = lines + # For vcards to work, we need to be able to insert new lines. Use
as new line character: + code_text = re.sub("
","\n",code_text) + # Clear the Display display.set_pen(15) # Change this to 0 if a white background is used @@ -117,11 +121,17 @@ def draw_qr_file(n): if state["current_qr"] > 0: state["current_qr"] -= 1 changed = True + else: + state["current_qr"] = TOTAL_CODES - 1 + changed = True if display.pressed(badger2040.BUTTON_DOWN): if state["current_qr"] < TOTAL_CODES - 1: state["current_qr"] += 1 changed = True + else: + state["current_qr"] = 0 + changed = True if display.pressed(badger2040.BUTTON_B) or display.pressed(badger2040.BUTTON_C): display.set_pen(15)