mirror of
https://github.com/easytarget/MQ-Pro-IO.git
synced 2025-10-14 01:35: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())
|
p = round(bme280.get_pressure())
|
||||||
return t, h, p
|
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()
|
_, _, _ = read_sensor()
|
||||||
|
show_text('Initialising..', 36, 26)
|
||||||
|
print('Initialising')
|
||||||
|
|
||||||
# loop
|
# loop
|
||||||
while True:
|
while True:
|
||||||
sleep(1)
|
sleep(1)
|
||||||
temp, humi, pres = read_sensor()
|
temp, humi, pres = read_sensor()
|
||||||
out = ' Temp: {}°C\n Humi: {}%\n Pres: {}mb'.format(temp, humi, pres)
|
out = ' Temp: {}°C\n Humi: {}%\n Pres: {}mb'.format(temp, humi, pres)
|
||||||
with canvas(device) as draw:
|
show_text(out, 26, 12)
|
||||||
draw.rectangle(device.bounding_box, outline="white", fill="black")
|
|
||||||
draw.text((26, 12), out, fill="white")
|
|
||||||
print('{} :: {}°C, {}%, {}mb'.format(ctime(),temp, humi, pres))
|
print('{} :: {}°C, {}%, {}mb'.format(ctime(),temp, humi, pres))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user