added environment sensing

This commit is contained in:
Siwat Sirichai 2022-10-25 22:01:26 +07:00
parent 37d8285b97
commit 3c3010d590
9 changed files with 90 additions and 56 deletions

View File

@ -1,5 +1,5 @@
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
if __name__ == '__main__':
@ -8,4 +8,6 @@ if __name__ == '__main__':
sensors = kuukar_sensors.sensors(aux_board,driver_board)
leds = kuukar_leds.leds(aux_board=aux_board)
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)

View File

@ -1,5 +1,6 @@
SERIAL_DRIVER_BOARD = "/dev/serial/by-id/..."
# HC Sonar Pins
SONAR_1_TRIG_PIN = 0
SONAR_1_ECHO_PIN = 1
SONAR_2_TRIG_PIN = 2
@ -7,6 +8,7 @@ SONAR_2_ECHO_PIN = 3
SONAR_3_TRIG_PIN = 4
SONAR_3_ECHO_PIN = 5
# Motor Pins
MOTOR_FL_F = 6
MOTOR_FL_R = 7
MOTOR_FR_F = 8

View File

@ -1,14 +1,18 @@
from kuukar_lcd import lcd
from kuukar_leds import leds
class cv:
def __init__(self, lcd: lcd, leds: leds) -> None:
self.lcd = lcd
self.leds = leds
self.noise = noise
def capture_image(self):
pass
def detectFace(self, image):
pass
def handle_face_detected(self):
pass

33
kuukar_environment.py Normal file
View File

@ -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)

View File

@ -5,9 +5,15 @@ class lcd:
def keke_uwu(self):
pass
def keke_cute_noise(self):
pass
def keke_hurt(self):
pass
def keke_died(self):
pass
def takina_noise(self):
pass
@ -20,7 +26,6 @@ class lcd:
def resume_video(self) -> None:
pass
def stop_video(self) -> None:
pass

View File

@ -1,6 +1,8 @@
from telemetrix_rpi_pico import telemetrix_rpi_pico
from kuukar_config import LEDS_DATA_PIN, LEDS_NUM
class leds:
def __init__(self, aux_board: telemetrix_rpi_pico.TelemetrixRpiPico) -> None:
self.aux_board = aux_board

View File

@ -6,6 +6,7 @@ from kuukar_sensors import sensors
from telemetrix_rpi_pico import telemetrix_rpi_pico
import threading
class motion:
roaming = False
@ -17,7 +18,8 @@ class motion:
self.roam_thread = threading.Thread(target=self.roam_loop)
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:
self.driver.set_pin_mode_pwm_output(drive_pin)

View File

@ -5,7 +5,8 @@ from kuukar_config import DHT22_PIN, SONAR_1_ECHO_PIN, SONAR_1_TRIG_PIN, SONAR_2
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]
__temperature__ = 0
__humidity__ = 0

View File

@ -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)