Bläddra i källkod

Merge branch 'master' of github.com:profplump/UberZach-Integration

Zachary Kotlarek 10 år sedan
förälder
incheckning
0342360431
1 ändrade filer med 15 tillägg och 4 borttagningar
  1. 15 4
      dmx/HDMIctrl.pl

+ 15 - 4
dmx/HDMIctrl.pl

@@ -22,6 +22,8 @@ my $PUSH_TIMEOUT = 20;
 my $PULL_TIMEOUT = $PUSH_TIMEOUT * 3;
 my $PULL_TIMEOUT = $PUSH_TIMEOUT * 3;
 my $DELAY        = $PULL_TIMEOUT / 2;
 my $DELAY        = $PULL_TIMEOUT / 2;
 my $CMD_DELAY    = 5.0;
 my $CMD_DELAY    = 5.0;
+my $BOOT_DELAY   = 10;
+my $BOOT_TIMEOUT = $BOOT_DELAY * 3;
 
 
 # Debug
 # Debug
 my $DEBUG = 0;
 my $DEBUG = 0;
@@ -42,9 +44,7 @@ my %exists    = ();
 my $pushLast  = 0;
 my $pushLast  = 0;
 my $pullLast  = time();
 my $pullLast  = time();
 my $update    = 0;
 my $update    = 0;
-my $lastMode  = 0;
-my $lastInput = 0;
-my $lastPower = 0;
+my $lastBoot  = 0;
 
 
 # Loop forever
 # Loop forever
 while (1) {
 while (1) {
@@ -119,6 +119,17 @@ while (1) {
 			print STDERR 'State: ' . $state . "\n";
 			print STDERR 'State: ' . $state . "\n";
 		}
 		}
 
 
+		# Reboot before the first update to GAME
+		if ($state eq 'GAME' && $lastBoot < $now - $BOOT_TIMEOUT) {
+			$hdmi->send('REBOOT')
+			  or die('Unable to write command to HDMI socket: ' . $state . ": ${!}\n");
+
+			# Wait for the reboot
+			sleep($BOOT_DELAY);
+			$now += $BOOT_DELAY;
+			$lastBoot = $now;
+		}
+
 		# Send master power state
 		# Send master power state
 		$hdmi->send($state)
 		$hdmi->send($state)
 		  or die('Unable to write command to HDMI socket: ' . $state . ": ${!}\n");
 		  or die('Unable to write command to HDMI socket: ' . $state . ": ${!}\n");
@@ -127,7 +138,7 @@ while (1) {
 		#DMX::say('Aitch-Dee-Em-I input' . lc($state));
 		#DMX::say('Aitch-Dee-Em-I input' . lc($state));
 
 
 		# Update the push time
 		# Update the push time
-		$pushLast = time();
+		$pushLast = $now;
 
 
 		# Clear the update flag
 		# Clear the update flag
 		$update = 0;
 		$update = 0;