Updated to use temp/hum/pres inside peripherals
This commit is contained in:
parent
d6982a12a2
commit
02f21270d7
1 changed files with 3 additions and 11 deletions
|
|
@ -3,10 +3,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
import time
|
import time
|
||||||
import board
|
|
||||||
import json
|
import json
|
||||||
import adafruit_dps310
|
|
||||||
import adafruit_ahtx0
|
|
||||||
from adafruit_display_shapes.circle import Circle
|
from adafruit_display_shapes.circle import Circle
|
||||||
from adafruit_funhouse import FunHouse
|
from adafruit_funhouse import FunHouse
|
||||||
|
|
||||||
|
|
@ -25,11 +22,6 @@ except ImportError:
|
||||||
print("WiFi secrets are kept in secrets.py, please add them there!")
|
print("WiFi secrets are kept in secrets.py, please add them there!")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Connect to the Sensors
|
|
||||||
i2c = board.I2C()
|
|
||||||
dps310 = adafruit_dps310.DPS310(i2c)
|
|
||||||
aht20 = adafruit_ahtx0.AHTx0(i2c)
|
|
||||||
|
|
||||||
funhouse = FunHouse(default_bg=0x0F0F00)
|
funhouse = FunHouse(default_bg=0x0F0F00)
|
||||||
funhouse.peripherals.dotstars.fill(INITIAL_LIGHT_COLOR)
|
funhouse.peripherals.dotstars.fill(INITIAL_LIGHT_COLOR)
|
||||||
|
|
||||||
|
|
@ -79,15 +71,15 @@ funhouse.splash.append(status)
|
||||||
def update_enviro():
|
def update_enviro():
|
||||||
global environment
|
global environment
|
||||||
|
|
||||||
temp = aht20.temperature
|
temp = funhouse.peripherals.temperature
|
||||||
unit = "C"
|
unit = "C"
|
||||||
if USE_FAHRENHEIT:
|
if USE_FAHRENHEIT:
|
||||||
temp = temp * (9 / 5) + 32
|
temp = temp * (9 / 5) + 32
|
||||||
unit = "F"
|
unit = "F"
|
||||||
|
|
||||||
environment["temperature"] = temp
|
environment["temperature"] = temp
|
||||||
environment["pressure"] = dps310.pressure
|
environment["pressure"] = funhouse.peripherals.pressure
|
||||||
environment["humidity"] = aht20.relative_humidity
|
environment["humidity"] = funhouse.peripherals.relative_humidity
|
||||||
environment["light"] = funhouse.peripherals.light
|
environment["light"] = funhouse.peripherals.light
|
||||||
|
|
||||||
funhouse.set_text("{:.1f}{}".format(environment["temperature"], unit), temp_label)
|
funhouse.set_text("{:.1f}{}".format(environment["temperature"], unit), temp_label)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue