37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import threading
|
|
from time import sleep
|
|
from kuukar.kuukar_lcd import lcd
|
|
from kuukar.kuukar_leds import leds
|
|
from kuukar.kuukar_sensors import sensors
|
|
|
|
|
|
class environment:
|
|
t_alerted = False
|
|
h_alerted = False
|
|
def __init__(self, lcd: lcd, leds: leds, sensors: sensors) -> None:
|
|
self.lcd = lcd
|
|
self.leds = leds
|
|
self.sensors = sensors
|
|
threading.Thread(target=self.__checker).start()
|
|
|
|
def __checker(self):
|
|
while True:
|
|
if self.sensors.get_temperature() > 38.0:
|
|
if not self.t_alerted:
|
|
#self.lcd.play_video("keke_died")
|
|
self.t_alerted = True
|
|
else:
|
|
self.t_alerted = False
|
|
|
|
if self.sensors.get_humidity_pct() > 60.0:
|
|
if not self.h_alerted:
|
|
#self.lcd.play_video("keke_cute_noise")
|
|
self.h_alerted = True
|
|
else:
|
|
self.h_alerted = False
|
|
|
|
if self.sensors.get_brightness_pct() < 25:
|
|
self.leds.set_headlights(True)
|
|
else:
|
|
self.leds.set_headlights(False)
|
|
sleep(1) |