added environment sensing
This commit is contained in:
parent
37d8285b97
commit
3c3010d590
|
@ -1,5 +1,5 @@
|
||||||
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
||||||
import kuukar_leds, kuukar_collision, kuukar_motion, kuukar_lcd, kuukar_sensors
|
import kuukar_leds, kuukar_collision, kuukar_motion, kuukar_lcd, kuukar_sensors, kuukar_environment
|
||||||
|
|
||||||
from kuukar_config import SERIAL_AUX_BOARD, SERIAL_DRIVER_BOARD
|
from kuukar_config import SERIAL_AUX_BOARD, SERIAL_DRIVER_BOARD
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -8,4 +8,6 @@ if __name__ == '__main__':
|
||||||
sensors = kuukar_sensors.sensors(aux_board,driver_board)
|
sensors = kuukar_sensors.sensors(aux_board,driver_board)
|
||||||
leds = kuukar_leds.leds(aux_board=aux_board)
|
leds = kuukar_leds.leds(aux_board=aux_board)
|
||||||
lcd = kuukar_lcd.lcd()
|
lcd = kuukar_lcd.lcd()
|
||||||
|
environment = kuukar_environment.environment(lcd,leds,sensors)
|
||||||
|
collision = kuukar_collision.collision(aux_board,lcd,leds)
|
||||||
motion = kuukar_motion.motion(driver_board=driver_board,leds=leds,sensors= sensors)
|
motion = kuukar_motion.motion(driver_board=driver_board,leds=leds,sensors= sensors)
|
|
@ -1,5 +1,6 @@
|
||||||
SERIAL_DRIVER_BOARD = "/dev/serial/by-id/..."
|
SERIAL_DRIVER_BOARD = "/dev/serial/by-id/..."
|
||||||
|
|
||||||
|
# HC Sonar Pins
|
||||||
SONAR_1_TRIG_PIN = 0
|
SONAR_1_TRIG_PIN = 0
|
||||||
SONAR_1_ECHO_PIN = 1
|
SONAR_1_ECHO_PIN = 1
|
||||||
SONAR_2_TRIG_PIN = 2
|
SONAR_2_TRIG_PIN = 2
|
||||||
|
@ -7,6 +8,7 @@ SONAR_2_ECHO_PIN = 3
|
||||||
SONAR_3_TRIG_PIN = 4
|
SONAR_3_TRIG_PIN = 4
|
||||||
SONAR_3_ECHO_PIN = 5
|
SONAR_3_ECHO_PIN = 5
|
||||||
|
|
||||||
|
# Motor Pins
|
||||||
MOTOR_FL_F = 6
|
MOTOR_FL_F = 6
|
||||||
MOTOR_FL_R = 7
|
MOTOR_FL_R = 7
|
||||||
MOTOR_FR_F = 8
|
MOTOR_FR_F = 8
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
from kuukar_lcd import lcd
|
from kuukar_lcd import lcd
|
||||||
from kuukar_leds import leds
|
from kuukar_leds import leds
|
||||||
|
|
||||||
|
|
||||||
class cv:
|
class cv:
|
||||||
def __init__(self, lcd: lcd, leds: leds) -> None:
|
def __init__(self, lcd: lcd, leds: leds) -> None:
|
||||||
self.lcd = lcd
|
self.lcd = lcd
|
||||||
self.leds = leds
|
self.leds = leds
|
||||||
self.noise = noise
|
self.noise = noise
|
||||||
|
|
||||||
def capture_image(self):
|
def capture_image(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def detectFace(self, image):
|
def detectFace(self, image):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def handle_face_detected(self):
|
def handle_face_detected(self):
|
||||||
pass
|
pass
|
|
@ -0,0 +1,33 @@
|
||||||
|
import threading
|
||||||
|
from time import sleep
|
||||||
|
from kuukar_lcd import lcd
|
||||||
|
from kuukar_leds import leds
|
||||||
|
from 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:
|
||||||
|
lcd.keke_died()
|
||||||
|
self.t_alerted = True
|
||||||
|
else:
|
||||||
|
self.t_alerted = False
|
||||||
|
|
||||||
|
if self.sensors.get_humidity_pct() > 60.0:
|
||||||
|
if not self.h_alerted:
|
||||||
|
lcd.keke_cute_noise()
|
||||||
|
self.h_alerted = True
|
||||||
|
else:
|
||||||
|
self.h_alerted = False
|
||||||
|
|
||||||
|
sleep(5)
|
|
@ -5,9 +5,15 @@ class lcd:
|
||||||
def keke_uwu(self):
|
def keke_uwu(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def keke_cute_noise(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def keke_hurt(self):
|
def keke_hurt(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def keke_died(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def takina_noise(self):
|
def takina_noise(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -20,7 +26,6 @@ class lcd:
|
||||||
def resume_video(self) -> None:
|
def resume_video(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def stop_video(self) -> None:
|
def stop_video(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
||||||
|
|
||||||
from kuukar_config import LEDS_DATA_PIN, LEDS_NUM
|
from kuukar_config import LEDS_DATA_PIN, LEDS_NUM
|
||||||
|
|
||||||
|
|
||||||
class leds:
|
class leds:
|
||||||
def __init__(self, aux_board: telemetrix_rpi_pico.TelemetrixRpiPico) -> None:
|
def __init__(self, aux_board: telemetrix_rpi_pico.TelemetrixRpiPico) -> None:
|
||||||
self.aux_board = aux_board
|
self.aux_board = aux_board
|
||||||
|
|
|
@ -6,6 +6,7 @@ from kuukar_sensors import sensors
|
||||||
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
|
||||||
class motion:
|
class motion:
|
||||||
|
|
||||||
roaming = False
|
roaming = False
|
||||||
|
@ -17,7 +18,8 @@ class motion:
|
||||||
self.roam_thread = threading.Thread(target=self.roam_loop)
|
self.roam_thread = threading.Thread(target=self.roam_loop)
|
||||||
self.roam_thread.start()
|
self.roam_thread.start()
|
||||||
|
|
||||||
drive_pins = [MOTOR_FL_F,MOTOR_FL_R,MOTOR_FR_F,MOTOR_FR_R,MOTOR_RL_F,MOTOR_RL_R,MOTOR_RR_F,MOTOR_RR_R]
|
drive_pins = [MOTOR_FL_F, MOTOR_FL_R, MOTOR_FR_F,
|
||||||
|
MOTOR_FR_R, MOTOR_RL_F, MOTOR_RL_R, MOTOR_RR_F, MOTOR_RR_R]
|
||||||
for drive_pin in drive_pins:
|
for drive_pin in drive_pins:
|
||||||
self.driver.set_pin_mode_pwm_output(drive_pin)
|
self.driver.set_pin_mode_pwm_output(drive_pin)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ from kuukar_config import DHT22_PIN, SONAR_1_ECHO_PIN, SONAR_1_TRIG_PIN, SONAR_2
|
||||||
|
|
||||||
class sensors:
|
class sensors:
|
||||||
|
|
||||||
__sonar_trig_pins__ = [SONAR_1_TRIG_PIN, SONAR_2_TRIG_PIN, SONAR_3_TRIG_PIN]
|
__sonar_trig_pins__ = [SONAR_1_TRIG_PIN,
|
||||||
|
SONAR_2_TRIG_PIN, SONAR_3_TRIG_PIN]
|
||||||
__sonar_distances__ = [0, 0, 0]
|
__sonar_distances__ = [0, 0, 0]
|
||||||
__temperature__ = 0
|
__temperature__ = 0
|
||||||
__humidity__ = 0
|
__humidity__ = 0
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
import threading
|
|
||||||
from time import sleep
|
|
||||||
from kuukar_lcd import lcd
|
|
||||||
from kuukar_leds import leds
|
|
||||||
from kuukar_sensors import sensors
|
|
||||||
|
|
||||||
|
|
||||||
class temperature:
|
|
||||||
def __init__(self, lcd: lcd, leds: leds, sensors: sensors) -> None:
|
|
||||||
self.lcd = lcd
|
|
||||||
self.leds = leds
|
|
||||||
self.sensors = sensors
|
|
||||||
threading.Thread(target=self.temperature_checker).start()
|
|
||||||
|
|
||||||
def temperature_checker(self):
|
|
||||||
while True:
|
|
||||||
sleep(5)
|
|
Loading…
Reference in New Issue