@@ -0,0 +1,1384 @@
+from ev3dev.ev3 import MediumMotor, ColorSensor%0Afrom argparse import ArgumentParser%0Aimport time%0A%0Aparser = ArgumentParser()%0Aparser.add_argument('-m', '--motor-port', default='A')%0Aparser.add_argument('-s', '--sensor-port', default='1')%0A%0A%0Aclass MarbleSorter:%0A%0A    def __init__(self, motor_port, sensor_port):%0A        self.motor = MediumMotor(motor_port)%0A        self.sensor = ColorSensor(sensor_port)%0A%0A    def __enter__(self):%0A        return self%0A%0A    def __exit__(self, exc_type, exc_value, traceback):%0A        self.motor.stop()%0A        self.motor.reset()%0A%0A    def eject(self, speed=0.3):%0A        self.motor.stop()%0A        self.motor.reset()%0A        self.motor.stop_action = self.motor.STOP_ACTION_HOLD%0A        self.motor.position_sp = -120%0A        self.motor.speed_sp = int(speed * self.motor.max_speed)%0A        self.motor.run_to_rel_pos()%0A        self.motor.wait_until('holding', timeout=2000)%0A%0A    def run_motor(self, speed=0.3):%0A        self.motor.reset()%0A        self.motor.speed_sp = int(speed * self.motor.max_speed)%0A        self.motor.run_forever()%0A%0A    def stop(self):%0A        self.motor.stop()%0A%0A%0Adef main():%0A%0A    args = parser.parse_args()%0A%0A    print('Starting')%0A    with MarbleSorter(args.motor_port, args.sensor_port) as sorter:%0A%0A        while True:%0A            sorter.eject()%0A            sorter.run_motor()%0A            time.sleep(5)%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Add first marble_sort version