update sticky light behavior

This commit is contained in:
Siwat Sirichai 2022-11-10 22:50:31 +07:00
parent 5adb74082a
commit e1d6df41fc
1 changed files with 7 additions and 0 deletions

View File

@ -40,9 +40,11 @@ class motion:
def turn(self, speed: int, duration: float):
if speed > 0:
self.leds.set_left_signal_led(False)
self.leds.set_right_signal_led(True)
elif speed < 0:
self.leds.set_left_signal_led(True)
self.leds.set_right_signal_led(False)
self.motor_write(MOTOR_FL_F, MOTOR_FL_R, speed)
self.motor_write(MOTOR_FR_F, MOTOR_FR_R, -speed)
self.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed)
@ -53,7 +55,9 @@ class motion:
def turn_cont(self, speed: int):
if speed > 0:
self.leds.set_right_signal_led(True)
self.leds.set_left_signal_led(False)
elif speed < 0:
self.leds.set_right_signal_led(False)
self.leds.set_left_signal_led(True)
self.motor_write(MOTOR_FL_F, MOTOR_FL_R, speed)
self.motor_write(MOTOR_FR_F, MOTOR_FR_R, -speed)
@ -63,9 +67,12 @@ class motion:
def drive_skew(self, speed: float, dir: float):
if dir > 0:
self.leds.set_right_signal_led(True)
self.leds.set_left_signal_led(False)
elif dir < 0:
self.leds.set_right_signal_led(False)
self.leds.set_left_signal_led(True)
lm_speed = (100+dir/2)*speed/100
if lm_speed>99:
lm_speed = 99