From 8ef7e8f23d173515f7fafc07c8caf3f9266b0263 Mon Sep 17 00:00:00 2001 From: kokofixcomputers Date: Tue, 12 Nov 2024 05:46:59 +0000 Subject: [PATCH] Update LEGO Technic 42176 XBOX RC.py --- LEGO Technic 42176 XBOX RC.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/LEGO Technic 42176 XBOX RC.py b/LEGO Technic 42176 XBOX RC.py index 2ebe2fb..bfdd0cd 100644 --- a/LEGO Technic 42176 XBOX RC.py +++ b/LEGO Technic 42176 XBOX RC.py @@ -194,18 +194,18 @@ async def main(): throttle_old = 0 steering_old = 0 lights_old = 0 + lights_extra_old = 0 was_brake = False start_time = time.time() slow_mode = False slow_mode_old = False - change_lights_because_of_slowmode_on = False - change_lights_because_of_slowmode_off = False + change_lights_back = False + change_lights_back_execution_count = 0 try: while True: # Pump Pygame event loop pygame.event.pump() # poll joystick - # Print controller inputs throttle = get_right_joystick(joystick)[1] steering = get_left_joystick(joystick)[0] @@ -216,6 +216,9 @@ async def main(): if abs(steering)< 3: steering = 0 + if change_lights_back == True and change_lights_back_execution_count == 10: + lights = lights_extra_old + brake = get_right_bumper(joystick) # toggle lights toggle = get_Y_button(joystick) @@ -233,11 +236,17 @@ async def main(): if slow_mode == True: print("slowmode off") slow_mode = False + lights_extra_old = lights + lights = hub.LIGHTS_OFF_OFF #await hub.change_led_color(hub.LIGHTS_OFF_OFF) else: print("slowmode on") slow_mode = True + lights_extra_old = lights + lights = hub.LIGHTS_OFF_ON #await hub.change_led_color(hub.LIGHTS_OFF_ON) + change_lights_back = True + change_lights_back_execution_count = 0 slow_mode_old = slow_mode_cont @@ -267,8 +276,9 @@ async def main(): # Flush the output sys.stdout.flush() + change_lights_back_execution_count += 1 - asyncio.sleep(0.05) + time.sleep(0.05) except KeyboardInterrupt: pass