示例#1
0
文件: robot5.py 项目: crazyonej/Robot
try:
    while True:
        if (Killing == False):
            if (GPIO.input(AutoMode) == False):
                tf = 5
                distance()
                MoveForward(tf)
            else:
                bd = BlueDot()
                bd.when_pressed = dpad
                bd.when_moved = dpad
                bd.when_released = stop
                #bd.when_double_pressed = quit
                bd.when_client_connects = BDConnect
                bd.when_client_disconnects = BDDisConnect
                bd.wait_for_connection = BDDisConnect

                pause()

        if (GPIO.input(KillSwitch) == False):
            if (Killing == True):
                print("KillSwitch-", Killing)
                Killing = False
                time.sleep(1.0)
            else:
                print("KillStop-", Killing)
                Killing = True
                stop()
                time.sleep(1.0)

finally:
示例#2
0
dot = BlueDot(auto_start_server=False)


def pressed(pos):
    print(
        "Pressed: x={} y={} angle={} distance={} middle={} top={} bottom={} left={} right={} time={}"
        .format(pos.x, pos.y, pos.angle, pos.distance, pos.middle, pos.top,
                pos.bottom, pos.left, pos.right, time()))


def released():
    print("Released: x={} y={}".format(dot.position.x, dot.position.y))


def moved(pos):
    print("Moved: x={} y={}".format(pos.x, pos.y))


dot.when_pressed = pressed
dot.when_released = released
dot.when_moved = moved
dot.start()
dot.wait_for_connection()

try:
    while True:
        sleep(0.1)
finally:
    dot.stop()