gpio setup and methods to control document camera light

workspace
Brendan Howell 8 years ago
parent 5d945f8e19
commit 3de427b4eb

@ -1,6 +1,8 @@
import subprocess import subprocess
import tempfile import tempfile
from pyA20.gpio import gpio, port
from bureau import Bureau, add_api from bureau import Bureau, add_api
@ -13,19 +15,35 @@ class Photography(Bureau):
name = "Photography Dept." name = "Photography Dept."
prefix = "PX" prefix = "PX"
version = 0 version = 0
doc_light_pin = port.PG0
def __init__(self): def __init__(self):
Bureau.__init__(self) Bureau.__init__(self)
# set up the gpios for lamp & knobs
gpio.init()
gpio.pullup(doc_light_pin, 0) # reset pullup state
gpio.pullup(doc_light_pin, gpio.PULLDOWN)
def _doc_light_on(self):
gpio.output(self.doc_light_pin, gpio.HIGH)
def _doc_light_off(self):
gpio.output(self.doc_light_pin, gpio.LOW)
@add_api("photo", "Get Document Photo") @add_api("photo", "Get Document Photo")
def photo(self): def photo(self):
""" """
Takes a photograph using the document camera. Returns Takes a photograph using the document camera. Returns
the file name. the file name.
""" """
self._doc_light_on()
tmpimg = tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) tmpimg = tempfile.NamedTemporaryFile(suffix=".jpg", delete=False)
tmpimg.close() tmpimg.close()
# TODO: make more reliable
# TODO: make resolution config variable
# this is a dirty hack to keep the webcam system calls from hanging # this is a dirty hack to keep the webcam system calls from hanging
#cmd1 = "fswebcam --jpeg 95 --no-banner --resolution 320x240 /dev/null" #cmd1 = "fswebcam --jpeg 95 --no-banner --resolution 320x240 /dev/null"
#cmd2 = "fswebcam --jpeg 95 --no-banner --resolution 1920x1080 " #cmd2 = "fswebcam --jpeg 95 --no-banner --resolution 1920x1080 "
@ -34,6 +52,7 @@ class Photography(Bureau):
cmd2 = "uvccapture -d/dev/video1 -D2 -m -x3264 -y2448 -o" + tmpimg.name cmd2 = "uvccapture -d/dev/video1 -D2 -m -x3264 -y2448 -o" + tmpimg.name
#subprocess.check_output(cmd1.split()) #subprocess.check_output(cmd1.split())
subprocess.check_output(cmd2.split()) subprocess.check_output(cmd2.split())
self._doc_light_off()
return {"photo": tmpimg.name} return {"photo": tmpimg.name}

Loading…
Cancel
Save