def rotate_until_stalled(speed): counter = 0 motor_power(SPINNER, speed) previous = abs(get_motor_position_counter(SPINNER)) while counter < 10: if abs(get_motor_position_counter(SPINNER)) == previous: counter += 1 else: counter = 0 previous = abs(get_motor_position_counter(SPINNER)) msleep(10) freeze(SPINNER) clear_motor_position_counter(SPINNER)
def _clear_ticks(): # Clears the motor ticks. clear_motor_position_counter(RMOTOR) clear_motor_position_counter(LMOTOR)
def set_spinner_safe(): clear_motor_position_counter(SPINNER)
def wait_for_someone_to_rotate(): display("please spin me back") clear_motor_position_counter(SPINNER) while abs(get_motor_position_counter(SPINNER)) < 350: pass display("good job")