Browse Source

plugin update

philippe44 5 years ago
parent
commit
93c24cbf5f

BIN
plugin/SqueezeESP32.zip


+ 116 - 78
plugin/SqueezeESP32/Graphics.pm

@@ -15,84 +15,37 @@ my $VISUALIZER_VUMETER = 1;
 my $VISUALIZER_SPECTRUM_ANALYZER = 2;
 my $VISUALIZER_WAVEFORM = 3;
 
-my $width = $prefs->get('width') || 128;
-my $spectrum_scale = $prefs->get('spectrum_scale') || 50;
-
-my @modes = (
-	# mode 0
-	{ desc => ['BLANK'],
-	  bar => 0, secs => 0,  width => $width, 
-	  params => [$VISUALIZER_NONE] },
-	# mode 1
-	{ desc => ['PROGRESS_BAR'],
-	  bar => 1, secs => 0,  width => $width,
-	  params => [$VISUALIZER_NONE] },
-	# mode 2
-	{ desc => ['ELAPSED'],
-	  bar => 0, secs => 1,  width => $width,
-	  params => [$VISUALIZER_NONE] },
-	# mode 3
-	{ desc => ['ELAPSED', 'AND', 'PROGRESS_BAR'],
-	  bar => 1, secs => 1,  width => $width, 
-	  params => [$VISUALIZER_NONE] },
-	# mode 4
-	{ desc => ['REMAINING'],
-	  bar => 0, secs => -1, width => $width,
-	  params => [$VISUALIZER_NONE] },
-	# mode 5  
-    { desc => ['CLOCK'],
-	  bar => 0, secs => 0, width => $width, clock => 1,
-	  params => [$VISUALIZER_NONE] },
-	# mode 6	  
-	{ desc => ['SETUP_SHOWBUFFERFULLNESS'],
-	  bar => 0, secs => 0,  width => $width, fullness => 1,
-	  params => [$VISUALIZER_NONE] },
-	# mode 7
-	{ desc => ['VISUALIZER_VUMETER_SMALL'],
-	  bar => 0, secs => 0,  width => $width, _width => -20,
-	  # extra parameters (width, height, col (< 0 = from right), row (< 0 = from bottom), bars, left space)
-	  params => [$VISUALIZER_VUMETER, 20, 32, -20, 0, 2] },
-	# mode 8
-	{ desc => ['VISUALIZER_SPECTRUM_ANALYZER_SMALL'],
-	  bar => 0, secs => 0,  width => $width, _width => -32,
-	  # extra parameters (width, height, col (< 0 = from right), row (< 0 = from bottom), bars, left space)
-	  params => [$VISUALIZER_SPECTRUM_ANALYZER, 32, 32, -32, 0, 2, 6, $spectrum_scale] },	  
-	# mode 9	 
-	{ desc => ['VISUALIZER_VUMETER'],
-	  bar => 0, secs => 0,  width => $width,
-	  params => [$VISUALIZER_VUMETER] },
-	# mode 10
-	{ desc => ['VISUALIZER_SPECTRUM_ANALYZER'],
-	  bar => 0, secs => 0,  width => $width,
-	  # extra parameters (bars)
-	  params => [$VISUALIZER_SPECTRUM_ANALYZER, 16, $spectrum_scale] },	  
-	# mode 11	 
-	{ desc => ['VISUALIZER_VUMETER', 'AND', 'ELAPSED'],
-	  bar => 0, secs => 1,  width => $width,
-	  params => [$VISUALIZER_VUMETER] },
-	# mode 12
-	{ desc => ['VISUALIZER_SPECTRUM_ANALYZER', 'AND', 'ELAPSED'],
-	  bar => 0, secs => 1,  width => $width,
-	  # extra parameters (bars)
-	  params => [$VISUALIZER_SPECTRUM_ANALYZER, 16, $spectrum_scale] },	  
-	# mode 13	 
-	{ desc => ['VISUALIZER_VUMETER', 'AND', 'REMAINING'],
-	  bar => 0, secs => -1,  width => $width,
-	  params => [$VISUALIZER_VUMETER] },
-	# mode 14
-	{ desc => ['VISUALIZER_SPECTRUM_ANALYZER', 'AND', 'REMAINING'],
-	  bar => 0, secs => -1,  width => $width,
-	  # extra parameters (bars)
-	  params => [$VISUALIZER_SPECTRUM_ANALYZER, 16, $spectrum_scale] },	  	  
-	  
-);
+{
+	#__PACKAGE__->mk_accessor('array', 'modes');
+	__PACKAGE__->mk_accessor('rw', 'modes');
+	__PACKAGE__->mk_accessor('rw', qw(vfdmodel));
+}
+
+use Data::Dumper;
 
