As python newbee i will try to describe my situation as best as i can
In fact, it's not so complicated but like i wrote am still learning.
Device function:
- doorbell intercom
Scenario:
- User presses tactile button
- sound is played
- read the value from external javascript ( extrabacon is installed for that purposes )
---> if user has answered
--------> send hasAnswered from JS to this python script
-------> starting javascript file for voip communication
-------> when the communication is done --> JS sends hangup value
- wait for nest button press
---> if user has NOT answered
-------> take picture
-------> delay for writing picture to file ( 3 sec )
-------> email with attached picture is send to owner
DONE
This is just ultra simple test code without JS part:
Code: Select all
import RPi.GPIO as GPIO
import subprocess
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.IN)
state = 0
while True:
input = GPIO.input(40)
if (input == False):
if (state == 1):
state = 0
# player.stdin.write("q")
elif (state == 0):
subprocess.Popen(["aplay", "DoorBell.wav"]);
# chech for call state
# if not accepted
subprocess.Popen(["fswebcam","-r 640x480", "testPic.jpg"]);
# delay
subprocess.call(["python", "sender.py"])
#-----------------------------------------
state = 1I need to reorganize the code so i can set the countdown and delay time, and exit the loop when the button was pressed.
Basically, main part is to detect this button press and according to that, make some action.
Any suggestion is welcome !
PIN