edit structure
This commit is contained in:
parent
8683898c3f
commit
7e9da402a6
46
app.py
46
app.py
|
@ -1,28 +1,32 @@
|
||||||
import time
|
import time
|
||||||
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
# from telemetrix_rpi_pico import telemetrix_rpi_pico
|
||||||
import kuukar.kuukar_leds as kuukar_leds
|
# import kuukar.kuukar_leds as kuukar_leds
|
||||||
import kuukar.kuukar_collision as kuukar_collision
|
# import kuukar.kuukar_collision as kuukar_collision
|
||||||
import kuukar.kuukar_motion as kuukar_motion
|
# import kuukar.kuukar_motion as kuukar_motion
|
||||||
import kuukar.kuukar_lcd as kuukar_lcd
|
# import kuukar.kuukar_lcd as kuukar_lcd
|
||||||
import kuukar.kuukar_sensors as kuukar_sensors
|
# import kuukar.kuukar_sensors as kuukar_sensors
|
||||||
import kuukar.kuukar_environment as kuukar_environment
|
# import kuukar.kuukar_environment as kuukar_environment
|
||||||
|
|
||||||
from kuukar.kuukar_config import SERIAL_MCU, SERIAL_DRV
|
# from kuukar.kuukar_config import SERIAL_MCU, SERIAL_DRV
|
||||||
|
|
||||||
mcu = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_MCU, sleep_tune=0.001)
|
from kuukar.kuukar import kuukar
|
||||||
drv = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_DRV, sleep_tune=0.001)
|
|
||||||
sensors = kuukar_sensors.sensors(mcu)
|
# mcu = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_MCU, sleep_tune=0.001)
|
||||||
leds = kuukar_leds.leds(mcu)
|
# drv = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_DRV, sleep_tune=0.001)
|
||||||
motion = kuukar_motion.motion(mcu, drv, leds, sensors)
|
# sensors = kuukar_sensors.sensors(mcu)
|
||||||
lcd = kuukar_lcd.lcd(motion, sensors)
|
# leds = kuukar_leds.leds(mcu)
|
||||||
environment = kuukar_environment.environment(lcd, leds, sensors)
|
# motion = kuukar_motion.motion(mcu, drv, leds, sensors)
|
||||||
collision = kuukar_collision.collision(mcu, lcd, leds)
|
# lcd = kuukar_lcd.lcd(motion, sensors)
|
||||||
|
# environment = kuukar_environment.environment(lcd, leds, sensors)
|
||||||
|
# collision = kuukar_collision.collision(mcu, lcd, leds)
|
||||||
|
|
||||||
|
car = kuukar()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
temp = sensors.get_temperature()
|
temp = car.sensors.get_temperature()
|
||||||
humid = sensors.get_humidity_pct()
|
humid = car.sensors.get_humidity_pct()
|
||||||
dist1 = sensors.sonar_get_distance(0)
|
dist1 = car.sensors.sonar_get_distance(0)
|
||||||
dist2 = sensors.sonar_get_distance(1)
|
dist2 = car.sensors.sonar_get_distance(1)
|
||||||
dist3 = sensors.sonar_get_distance(2)
|
dist3 = car.sensors.sonar_get_distance(2)
|
||||||
print(f'temp: {temp}, humidity: {humid}, dist1: {dist1}, dist2: {dist2}, dist3: {dist3}')
|
print(f'temp: {temp}, humidity: {humid}, dist1: {dist1}, dist2: {dist2}, dist3: {dist3}')
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
|
@ -7,13 +7,19 @@ import kuukar.kuukar_sensors as kuukar_sensors
|
||||||
import kuukar.kuukar_environment as kuukar_environment
|
import kuukar.kuukar_environment as kuukar_environment
|
||||||
from kuukar.kuukar_config import SERIAL_MCU, SERIAL_DRV
|
from kuukar.kuukar_config import SERIAL_MCU, SERIAL_DRV
|
||||||
|
|
||||||
|
|
||||||
class kuukar:
|
class kuukar:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.mcu = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_MCU, sleep_tune=0.001)
|
self.mcu = telemetrix_rpi_pico.TelemetrixRpiPico(
|
||||||
self.drv = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_DRV, sleep_tune=0.001)
|
com_port=SERIAL_MCU, sleep_tune=0.001)
|
||||||
self.sensors = kuukar_sensors.sensors(self.mcu)
|
self.drv = telemetrix_rpi_pico.TelemetrixRpiPico(
|
||||||
|
com_port=SERIAL_DRV, sleep_tune=0.001)
|
||||||
|
self.sensors = kuukar_sensors.sensors(self.mcu, self.drv)
|
||||||
self.leds = kuukar_leds.leds(self.mcu)
|
self.leds = kuukar_leds.leds(self.mcu)
|
||||||
self.motion = kuukar_motion.motion(self.mcu, self.drv, self.leds, self.sensors)
|
self.motion = kuukar_motion.motion(
|
||||||
|
self.mcu, self.drv, self.leds, self.sensors)
|
||||||
self.lcd = kuukar_lcd.lcd(self.motion, self.sensors)
|
self.lcd = kuukar_lcd.lcd(self.motion, self.sensors)
|
||||||
self.environment = kuukar_environment.environment(self.lcd, self.leds, self.sensors)
|
self.environment = kuukar_environment.environment(
|
||||||
self.collision = kuukar_collision.collision(self.mcu, self.lcd, self.leds)
|
self.lcd, self.leds, self.sensors)
|
||||||
|
self.collision = kuukar_collision.collision(
|
||||||
|
self.mcu, self.lcd, self.leds)
|
||||||
|
|
|
@ -12,13 +12,14 @@ class sensors:
|
||||||
__humidity = 0
|
__humidity = 0
|
||||||
__brightness = 0
|
__brightness = 0
|
||||||
|
|
||||||
def __init__(self, mcu: telemetrix_rpi_pico.TelemetrixRpiPico) -> None:
|
def __init__(self, mcu: telemetrix_rpi_pico.TelemetrixRpiPico, drv: telemetrix_rpi_pico.TelemetrixRpiPico) -> None:
|
||||||
self.mcu = mcu
|
self.mcu = mcu
|
||||||
|
self.drv = drv
|
||||||
self.mcu.set_pin_mode_analog_input(SONAR_1_ADC_PIN, 100, self.__sonar_callback)
|
self.mcu.set_pin_mode_analog_input(SONAR_1_ADC_PIN, 100, self.__sonar_callback)
|
||||||
self.mcu.set_pin_mode_analog_input(SONAR_2_ADC_PIN, 100, self.__sonar_callback)
|
self.mcu.set_pin_mode_analog_input(SONAR_2_ADC_PIN, 100, self.__sonar_callback)
|
||||||
self.mcu.set_pin_mode_analog_input(SONAR_3_ADC_PIN, 100, self.__sonar_callback)
|
self.mcu.set_pin_mode_analog_input(SONAR_3_ADC_PIN, 100, self.__sonar_callback)
|
||||||
self.mcu.set_pin_mode_dht(DHT22_PIN, self.__dht22_callback)
|
self.mcu.set_pin_mode_dht(DHT22_PIN, self.__dht22_callback)
|
||||||
self.mcu.set_pin_mode_analog_input(LIGHT_ANALOG_PIN, 0, self.__light_sensor_callback)
|
self.drv.set_pin_mode_analog_input(LIGHT_ANALOG_PIN, 0, self.__light_sensor_callback)
|
||||||
|
|
||||||
def sonar_get_distance(self, id: int) -> float:
|
def sonar_get_distance(self, id: int) -> float:
|
||||||
return self.__sonar_distances[id]
|
return self.__sonar_distances[id]
|
||||||
|
|
Loading…
Reference in New Issue