+sub new {
+	my $class = shift;
+	my $client = shift;
+	
+	my $display = $class->SUPER::new($client);
+		
+	$display->init_accessor(	
+		modes => $display->build_modes,
+		vfdmodel => 'graphic-<width>x32',	# doesn't matter much
+	);	
+	
+	return $display;
+}
+
+=comment
 sub modes {
 	return \@modes;
 }
+=cut
 
 sub nmodes {
-	return $#modes;
+	# -1 for LMS bug workaround
+	return scalar(@{shift->modes}) - 1;
 }
 
 sub displayWidth {
@@ -116,12 +69,6 @@ sub displayWidth {
 	}	
 }
 
-# I don't think LMS renderer handles properly screens other than 32 pixels. It
-# seems that all we get is a 32 pixel-tall data with anything else padded to 0
-# i.e. if we try 64 pixels height, bytes 0..3 and 4..7 will contains the same 
-# pattern than the 32 pixels version, where one would have expected bytes 4..7
-# to be empty
-
 sub brightnessMap {
 	return (65535, 10, 50, 100, 200);
 }
@@ -132,12 +79,103 @@ sub bytesPerColumn {
 }
 =cut
 
+# I don't think LMS renderer handles properly screens other than 32 pixels. It
+# seems that all we get is a 32 pixel-tall data with anything else padded to 0
+# i.e. if we try 64 pixels height, bytes 0..3 and 4..7 will contains the same 
+# pattern than the 32 pixels version, where one would have expected bytes 4..7
+# to be empty
 sub displayHeight {
 	return 32;
 }
 
+=comment
 sub vfdmodel {
 	return 'graphic-'.$width.'x32';
 }
