Update LEGO Technic 42176 XBOX RC.py
This commit is contained in:
parent
f5bc9ad12a
commit
8ef7e8f23d
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user