This commit is contained in:
Danny Staple
2023-01-02 12:26:53 +00:00
parent 92e3f85094
commit d56b89787e
+5 -7
View File
@@ -32,7 +32,9 @@ async def command_handler():
robot.stop() robot.stop()
elif command.startswith("G"): elif command.startswith("G"):
await asyncio.sleep(5) await asyncio.sleep(5)
asyncio.create_task(stop_motors_after(float(command[1:]))) asyncio.create_task(
stop_motors_after(float(command[1:]))
)
robot.set_left(Settings.speed) robot.set_left(Settings.speed)
robot.set_right(Settings.speed) robot.set_right(Settings.speed)
elif command.startswith("?"): elif command.startswith("?"):
@@ -41,9 +43,5 @@ async def command_handler():
await asyncio.sleep(3) await asyncio.sleep(3)
await asyncio.sleep(0) await asyncio.sleep(0)
try: asyncio.create_task(motor_speed_loop())
motor_task = asyncio.create_task(motor_speed_loop()) asyncio.run(command_handler())
asyncio.run(command_handler())
finally:
motor_task.cancel()
robot.stop()