Explorar o código

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

Zachary Kotlarek %!s(int64=13) %!d(string=hai) anos
pai
achega
237172ca43
Modificáronse 2 ficheiros con 42 adicións e 23 borrados
  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 DMX;
 
+# Prototypes
+sub sendCmd($$);
+
 # App config
 my $DATA_DIR     = DMX::dataDir();
 my $STATE_SOCK   = 'AMPLIFIER_POWER';
@@ -109,9 +112,8 @@ while (1) {
 		if ($DEBUG) {
 			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);
+		sendCmd($amp, $mode);
 	}
 
 	# Set the amplifier input as needed
@@ -119,9 +121,8 @@ while (1) {
 		if ($DEBUG) {
 			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);
+		sendCmd($amp, $input);
 	}
 
 	# Update the amp
@@ -140,8 +141,7 @@ while (1) {
 			$cmd = 'ON';
 		}
 		if (defined($cmd)) {
-			$amp->send($cmd)
-			  or die('Unable to write command to amp socket: ' . $cmd . ": ${!}\n");
+			sendCmd($amp, $cmd);
 		}
 
 		# No output file
@@ -153,3 +153,18 @@ while (1) {
 		$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";
 	$DELIMITER = "\r";
 	%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 = (