mirror of
https://github.com/easytarget/MQ-Pro-IO.git
synced 2025-10-13 17:25:52 +01:00
enfancify demo
This commit is contained in:
parent
454de66351
commit
c0d10677aa
13
GPIO-demo.py
13
GPIO-demo.py
@ -38,15 +38,20 @@ def read_sensor():
|
||||
p = round(bme280.get_pressure())
|
||||
return t, h, p
|
||||
|
||||
# initial reading settles sensor
|
||||
def show_text(s, x, y):
|
||||
with canvas(device) as draw:
|
||||
draw.rectangle(device.bounding_box, outline="white", fill="black")
|
||||
draw.text((x, y), s, fill="white")
|
||||
|
||||
# initial reading to settle sensor
|
||||
_, _, _ = read_sensor()
|
||||
show_text('Initialising..', 36, 26)
|
||||
print('Initialising')
|
||||
|
||||
# loop
|
||||
while True:
|
||||
sleep(1)
|
||||
temp, humi, pres = read_sensor()
|
||||
out = ' Temp: {}°C\n Humi: {}%\n Pres: {}mb'.format(temp, humi, pres)
|
||||
with canvas(device) as draw:
|
||||
draw.rectangle(device.bounding_box, outline="white", fill="black")
|
||||
draw.text((26, 12), out, fill="white")
|
||||
show_text(out, 26, 12)
|
||||
print('{} :: {}°C, {}%, {}mb'.format(ctime(),temp, humi, pres))
|
||||
|
Loading…
x
Reference in New Issue
Block a user