Selaa lähdekoodia

Try to keep the input mode set correctly. We cannot read it (for whatever reason) so just set it on every change.

Zachary Kotlarek 13 vuotta sitten
vanhempi
sitoutus
237172ca43
2 muutettua tiedostoa jossa 42 lisäystä ja 23 poistoa
  1. 21 6
      dmx/amplifierPower.pl
  2. 21 17
      serial/serial.pl

+ 21 - 6
dmx/amplifierPower.pl

@@ -9,6 +9,9 @@ use File::Basename qw(dirname);
 use lib dirname(abs_path($0));
 use lib dirname(abs_path($0));
 use DMX;
 use DMX;
 
 
+# Prototypes
+sub sendCmd($$);
+
 # App config
 # App config
 my $DATA_DIR     = DMX::dataDir();
 my $DATA_DIR     = DMX::dataDir();
 my $STATE_SOCK   = 'AMPLIFIER_POWER';
 my $STATE_SOCK   = 'AMPLIFIER_POWER';
@@ -109,9 +112,8 @@ while (1) {
 		if ($DEBUG) {
 		if ($DEBUG) {
 			print STDERR 'Setting mode to: ' . $mode . "\n";
 			print STDERR 'Setting mode to: ' . $mode . "\n";
 		}
 		}
-		$amp->send($mode)
-		  or die('Unable to write command to amp socket: ' . $mode . ": ${!}\n");
 		DMX::say('Amplifier: ' . $mode);
 		DMX::say('Amplifier: ' . $mode);
+		sendCmd($amp, $mode);
 	}
 	}
 
 
 	# Set the amplifier input as needed
 	# Set the amplifier input as needed
@@ -119,9 +121,8 @@ while (1) {
 		if ($DEBUG) {
 		if ($DEBUG) {
 			print STDERR 'Setting input to: ' . $input . "\n";
 			print STDERR 'Setting input to: ' . $input . "\n";
 		}
 		}
-		$amp->send($input)
-		  or die('Unable to write command to amp socket: ' . $input . ": ${!}\n");
 		DMX::say('Amplifier: ' . $input);
 		DMX::say('Amplifier: ' . $input);
+		sendCmd($amp, $input);
 	}
 	}
 
 
 	# Update the amp
 	# Update the amp
@@ -140,8 +141,7 @@ while (1) {
 			$cmd = 'ON';
 			$cmd = 'ON';
 		}
 		}
 		if (defined($cmd)) {
 		if (defined($cmd)) {
-			$amp->send($cmd)
-			  or die('Unable to write command to amp socket: ' . $cmd . ": ${!}\n");
+			sendCmd($amp, $cmd);
 		}
 		}
 
 
 		# No output file
 		# No output file
@@ -153,3 +153,18 @@ while (1) {
 		$update = 0;
 		$update = 0;
 	}
 	}
 }
 }
+
+sub sendCmd($$) {
+	my ($amp, $cmd) = @_;
+
+	# Send the command
+	$amp->send($cmd)
+	  or die('Unable to write command to amp socket: ' . $cmd . ": ${!}\n");
+	sleep(1);
+
+	# Always reset the input mode
+	$cmd = 'INPUT_AUTO';
+	$amp->send($cmd)
+	  or die('Unable to write command to amp socket: ' . $cmd . ": ${!}\n");
+	sleep(1);
+}

+ 21 - 17
serial/serial.pl

@@ -60,23 +60,27 @@ if (basename($0) =~ /PROJECTOR/i) {
 	$CRLF      = "\r";
 	$CRLF      = "\r";
 	$DELIMITER = "\r";
 	$DELIMITER = "\r";
 	%CMDS      = (
 	%CMDS      = (
-		'INIT'     => '',
-		'ON'       => 'PWON',
-		'OFF'      => 'PWSTANDBY',
-		'STATUS'   => 'PW?',
-		'VOL'      => 'MV?',
-		'VOL+'     => 'MVUP',
-		'VOL-'     => 'MVDOWN',
-		'MUTE'     => 'MUON',
-		'UNMUTE'   => 'MUOFF',
-		'INPUT'    => 'SI?',
-		'TV'       => 'SITV',
-		'DVD'      => 'SIDVD',
-		'MODE'     => 'MS?',
-		'SURROUND' => 'MSDOLBY DIGITAL',
-		'STEREO'   => 'MS7CH STEREO',
-		'TV'       => 'SITV',
-		'INPUT'    => 'SI?',
+		'INIT'         => '',
+		'ON'           => 'PWON',
+		'OFF'          => 'PWSTANDBY',
+		'STATUS'       => 'PW?',
+		'VOL'          => 'MV?',
+		'VOL+'         => 'MVUP',
+		'VOL-'         => 'MVDOWN',
+		'MUTE'         => 'MUON',
+		'UNMUTE'       => 'MUOFF',
+		'INPUT'        => 'SI?',
+		'TV'           => 'SITV',
+		'DVD'          => 'SIDVD',
+		'MODE'         => 'MS?',
+		'SURROUND'     => 'MSDOLBY DIGITAL',
+		'STEREO'       => 'MS7CH STEREO',
+		'TV'           => 'SITV',
+		'INPUT'        => 'SI?',
+		'INPUT_MODE'   => 'SD?',
+		'INPUT_AUTO'   => 'SDAUTO',
+		'INPUT_ANALOG' => 'SDANALOG',
+		'INPUT_EXT'    => 'SDEXT.IN-1',
 
 
 	);
 	);
 	%STATUS_CMDS = (
 	%STATUS_CMDS = (