slitaz-arm view rpi/cgi-adm/plugins/rpi_cam/rpi_cam.cgi @ rev 138

cgi-adm: move time setiing to core and misc fixes
author Christophe Lincoln <pankso@slitaz.org>
date Sat Apr 26 12:06:42 2014 +0200 (2014-04-26)
parents 32e4a7121e8f
children fae61a8c31e0
line source
1 #!/bin/sh
2 #
3 # TazBerry CGI Plugin - Raspberry Pi Camera tools web interface
4 #
6 case " $(GET) " in
8 *\ rpi_cam\ *)
9 html_header "PiCam"
10 export PATH="/opt/vc/bin:/bin:/usr/bin"
11 export LD_LIBRARY_PATH="/opt/vc/lib"
12 camdir="/var/www/adm/cam"
13 mkdir -p ${camdir}
15 # CSS --> style.css
16 cat << EOT
17 <style type="text/css">
18 img { margin: 10px 0; }
19 </style>
20 EOT
21 # We need VC Tools
22 if [ ! -x "/opt/vc/bin/raspistill" ]; then
23 echo "<div id='error'>VideoCore tools are missing. \
24 Please use tazberry to setup your PiCam/NoIR</div>"
25 html_footer && exit 0
26 fi
28 # raspivid + raspistill
29 case " $(GET rpi_cam) " in
30 *\ shot\ *)
31 opts="$(GET options)"
32 notify "Executing: raspistill $opts"
33 echo "$opts" > ${camdir}/shot.opts
34 raspistill ${opts} -o ${camdir}/shot.jpg
35 notify hide ;;
36 *\ rm_shot\ *)
37 rm -f ${camdir}/shot.jpg ;;
38 esac
40 # Get last used options
41 if [ -f "${camdir}/shot.opts" ]; then
42 shot_opts="$(cat ${camdir}/shot.opts)"
43 else
44 shot_opts="--width 480 --height 320"
45 fi
47 cat << EOT
48 <h1>Raspberry Pi Camera</h1>
50 <div id="actions">
51 <form method="get" action="$script">
52 <input type="hidden" name="rpi_cam" value="shot" />
53 <input type="submit" name="raspistill" value="Take a picture" />
54 <input type="text" name="options" value="$shot_opts" />
55 </form>
56 </div>
58 EOT
59 # Display last shot
60 if [ -f "${camdir}/shot.jpg" ]; then
61 cat << EOT
62 <h2>Latest shot</h2>
63 <div class='center'>
64 <a href="/adm/cam/shot.jpg"><img src='/adm/cam/shot.jpg' /></a>
65 <p><a href="$script?rpi_cam=rm_shot">Remove</a></p>
66 </div>
68 EOT
69 fi
70 html_footer && exit 0 ;;
71 esac