From ab3a4477c70de280d1f5ca6ffc5c540343b56137 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Wed, 9 Nov 2022 23:15:28 +0700 Subject: [PATCH] handle manual error --- kuukar/kuukar_lcd.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kuukar/kuukar_lcd.py b/kuukar/kuukar_lcd.py index 7af9ab1..49ce19b 100644 --- a/kuukar/kuukar_lcd.py +++ b/kuukar/kuukar_lcd.py @@ -46,11 +46,12 @@ class lcd: if component_id == 2 and press_type == '00': x = self.nextion.get_attribute("joystick.x") y = self.nextion.get_attribute("joystick.y") - speed = 100 - (y - 60) / (205 - 60) * 200 - turn = (x - 5) / (150 - 5) * 200 - 100 - print(f"Setting speed to {speed} and turn angle to {turn}") - if not self.motion.is_roaming(): - self.motion.drive_skew(speed,turn) + if x is not None and y is not None: + speed = 100 - (y - 60) / (205 - 60) * 200 + turn = (x - 5) / (150 - 5) * 200 - 100 + print(f"Setting speed to {speed} and turn angle to {turn}") + if not self.motion.is_roaming(): + self.motion.drive_skew(speed,turn) def _sensor_screen_updator(self): while True: self.nextion.send_command(