async def read_gamepad_inputs(): global head_light_flag print("Ready to drive!!") turn_sound = SoundPlayer( "/home/pi/xbox-raspberrypi-rover/soundfiles/turn-signal.mp3", card) horn_sound = SoundPlayer( "/home/pi/xbox-raspberrypi-rover/soundfiles/Horn.mp3", card) while not is_connected(): time.sleep(2) # Wait 2 seconds for controller to come up and try again while is_connected() and remote_control.button_b == False: #print(" trigger_right = ", round(remote_control.trigger_right,2),end="\r") x = round(remote_control.joystick_left_x, 2) y = round(remote_control.joystick_left_y, 2) angle = get_angle_from_coords(x, y) if angle > 180: angle = 360 - angle #print("x:", x, " y:", y, " angle: ",angle,end="\r") turn_head(angle) direction = get_motor_direction(x, y) y = adjust_speed(y, angle) #print("x:", x, " y:", y, " direction: ",direction,end="\r") drive_motor(direction, y) if round(remote_control.trigger_right, 2) > 0.0: horn_sound.play(1.0) led.blue() elif round(remote_control.trigger_left, 2) > 0.0: led.cyan() elif remote_control.bump_left: turn_sound.play(1.0) led.turn_left(5) elif remote_control.bump_right: turn_sound.play(1.0) led.turn_right(5) elif remote_control.dpad_up: remote_control.dpad_up = False elif remote_control.dpad_left: remote_control.dpad_left = False elif remote_control.dpad_right: remote_control.dpad_right = False elif remote_control.button_a: remote_control.button_a = False elif head_light_flag == False: led.both_off() led_strip.colorWipe(strip, Color(0, 0, 0)) if turn_sound.isPlaying(): turn_sound.stop() await asyncio.sleep(100e-3) #100ms return
def turn_left_led(): #Turn on the LED on the left led.turn_left(4)
def turn_left_led(): '''Turn on the LED on the left''' #TODO: fix names #??? why not just use that one line... led.turn_left(4)