kuukar-rpi/kuukar/kuukar_environment.py

37 lines
1.1 KiB
Python
Raw Normal View History

2022-10-25 15:01:26 +00:00
import threading
from time import sleep
2022-10-30 08:57:00 +00:00
from kuukar.kuukar_lcd import lcd
from kuukar.kuukar_leds import leds
from kuukar.kuukar_sensors import sensors
2022-10-25 15:01:26 +00:00
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
2022-10-28 07:14:00 +00:00
threading.Thread(target=self.__checker).start()
2022-10-25 15:01:26 +00:00
2022-10-28 07:14:00 +00:00
def __checker(self):
2022-10-25 15:01:26 +00:00
while True:
if self.sensors.get_temperature() > 38.0:
if not self.t_alerted:
2022-11-09 16:10:12 +00:00
#self.lcd.play_video("keke_died")
2022-10-25 15:01:26 +00:00
self.t_alerted = True
else:
self.t_alerted = False
2022-12-12 04:14:34 +00:00
if self.sensors.get_humidity_pct() > 80.0:
2022-10-25 15:01:26 +00:00
if not self.h_alerted:
2022-12-12 04:14:34 +00:00
self.lcd.play_video("kanon_hurt")
2022-10-25 15:01:26 +00:00
self.h_alerted = True
else:
self.h_alerted = False
2022-11-10 15:41:01 +00:00
if self.sensors.get_brightness_pct() < 25:
2022-10-28 07:14:00 +00:00
self.leds.set_headlights(True)
else:
self.leds.set_headlights(False)
2022-11-03 08:53:27 +00:00
sleep(1)