コード例 #1
0
        print("continue_program", continue_program)


def record_video():
    global started_video
    global last_video_pic
    global recent_ended_video
    if os.path.isfile(last_video_pic):
        os.remove(last_video_pic)
    if started_video:
        cam.stop_recording()
        started_video = False
        recent_ended_video = True
        print("stopped video. started_video=", started_video)
    else:
        cam.start_recording('/home/pi/Videos/video_' +
                            time.strftime("%Y-%m-%d_%H-%M-%S") + '.h264')
        started_video = True
        print("started video. started_video=", started_video)


bd = BlueDot()
cam = PiCamera()
cam.start_preview()
started_video = False
last_video_pic = ''
recent_ended_video = False
bd.when_double_pressed = record_video
bd.set_when_pressed(take_picture, background=True)
bd.when_swiped = stop_program
コード例 #2
0
from bluedot import BlueDot
from time import sleep
from signal import pause
bd = BlueDot()


def pressed():
    print("pressed - waiting")
    sleep(3)
    print("pressed - complete")


def released():
    print("released")


bd.set_when_pressed(pressed, background=True)
bd.when_released = released

pause()
コード例 #3
0

# Function to stop the motor
# Will stop all motors as soon as there is not input detected from the Blue Dot
def stop():
    robot.control(1500)


# Function to toggle between power on and power off
# Double tap to toggle between the power states
# Power on: Button will be blue
# Power off: Button will be red
def power_button():
    global running
    running = not running
    if running:
        bd.color = 'blue'
    else:
        bd.color = 'red'


# Allows pairing of other devices for a minute after startup
bd.allow_pairing(60)

bd.set_when_pressed(move)
bd.set_when_moved(move)
bd.set_when_released(stop)
bd.set_when_double_press(power_button)

pause()