Browse Source

Check the change time of the projector file, in addition to the state. This avoid situations where the projector is powered down immediately after power-up due to Plex timeout.

Zachary Kotlarek 14 years ago
parent
commit
8c3722a870
1 changed files with 9 additions and 4 deletions
  1. 9 4
      projector/projectorPower.pl

+ 9 - 4
projector/projectorPower.pl

@@ -48,21 +48,21 @@ while (1) {
 
 	# Monitor the GUI and PLAYING files for changes only
 	{
-		my $mtime = mtime($DATA_DIR . '/PLAYING');
+		my $mtime = mtime($DATA_DIR . 'PLAYING');
 		if ($mtime > $updateLast) {
 			$updateLast = $mtime;
 		}
-		$mtime = mtime($DATA_DIR . '/GUI');
+		$mtime = mtime($DATA_DIR . 'GUI');
 		if ($mtime > $updateLast) {
 			$updateLast = $mtime;
 		}
 	}
 
-	# Monitor the PROJECTOR file for state only
+	# Monitor the PROJECTOR file for state and changes
 	{
 		$projector = 0;
 		my $fh;
-		open($fh, $DATA_DIR . '/PROJECTOR')
+		open($fh, $DATA_DIR . 'PROJECTOR')
 		  or die("Unable to open PROJECTOR\n");
 		my $text = <$fh>;
 		close($fh);
@@ -72,6 +72,11 @@ while (1) {
 		if ($DEBUG) {
 			print STDERR 'Projector: ' . $projector . "\n";
 		}
+
+		$mtime = mtime($DATA_DIR . 'PROJECTOR');
+		if ($mtime > $updateLast) {
+			$updateLast = $mtime;
+		}
 	}
 
 	# Calculate the new state