+=cut
+
+sub build_modes {
+	my $client = shift->client;
+	print("CLIENT IN BUILD MODE $client\n");
+	my $cprefs = $prefs->client($client);
+	
+	my $width = shift || $cprefs->get('width') || $prefs->get('width') || 128;
+	my $small_VU = shift || $cprefs->get('small_vu') || 0.15; 
+	my $small_spectrum = shift || $cprefs->get('small_spectrum') || 0.25;
+	my $spectrum_bar = shift ||  $cprefs->get('spectrum_bar') || { 'small' => 0.1875, 'full' => 0.125 };
+	my $spectrum_scale = shift ||  $cprefs->get('spectrum_scale') || $prefs->get('spectrum_scale') || 50;
+	
+	my @modes = (
+		# mode 0
+		{ desc => ['BLANK'],
+		bar => 0, secs => 0,  width => $width, 
+		params => [$VISUALIZER_NONE] },
+		# mode 1
+		{ desc => ['PROGRESS_BAR'],
+		bar => 1, secs => 0,  width => $width,
+		params => [$VISUALIZER_NONE] },
+		# mode 2
+		{ desc => ['ELAPSED'],
+		bar => 0, secs => 1,  width => $width,
+		params => [$VISUALIZER_NONE] },
+		# mode 3
+		{ desc => ['ELAPSED', 'AND', 'PROGRESS_BAR'],
+		bar => 1, secs => 1,  width => $width, 
+		params => [$VISUALIZER_NONE] },
+		# mode 4
+		{ desc => ['REMAINING'],
+		bar => 0, secs => -1, width => $width,
+		params => [$VISUALIZER_NONE] },
+		# mode 5  
+		{ desc => ['CLOCK'],
+		bar => 0, secs => 0, width => $width, clock => 1,
+		params => [$VISUALIZER_NONE] },
+		# mode 6	  
+		{ desc => ['SETUP_SHOWBUFFERFULLNESS'],
+		bar => 0, secs => 0,  width => $width, fullness => 1,
+		params => [$VISUALIZER_NONE] },
+		# mode 7
+		{ desc => ['VISUALIZER_VUMETER_SMALL'],
+		bar => 0, secs => 0,  width => $width, _width => int -($small_VU*$width),
+		# extra parameters (width, height, col (< 0 = from right), row (< 0 = from bottom), left_space)
+		params => [$VISUALIZER_VUMETER, int ($small_VU* $width), 32, int -($small_VU*$width), 0, 2] },
+		# mode 8
+		{ desc => ['VISUALIZER_SPECTRUM_ANALYZER_SMALL'],
+		bar => 0, secs => 0,  width => $width, _width => int -($small_spectrum*$width),
+		# extra parameters (width, height, col (< 0 = from right), row (< 0 = from bottom), left_space, bars)
+		params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($small_spectrum*$width), 32, int -($small_spectrum*$width), 0, 2, int ($small_spectrum*$width*$spectrum_bar->{small}), $spectrum_scale] },	  
+		# mode 9	 
+		{ desc => ['VISUALIZER_VUMETER'],
+		bar => 0, secs => 0,  width => $width,
+		params => [$VISUALIZER_VUMETER] },
+		# mode 10
+		{ desc => ['VISUALIZER_SPECTRUM_ANALYZER'],
+		bar => 0, secs => 0,  width => $width,
+		# extra parameters (bars)
+		params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width * $spectrum_bar->{full}), $spectrum_scale] },	  
+		# mode 11	 
+		{ desc => ['VISUALIZER_VUMETER', 'AND', 'ELAPSED'],
+		bar => 0, secs => 1,  width => $width,
+		params => [$VISUALIZER_VUMETER] },
+		# mode 12
+		{ desc => ['VISUALIZER_SPECTRUM_ANALYZER', 'AND', 'ELAPSED'],
+		bar => 0, secs => 1,  width => $width,
+		# extra parameters (bars)
+		params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width * $spectrum_bar->{full}), $spectrum_scale] },	  
+		# mode 13	 
+		{ desc => ['VISUALIZER_VUMETER', 'AND', 'REMAINING'],
+		bar => 0, secs => -1,  width => $width,
+		params => [$VISUALIZER_VUMETER] },
+		# mode 14
+		{ desc => ['VISUALIZER_SPECTRUM_ANALYZER', 'AND', 'REMAINING'],
+		bar => 0, secs => -1,  width => $width,
+		# extra parameters (bars)
+		params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width * $spectrum_bar->{full}), $spectrum_scale] },	
+		# dummy for LMS bug workaround
+		{ desc => [], bar => 0, secs => -1,  width => $width,params => [] },	
+	);
+	
+	return \@modes;
+}	
 
 1;

+ 1 - 0
plugin/SqueezeESP32/Player.pm

@@ -25,6 +25,7 @@ sub playerSettingsFrame {
 	if ($id == 0xfe) { 
 		$value = (unpack('Cn', $$data_ref))[1];
 		if ($value > 100 && $value < 400) {
+			$client->display->modes($client->display->build_modes($value));
 			$client->display->widthOverride(1, $value);
 			$client->update;
 		} 

+ 1 - 1
plugin/SqueezeESP32/install.xml

@@ -10,6 +10,6 @@
   <name>PLUGIN_SQUEEZEESP32</name>
   <description>PLUGIN_SQUEEZEESP32_DESC</description>
   <module>Plugins::SqueezeESP32::Plugin</module>
-    <version>0.20</version>
+    <version>0.21</version>
   <creator>Philippe</creator>
 </extensions>

+ 1 - 1
plugin/repo.xml

@@ -4,7 +4,7 @@
     <plugin version="0.20" name="SqueezeESP32" minTarget="7.5" maxTarget="*">
       <link>https://github.com/sle118/squeezelite-esp32</link>
       <creator>Philippe</creator>
-      <sha>c17cce48b8fa14f995ca93f51fdab52b4bdcb422</sha>
+      <sha>f1955a3c930a0c1809a1d2dac85970905c9b68a0</sha>
       <email>philippe_44@outlook.com</email>
       <desc lang="EN">SqueezeESP32 additional player id (100)</desc>
       <url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url>