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
|
throttle_old = 0
|
||||||
steering_old = 0
|
steering_old = 0
|
||||||
lights_old = 0
|
lights_old = 0
|
||||||
|
lights_extra_old = 0
|
||||||
was_brake = False
|
was_brake = False
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
slow_mode = False
|
slow_mode = False
|
||||||
slow_mode_old = False
|
slow_mode_old = False
|
||||||
change_lights_because_of_slowmode_on = False
|
change_lights_back = False
|
||||||
change_lights_because_of_slowmode_off = False
|
change_lights_back_execution_count = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
# Pump Pygame event loop
|
# Pump Pygame event loop
|
||||||
pygame.event.pump() # poll joystick
|
pygame.event.pump() # poll joystick
|
||||||
|
|
||||||
# Print controller inputs
|
# Print controller inputs
|
||||||
throttle = get_right_joystick(joystick)[1]
|
throttle = get_right_joystick(joystick)[1]
|
||||||
steering = get_left_joystick(joystick)[0]
|
steering = get_left_joystick(joystick)[0]
|
||||||
@ -216,6 +216,9 @@ async def main():
|
|||||||
if abs(steering)< 3:
|
if abs(steering)< 3:
|
||||||
steering = 0
|
steering = 0
|
||||||
|
|
||||||
|
if change_lights_back == True and change_lights_back_execution_count == 10:
|
||||||
|
lights = lights_extra_old
|
||||||
|
|
||||||
brake = get_right_bumper(joystick)
|
brake = get_right_bumper(joystick)
|
||||||
# toggle lights
|
# toggle lights
|
||||||
toggle = get_Y_button(joystick)
|
toggle = get_Y_button(joystick)
|
||||||
@ -233,11 +236,17 @@ async def main():
|
|||||||
if slow_mode == True:
|
if slow_mode == True:
|
||||||
print("slowmode off")
|
print("slowmode off")
|
||||||
slow_mode = False
|
slow_mode = False
|
||||||
|
lights_extra_old = lights
|
||||||
|
lights = hub.LIGHTS_OFF_OFF
|
||||||
#await hub.change_led_color(hub.LIGHTS_OFF_OFF)
|
#await hub.change_led_color(hub.LIGHTS_OFF_OFF)
|
||||||
else:
|
else:
|
||||||
print("slowmode on")
|
print("slowmode on")
|
||||||
slow_mode = True
|
slow_mode = True
|
||||||
|
lights_extra_old = lights
|
||||||
|
lights = hub.LIGHTS_OFF_ON
|
||||||
#await hub.change_led_color(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
|
slow_mode_old = slow_mode_cont
|
||||||
|
|
||||||
|
|
||||||
@ -267,8 +276,9 @@ async def main():
|
|||||||
|
|
||||||
# Flush the output
|
# Flush the output
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
change_lights_back_execution_count += 1
|
||||||
|
|
||||||
asyncio.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user