From ede5d70bceed58d14a84548c60289cc1539f9ae9 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Tue, 6 Dec 2022 13:39:39 +0700 Subject: [PATCH] change board for ultrasonic distance sensor --- kuukar/kuukar.py | 2 +- kuukar/kuukar_sensors.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/kuukar/kuukar.py b/kuukar/kuukar.py index 38212c5..7e0d435 100644 --- a/kuukar/kuukar.py +++ b/kuukar/kuukar.py @@ -11,7 +11,7 @@ class kuukar: def __init__(self) -> None: self.mcu = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_MCU, sleep_tune=0.001) self.drv = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_DRV, sleep_tune=0.001) - self.sensors = kuukar_sensors.sensors(self.mcu) + self.sensors = kuukar_sensors.sensors(self.mcu, self.drv) self.leds = kuukar_leds.leds(self.mcu) self.motion = kuukar_motion.motion(self.mcu, self.drv, self.leds, self.sensors) self.lcd = kuukar_lcd.lcd(self.motion, self.sensors) diff --git a/kuukar/kuukar_sensors.py b/kuukar/kuukar_sensors.py index e3b27a7..13d7565 100644 --- a/kuukar/kuukar_sensors.py +++ b/kuukar/kuukar_sensors.py @@ -12,11 +12,12 @@ class sensors: __humidity = 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.set_pin_mode_analog_input(SONAR_1_ADC_PIN, 10, self.__sonar_callback) - self.mcu.set_pin_mode_analog_input(SONAR_2_ADC_PIN, 10, self.__sonar_callback) - self.mcu.set_pin_mode_analog_input(SONAR_3_ADC_PIN, 10, self.__sonar_callback) + self.drv = mrv + self.drv.set_pin_mode_analog_input(SONAR_1_ADC_PIN, 10, self.__sonar_callback) + self.drv.set_pin_mode_analog_input(SONAR_2_ADC_PIN, 10, self.__sonar_callback) + self.drv.set_pin_mode_analog_input(SONAR_3_ADC_PIN, 10, self.__sonar_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)