diff --git a/README.md b/README.md index e03ae996..5c8cf423 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ Web based interface for controlling the Raspberry Pi Camera, includes motion detection, time lapse, and image and video recording. -Current version 6.0.11 +Current version 6.0.12 All information on this project can be found here: http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=63276 The wiki page can be found here: diff --git a/www/config.php b/www/config.php index 2f7cf360..90452770 100755 --- a/www/config.php +++ b/www/config.php @@ -3,7 +3,7 @@ define('LBASE_DIR',dirname(__FILE__)); //Global defines and utility functions // version string - define('APP_VERSION', 'v6.0.11'); + define('APP_VERSION', 'v6.0.12'); // name of this application define('APP_NAME', 'RPi Cam Control'); diff --git a/www/schedule.php b/www/schedule.php index 8e2a73ad..efab536d 100644 --- a/www/schedule.php +++ b/www/schedule.php @@ -51,6 +51,7 @@ define('SCHEDULE_PURGESPACEMODE', 'PurgeSpace_ModeEx'); define('SCHEDULE_PURGESPACELEVEL', 'PurgeSpace_Level'); define('SCHEDULE_AUTOCAPTUREINTERVAL', 'AutoCapture_Interval'); + define('SCHEDULE_AUTOCAMERAINTERVAL', 'AutoCamera_Interval'); define('SCHEDULE_COMMANDSON', 'Commands_On'); define('SCHEDULE_COMMANDSOFF', 'Commands_Off'); define('SCHEDULE_MODES', 'Modes'); @@ -191,6 +192,7 @@ function initPars() { SCHEDULE_MAXCAPTURE => '0', SCHEDULE_DAYMODE => '1', SCHEDULE_AUTOCAPTUREINTERVAL => '0', + SCHEDULE_AUTOCAMERAINTERVAL => '0', SCHEDULE_TIMES => array("09:00","10:00","11:00","12:00","13:00","14:00"), SCHEDULE_COMMANDSON => array("ca 1","","","ca 1","","","","","","",""), SCHEDULE_COMMANDSOFF => array("ca 0","","","ca 0","","","","","","",""), @@ -645,6 +647,7 @@ function mainCLI() { $pollTime = $schedulePars[SCHEDULE_CMDPOLL]; $slowPoll = 0; $managechecktime = time(); + $autocameratime =$managechecktime; $modechecktime = $managechecktime; if ($schedulePars[SCHEDULE_AUTOCAPTUREINTERVAL] > $schedulePars[SCHEDULE_MAXCAPTURE] ) { $autocapturetime = $managechecktime; @@ -653,7 +656,7 @@ function mainCLI() { $autocapturetime = 0; $autocapture = 0; } - + $lastStatusTime = filemtime(BASE_DIR . "/status_mjpeg.txt"); while($timeoutMax == 0 || $timeout < $timeoutMax) { usleep($pollTime * 1000000); //Check for incoming motion capture requests @@ -745,6 +748,27 @@ function mainCLI() { writeLog("Autocapture request."); $autocapture = 1; } + //Check for auto camera on/off based on status update timing (active browser) + if (($schedulePars[SCHEDULE_AUTOCAMERAINTERVAL] > 0) && $timenow > $autocameratime) { + // 2 seconds between tests to allow time for commands to take effect + $autocameratime = $timenow + 2; + clearstatcache(); + $modTime = filemtime(BASE_DIR . "/status_mjpeg.txt"); + if (file_get_contents(BASE_DIR . "/status_mjpeg.txt") == 'halted') { + if ($modTime > $lastStatusTime) { + writeLog("autocamera startup"); + sendCmds('ru 1'); + } + } else { + if (($timenow - $modTime) > $schedulePars[SCHEDULE_AUTOCAMERAINTERVAL]) { + writeLog("autocamera shutdown"); + sendCmds('md 0;ru 0'); + $lastStatusTime = $timenow + $schedulePars[SCHEDULE_AUTOCAMERAINTERVAL]; + } else { + $lastStatusTime = $timenow; + } + } + } } } } diff --git a/www/status_mjpeg.php b/www/status_mjpeg.php index 400d1903..785824b8 100644 --- a/www/status_mjpeg.php +++ b/www/status_mjpeg.php @@ -7,6 +7,7 @@ if($file_content != $_GET["last"]) break; usleep(100000); } + touch("status_mjpeg.txt"); echo $file_content; ?>