#!/bin/bash

max-lcd-backlight

if test "$1" = start -o "$1" = on; then
    shift
    (
	fb2bmp /data/lcd.bmp>/dev/null 2>&1 &
        if ! flock -n 9; then
	    die "Can not test 2 cameras at the same time"
	fi

	if test $# == 0; then
            tcmd-camera-preview "$@">/dev/null 2>&1 &
	elif test $# -gt 1; then
	    die "Error: Usage $(basename $0) on/off [/dev/videoN]"
	fi
            tcmd-camera-preview -d /dev/video"$@">/dev/null 2>&1 &
    ) 9> /data/camera-preview.lock
else    
    bmp2fb /data/lcd.bmp>/dev/null 2>&1 &    
    killall tcmd-camera-preview
    rm /data/lcd.bmp>/dev/null 2>&1 &
fi

#ask-result Can you see the camera preview on LCD?
