better screensaver handling - release

This commit is contained in:
philippe44
2020-03-21 13:24:26 -07:00
parent ff40290610
commit fb499982c2
8 changed files with 32 additions and 24 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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 );
}

View File

@@ -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>