mirror of
https://github.com/easytarget/MQ-Pro-IO.git
synced 2025-10-14 01:35:52 +01:00
tweak
This commit is contained in:
parent
bc5feff23e
commit
d98ed556e5
19
GPIO-demo.py
19
GPIO-demo.py
@ -1,10 +1,15 @@
|
|||||||
'''
|
'''
|
||||||
Demo Python GPIO on the MQ-Pro (requires a modified device tree)
|
Demo Python GPIO on the MQ-Pro (requires a modified device tree)
|
||||||
See: https://github.com/easytarget/MQ-Pro-IO/
|
See: https://github.com/easytarget/MQ-Pro-IO/
|
||||||
For install requirements requirements look at:
|
|
||||||
- https://github.com/easytarget/MQ-Pro-IO/blob/main/GPIO-examples.md#python-demo
|
For install requirements requirements look at:
|
||||||
|
- https://github.com/easytarget/MQ-Pro-IO/blob/main/GPIO-examples.md#python-demo
|
||||||
|
Tested using the LoRa HAT device tree:
|
||||||
|
- https://github.com/easytarget/MQ-Pro-IO/tree/main/alt-trees/lora-hat
|
||||||
'''
|
'''
|
||||||
from time import sleep
|
|
||||||
|
from time import sleep, ctime
|
||||||
|
|
||||||
# oled libs
|
# oled libs
|
||||||
from luma.core.interface.serial import i2c
|
from luma.core.interface.serial import i2c
|
||||||
from luma.core.render import canvas
|
from luma.core.render import canvas
|
||||||
@ -31,9 +36,9 @@ while True:
|
|||||||
t = round(bme280.get_temperature(),1)
|
t = round(bme280.get_temperature(),1)
|
||||||
h = round(bme280.get_humidity(),1)
|
h = round(bme280.get_humidity(),1)
|
||||||
p = round(bme280.get_pressure())
|
p = round(bme280.get_pressure())
|
||||||
out = ' Temp: {}°\n Humi: {}%\n Pres: {}mb'.format(t,h,p)
|
out = ' Temp: {}°C\n Humi: {}%\n Pres: {}mb'.format(t,h,p)
|
||||||
with canvas(device) as draw:
|
with canvas(device) as draw:
|
||||||
draw.rectangle(device.bounding_box, outline="white", fill="black")
|
draw.rectangle(device.bounding_box, outline="white", fill="black")
|
||||||
draw.text((26, 12), out, fill="white")
|
draw.text((26, 12), out, fill="white")
|
||||||
print(out.replace('\n',' : '))
|
print('{} : {}°C, {}%, {}mb'.format(ctime(),t,h,p)
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user