Skip to content

Commit

Permalink
treehouses camera refactor (fixes #2061) (#2064)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
JLKwong and dogi authored Mar 6, 2021
1 parent 51beb4b commit b1927c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions modules/camera.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ function camera {
if ! grep -q "start_x=1" ${config} ; then
log_and_exit1 "Error: you need to enable AND reboot first in order to take pictures."
fi
case "$2" in
case "$2" in
"")
echo "Camera is recording ${length} seconds of video and storing a time-stamped ${vidtype} video in ${viddir}."
let length=$length*1000
raspivid -o "${viddir}$BASENAME-${timestamp}.h264" -t "${length}" && echo "Success: Video captured" && echo "Converting video to ${vidtype}"
convert ${viddir}$BASENAME-${timestamp}.h264 ${viddir}$BASENAME-${timestamp}.${vidtype}
rm ${viddir}$BASENAME-${timestamp}.h264
;;
;;

*)
if ! [[ "$2" =~ ^[1-9][0-9]*$ ]] ; then #^[0-9]+$ to accept 0 for indefinite recording
log_and_exit1 "Error: positive integers only."
else
else
echo "Camera is recording ${2} seconds of video and storing a time-stamped ${vidtype} video in ${viddir}."
let length=$2*1000
raspivid -o "${viddir}$BASENAME-${timestamp}.h264" -t "${length}" && echo "Success: Video captured" && echo "Converting video to ${vidtype}"
Expand All @@ -82,7 +82,7 @@ function camera {
;;
esac
;;

"detect")
mkdir -p ${directory}
if ! grep -q "start_x=1" ${config} ; then
Expand Down Expand Up @@ -113,7 +113,8 @@ function camera {
fi
;;

"*")
*)
echo "Error: The only supported options are 'on', 'off', 'detect, 'capture', and 'record'."
camera_help
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@treehouses/cli",
"version": "1.25.12",
"version": "1.25.13",
"remote": "4000",
"description": "Thin command-line interface for Raspberry Pi low level configuration.",
"main": "cli.sh",
Expand Down

0 comments on commit b1927c4

Please sign in to comment.