implement screen updator
This commit is contained in:
parent
cca77561b2
commit
59be6810ee
|
@ -3,15 +3,20 @@ from socket import gethostname, gethostbyname
|
||||||
import kuukar.kuukar_nextion as kuukar_nextion
|
import kuukar.kuukar_nextion as kuukar_nextion
|
||||||
import kuukar.kuukar_motion as kuukar_motion
|
import kuukar.kuukar_motion as kuukar_motion
|
||||||
import kuukar.kuukar_sensors as kuukar_sensors
|
import kuukar.kuukar_sensors as kuukar_sensors
|
||||||
|
from threading import Thread
|
||||||
|
|
||||||
|
|
||||||
class lcd:
|
class lcd:
|
||||||
def __init__(self, motion: kuukar_motion.motion, sensors: kuukar_sensors.sensors) -> None:
|
def __init__(self, motion: kuukar_motion.motion, sensors: kuukar_sensors.sensors) -> None:
|
||||||
self.nextion = kuukar_nextion.nextion()
|
self.nextion = kuukar_nextion.nextion()
|
||||||
|
self.motion = motion
|
||||||
|
self.sensors = sensors
|
||||||
sleep(1)
|
sleep(1)
|
||||||
self.nextion.send_command("page home")
|
self.nextion.send_command("page home")
|
||||||
self.nextion.send_command("ipTXT.txt=\"" + str(gethostbyname(gethostname())) + "\"")
|
self.nextion.send_command(
|
||||||
|
"ipTXT.txt=\"" + str(gethostbyname(gethostname())) + "\"")
|
||||||
self.nextion.external_touch_handler = self.touch_handler
|
self.nextion.external_touch_handler = self.touch_handler
|
||||||
|
Thread(target=self._sensor_screen_updator).start()
|
||||||
|
|
||||||
def play_video(self, filename: str) -> None:
|
def play_video(self, filename: str) -> None:
|
||||||
self.nextion.send_command("page video_player")
|
self.nextion.send_command("page video_player")
|
||||||
|
@ -44,4 +49,13 @@ class lcd:
|
||||||
print(f"Setting speed to {speed} and turn angle to {turn}")
|
print(f"Setting speed to {speed} and turn angle to {turn}")
|
||||||
|
|
||||||
def _sensor_screen_updator(self):
|
def _sensor_screen_updator(self):
|
||||||
pass
|
while True:
|
||||||
|
self.nextion.send_command(
|
||||||
|
f"tempTXT.txt=\"{self.sensors.get_temperature()} C\"")
|
||||||
|
self.nextion.send_command(
|
||||||
|
f"humidityTXT.txt=\"{self.sensors.get_humidity_pct()}%\"")
|
||||||
|
self.nextion.send_command(
|
||||||
|
f"brightnessTXT.txt=\"{self.sensors.get_brightness_pct()}\"")
|
||||||
|
self.nextion.send_command(
|
||||||
|
f"sonarTXT.txt=\"{int(self.sensors.sonar_get_distance(0))} / {int(self.sensors.sonar_get_distance(1))} / {int(self.sensors.sonar_get_distance(2))}\"")
|
||||||
|
sleep(1)
|
||||||
|
|
Loading…
Reference in New Issue