浏览代码

better screensaver handling - release

philippe44 5 年之前
父节点
当前提交
fb499982c2

+ 11 - 13
components/squeezelite/display.c

@@ -735,12 +735,18 @@ static void grfa_handler(u8_t *data, int len) {
 	int length = htonl(pkt->length);
 	
 	artwork.enable = (length != 0);
-	
-	// clean up if we are disabling previously enabled artwork
-	if (!artwork.enable) {
-		if (artwork.size) GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK);
+
+	// just a config or an actual artwork	
+	if (length < 32) {
+		if (artwork.enable) {
+			// this is just to specify artwork coordinates
+			artwork.x = htons(pkt->x);
+			artwork.y = htons(pkt->y);		
+		} else if (artwork.size) GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK);
+		
+		// done in any case
 		return;
-	}	
+	}
 	
 	// new grfa artwork, allocate memory
 	if (!offset) {	
@@ -1071,11 +1077,3 @@ static void displayer_task(void *args) {
 		visu.wake -= sleep;
 	}	
 }	
-			
-
-
-
-
-
-
-

二进制
plugin/SqueezeESP32.zip


+ 4 - 1
plugin/SqueezeESP32/Graphics.pm

@@ -42,7 +42,10 @@ sub new {
 		
 	$display->init_accessor(	
 		modes => $display->build_modes,
-		vfdmodel => 'graphic-<width>x32',	# doesn't matter much
+		# Only seems to matter for screensaver and update to decide font. Not 
+		# any value is acceptable, so use Boom value which seems to be best 
+		# compromise
+		vfdmodel => 'graphic-160x32',	
 	);	
 	
 	return $display;

+ 6 - 0
plugin/SqueezeESP32/Player.pm

@@ -13,6 +13,12 @@ sub model { 'squeezeesp32' }
 sub modelName { 'SqueezeESP32' }
 sub hasIR { 0 }
 
+sub init {
+	my $client = shift;
+	$client->SUPER::init(@_);
+	Plugins::SqueezeESP32::Plugin::config_artwork($client);
+}
+
 # Allow the player to define it's display width (and probably more)
 sub playerSettingsFrame {
 	my $client   = shift;

+ 1 - 1
plugin/SqueezeESP32/PlayerSettings.pm

@@ -59,7 +59,7 @@ sub handler {
 		if ($artwork->{'enable'}) {
 			Plugins::SqueezeESP32::Plugin::update_artwork($client, 1);
 		} else {
-			Plugins::SqueezeESP32::Plugin::disable_artwork($client);
+			Plugins::SqueezeESP32::Plugin::config_artwork($client);
 		}	
 	}
 	

+ 7 - 6
plugin/SqueezeESP32/Plugin.pm

@@ -50,7 +50,7 @@ sub onNotification {
 
 sub update_artwork {
     my $client  = shift;
-	my $force = shift || 0;
+	my $params = { force => shift || 0 };
 	my $cprefs = $prefs->client($client);
 	my $artwork = $cprefs->get('artwork');
 		
@@ -60,17 +60,17 @@ sub update_artwork {
 	$s = min($s, $cprefs->get('width') - $artwork->{'x'});
 	
 	my $path = 'music/current/cover_' . $s . 'x' . $s . '_o.jpg';
-	my $body = Slim::Web::Graphics::artworkRequest($client, $path, $force, \&send_artwork, undef, HTTP::Response->new);
+	my $body = Slim::Web::Graphics::artworkRequest($client, $path, $params, \&send_artwork, undef, HTTP::Response->new);
 	
 	send_artwork($client, undef, \$body) if $body;
 }
 
 sub send_artwork {
-	my ($client, $force, $dataref) = @_;
+	my ($client, $params, $dataref) = @_;
 	
 	# I'm not sure why we are called so often, so only send when needed
 	my $md5 = md5($$dataref);
-	return if $client->pluginData('artwork_md5') eq $md5 && !$force;
+	return if $client->pluginData('artwork_md5') eq $md5 && !$params->{'force'};
 	
 	$client->pluginData('artwork', $dataref);
 	$client->pluginData('artwork_md5', $md5);
@@ -95,9 +95,10 @@ sub send_artwork {
 	}
 }	
 
-sub disable_artwork {
+sub config_artwork {
 	my ($client) = @_;
-	my $header = pack('N', 0);
+	my $artwork = $prefs->client($client)->get('artwork');
+	my $header = pack('Nnn', $artwork->{'enable'}, $artwork->{'x'}, $artwork->{'y'});
 	$client->sendFrame( grfa => \$header );
 }
 

+ 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.50</version>
+    <version>0.51</version>
   <creator>Philippe</creator>
 </extensions>

+ 2 - 2
plugin/repo.xml

@@ -1,10 +1,10 @@
 <?xml version='1.0' standalone='yes'?>
 <extensions>
   <plugins>
-    <plugin version="0.50" name="SqueezeESP32" minTarget="7.5" maxTarget="*">
+    <plugin version="0.51" name="SqueezeESP32" minTarget="7.5" maxTarget="*">
       <link>https://github.com/sle118/squeezelite-esp32</link>
       <creator>Philippe</creator>
-      <sha>47feaf69a40ad4f87c58b34212d71e60dca99d3e</sha>
+      <sha>22551488cdbe02c7a357b2b520f8d377af9cb7d3</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>