Beispiel #1
0
def runAutoMode():
    print "\nAuto Mode Running..."
    setCurrentAction('off')
    global check_stream
    global check_door
    roomState = readingRoomSensor()

    if roomState == True:
        insert_motion()
        take_pic()

    doorState = readingDoorSensor()

    if doorState == True:
        if check_door == 0:
            insert_door()
            print "Email sending.."
            email('*****@*****.**')
            print "Email sent"
            print "Check stream..."
            stream()
            check_door = 1
        elif check_stream == 0:
            stream()
        else:
            pass
    else:
        kill_stream()
        setCurrentAction('off')
        check_stream = 0
        check_door = 0
Beispiel #2
0
def runManualMode():
    global check_stream
    print "\nManual Mode Running..."
    currentAction = getCurrentAction()

    if currentAction == 'snap':
        take_pic()
        print 'Snapshot Saved'
        #setCurrentAction('off')
        #check_stream =0

    elif currentAction == 'vid':
        print "Recording"
        take_vid(5)
        print 'Video Recorded for 5 seconds'
        #setCurrentAction('off')
        #check_stream =0

    elif currentAction == 'stream':
        print "Streaming"
        stream()
        #setCurrentAction('off')

    elif currentAction == 'off':
        print "Waiting for user"
        kill_stream()
        check_stream = 0
Beispiel #3
0
def take_pic():
    global check_stream
    kill_stream()
    check_stream = 0
    setCurrentAction('off')
    time.sleep(0.5)
    camera = PiCamera()
    camera.capture('/home/pi/scc/myapp/static/myapp/pic.jpg')
    print "Snapshot Saved"
    camera.close()
Beispiel #4
0
def take_vid(time_to_record):
    kill_stream()
    check_stream = 0
    setCurrentAction('off')
    time.sleep(0.5)
    camera = PiCamera()
    camera.start_recording('my_video.h264')
    camera.wait_recording(time_to_record)
    camera.stop_recording()
    print "Recording Saved"
    camera.close()
Beispiel #5
0
            check_door = 1
        elif check_stream == 0:
            stream()
        else:
            pass
    else:
        kill_stream()
        setCurrentAction('off')
        check_stream = 0
        check_door = 0


# Controller main function
def runController():
    currentMode = getCurrentMode()
    if currentMode == 'auto':
        runAutoMode()
    elif currentMode == 'manual':
        runManualMode()
    return True


while True:
    try:
        runController()
        time.sleep(1)
    except KeyboardInterrupt:
        GPIO.cleanup()
        kill_stream()
        exit()