From dbfdd546eac0440603fb33a861587f3d03b0ba15 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 8 Dec 2022 21:39:18 +0700 Subject: [PATCH] remove reference to drv in motion --- kuukar/kuukar.py | 2 +- kuukar/kuukar_motion.py | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/kuukar/kuukar.py b/kuukar/kuukar.py index e11077c..4a6da44 100644 --- a/kuukar/kuukar.py +++ b/kuukar/kuukar.py @@ -15,7 +15,7 @@ class kuukar: self.sensors = kuukar_sensors.sensors(self.mcu) self.leds = kuukar_leds.leds(self.mcu) self.motion = kuukar_motion.motion( - self.mcu, self.drv, self.leds, self.sensors) + self.mcu, self.leds, self.sensors) self.lcd = kuukar_lcd.lcd(self.motion, self.sensors) self.environment = kuukar_environment.environment( self.lcd, self.leds, self.sensors) diff --git a/kuukar/kuukar_motion.py b/kuukar/kuukar_motion.py index eb8a573..1642565 100644 --- a/kuukar/kuukar_motion.py +++ b/kuukar/kuukar_motion.py @@ -11,9 +11,8 @@ class motion: roaming = False - def __init__(self, mcu: telemetrix_rpi_pico.TelemetrixRpiPico, drv: telemetrix_rpi_pico.TelemetrixRpiPico, leds: leds, sensors: sensors) -> None: + def __init__(self, mcu: telemetrix_rpi_pico.TelemetrixRpiPico, leds: leds, sensors: sensors) -> None: self.mcu = mcu - self.drv = drv self.leds = leds self.sensors = sensors self.roam_thread = threading.Thread(target=self.__roam_looper) @@ -22,15 +21,15 @@ class motion: 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.drv.set_pin_mode_pwm_output(drive_pin) + self.mcu.set_pin_mode_pwm_output(drive_pin) def motor_write(self, forward_pin: int, reverse_pin: int, speed: int): if speed < 0: - self.drv.pwm_write(forward_pin, 0) - self.drv.pwm_write(reverse_pin, -int(speed)) + self.mcu.pwm_write(forward_pin, 0) + self.mcu.pwm_write(reverse_pin, -int(speed)) elif speed >= 0: - self.drv.pwm_write(forward_pin, int(speed)) - self.drv.pwm_write(reverse_pin, 0) + self.mcu.pwm_write(forward_pin, int(speed)) + self.mcu.pwm_write(reverse_pin, 0) def drive(self, speed: int): self.motor_write(MOTOR_FL_F, MOTOR_FL_R, speed)