always convert pwm value to int

This commit is contained in:
Siwat Sirichai 2022-11-10 22:46:25 +07:00
parent e41b4c69d8
commit 5adb74082a
1 changed files with 2 additions and 2 deletions

View File

@ -27,9 +27,9 @@ class motion:
def motor_write(self, forward_pin: int, reverse_pin: int, speed: int): def motor_write(self, forward_pin: int, reverse_pin: int, speed: int):
if speed < 0: if speed < 0:
self.drv.pwm_write(forward_pin, 0) self.drv.pwm_write(forward_pin, 0)
self.drv.pwm_write(reverse_pin, -speed) self.drv.pwm_write(reverse_pin, -int(speed))
elif speed >= 0: elif speed >= 0:
self.drv.pwm_write(forward_pin, speed) self.drv.pwm_write(forward_pin, int(speed))
self.drv.pwm_write(reverse_pin, 0) self.drv.pwm_write(reverse_pin, 0)
def drive(self, speed: int): def drive(self, speed: int):