示例#1
0
    def __init__(self, language='en'):
        try:
            conn = DebugServerConnection()
        except BaseException:
            logging.debug("Failed to use debug server: %s",
                          traceback.format_exc())
            conn = BLEConnection().connect()

        super(Vernie, self).__init__(conn)
        self.language = language

        while True:
            required_devices = (self.color_distance_sensor,
                                self.motor_external)
            if None not in required_devices:
                break
            log.debug("Waiting for required devices to appear: %s",
                      required_devices)
            time.sleep(1)

        self._head_position = 0
        self.motor_external.subscribe(self._external_motor_data)

        self._reset_head()
        self.say("ready")
        time.sleep(1)
示例#2
0
文件: __init__.py 项目: zsc/pylgbst
        logging.debug("%s", [COLORS[x[0]] if x else None for x in self.queue])

        last = self.queue.pop(0)
        if last:
            self.move_to_bucket(last[0])
            res = True

        self.feed()
        return res


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)

    try:
        conn = DebugServerConnection()
    except BaseException:
        logging.warning("Failed to use debug server: %s", traceback.format_exc())
        conn = get_connection_auto()

    sorter = ColorSorter(conn)
    empty = 0
    try:
        while True:
            empty += 1
            if sorter.tick():
                empty = 0
            elif empty > 20:
                break

    finally:
示例#3
0
    movehub.voltage.unsubscribe(callback2)


def demo_all(movehub):
    demo_voltage(movehub)
    demo_led_colors(movehub)
    demo_motors_timed(movehub)
    demo_motors_angled(movehub)
    demo_port_cd_motor(movehub)
    demo_tilt_sensor_simple(movehub)
    demo_tilt_sensor_precise(movehub)
    demo_color_sensor(movehub)
    demo_motor_sensors(movehub)


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)

    try:
        connection = DebugServerConnection()
    except BaseException:
        logging.debug("Failed to use debug server: %s", traceback.format_exc())
        connection = get_connection_auto()

    try:
        hub = MoveHub(connection)
        sleep(1)
        # demo_all(hub)
    finally:
        connection.disconnect()