Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding temperature sensing (IEQ; indoor environmental quality) + roll-over for qr code #8

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added badger_os/examples/icon-ieq.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions badger_os/examples/ieq.py
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 10 additions & 0 deletions badger_os/examples/qrgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
import os
import badger_os
import re

# Check that the qrcodes directory exists, if not, make it
try:
Expand Down Expand Up @@ -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 <br> as new line character:
code_text = re.sub("<br>","\n",code_text)


# Clear the Display
display.set_pen(15) # Change this to 0 if a white background is used
Expand Down Expand Up @@ -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)
Expand Down