slitaz-arm rev 136

rpi: add Camera support in CG admin interface :-)
author Christophe Lincoln <pankso@slitaz.org>
date Sat Apr 26 10:43:15 2014 +0200 (2014-04-26)
parents c10b9b20b9a5
children 8d2fe01fe16f
files rpi/cgi-adm/plugins/rpi_cam/rpi_cam.cgi rpi/cgi-adm/plugins/rpi_cam/rpi_cam.conf
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rpi/cgi-adm/plugins/rpi_cam/rpi_cam.cgi	Sat Apr 26 10:43:15 2014 +0200
     1.3 @@ -0,0 +1,69 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# TazBerry CGI Plugin - Raspberry Pi Camera tools web interface
     1.7 +#
     1.8 +
     1.9 +case " $(GET) " in
    1.10 +
    1.11 +	*\ rpi_cam\ *)
    1.12 +		html_header "PiCam"
    1.13 +		export PATH="/opt/vc/bin:/bin:/usr/bin"
    1.14 +		export LD_LIBRARY_PATH="/opt/vc/lib"
    1.15 +		camdir="/var/www/adm/cam"
    1.16 +		mkdir -p ${camdir}
    1.17 +		
    1.18 +		# CSS --> style.css
    1.19 +		cat << EOT
    1.20 +<style type="text/css">
    1.21 +	img { margin: 10px 0; }
    1.22 +</style>
    1.23 +EOT
    1.24 +		# Wen need VC Tools
    1.25 +		if [ ! -x "/opt/vc/bin/raspivid" ]; then
    1.26 +			echo "<p>VideoCore tools are missing. Please use tazberry \
    1.27 +				to setup the PiCam/NoIR</p>" && exit 0
    1.28 +		fi
    1.29 +		
    1.30 +		# raspivid + raspistill
    1.31 +		case " $(GET rpi_cam) " in
    1.32 +			*\ shot\ *)
    1.33 +				notify "Executing raspistill..."
    1.34 +				echo "$(GET options)" > ${camdir}/shot.opts
    1.35 +				raspistill $(GET options) -o ${camdir}/shot.jpg 
    1.36 +				notify hide ;;
    1.37 +			*\ rm_shot\ *)
    1.38 +				rm -f ${camdir}/shot.jpg ;;
    1.39 +		esac
    1.40 +		
    1.41 +		# Get last used options
    1.42 +		if [ -f "${camdir}/shot.opts" ]; then
    1.43 +			shot_opts="$(cat ${camdir}/shot.opts)"
    1.44 +		else
    1.45 +			shot_opts="--width 480 --height 320"
    1.46 +		fi
    1.47 +		
    1.48 +		cat << EOT
    1.49 +<h1>Raspberry Pi Camera</h1>
    1.50 +
    1.51 +<div id="actions">
    1.52 +	<form method="get" action="$script">
    1.53 +		<input type="hidden" name="rpi_cam" value="shot" />
    1.54 +		<input type="submit" name="raspistill" value="Take a picture" />
    1.55 +		<input type="text" name="options" value="$shot_opts" />
    1.56 +	</form>
    1.57 +</div>
    1.58 +
    1.59 +EOT
    1.60 +		# Display last shot
    1.61 +		if [ -f "${camdir}/shot.jpg" ]; then
    1.62 +			cat << EOT
    1.63 +<h2>Latest shot</h2>
    1.64 +<div class='center'>
    1.65 +	<a href="/adm/cam/shot.jpg"><img src='/adm/cam/shot.jpg' /></a>
    1.66 +	<p><a href="$script?rpi_cam=rm_shot">Remove</a></p>
    1.67 +</div>
    1.68 +
    1.69 +EOT
    1.70 +		fi
    1.71 +		html_footer && exit 0 ;;
    1.72 +esac
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/rpi/cgi-adm/plugins/rpi_cam/rpi_cam.conf	Sat Apr 26 10:43:15 2014 +0200
     2.3 @@ -0,0 +1,6 @@
     2.4 +# TazBerry CGI Plugin configuration
     2.5 +
     2.6 +PLUGIN="Raspberry Pi Camera"
     2.7 +SHORT_DESC="Raspberry PiCam and NoIR management."
     2.8 +MAINTAINER="pankso@slitaz.org"
     2.9 +WEB_SITE="http://arm.slitaz.org/rpi"