diff --git a/components/squeezelite/display.c b/components/squeezelite/display.c index c85cf4a2..cace344e 100644 --- a/components/squeezelite/display.c +++ b/components/squeezelite/display.c @@ -595,9 +595,6 @@ static void grfs_handler(u8_t *data, int len) { scroller.first = true; scroller.overflow = false; - // background excludes space taken by visu (if any) - scroller.back.width = displayer.width - ((visu.mode && visu.row < SB_HEIGHT) ? visu.width : 0); - // set scroller steps & beginning if (pkt->direction == 1) { scroller.scrolled = 0; @@ -634,6 +631,7 @@ static void grfg_handler(u8_t *data, int len) { // size of scrollable area (less than background) scroller.width = htons(pkt->width); + scroller.back.width = ((len - sizeof(struct grfg_packet)) * 8) / displayer.height; memcpy(scroller.back.frame, data + sizeof(struct grfg_packet), len - sizeof(struct grfg_packet)); // update display asynchronously (frames are organized by columns) @@ -670,13 +668,20 @@ static void grfa_handler(u8_t *data, int len) { // new grfa artwork, allocate memory if (!offset) { + // same trick to clean current/previous window + if (artwork.size) { + GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK); + artwork.size = 0; + } + + // now use new parameters artwork.x = htons(pkt->x); artwork.y = htons(pkt->y); if (artwork.data) free(artwork.data); artwork.data = malloc(length); artwork.size = 0; } - + // copy artwork data memcpy(artwork.data + offset, data + sizeof(struct grfa_packet), size); artwork.size += size; @@ -685,7 +690,6 @@ static void grfa_handler(u8_t *data, int len) { GDS_DrawJPEG(display, artwork.data, artwork.x, artwork.y, artwork.y < 32 ? (GDS_IMAGE_RIGHT | GDS_IMAGE_TOP) : GDS_IMAGE_CENTER); free(artwork.data); artwork.data = NULL; - artwork.size = 0; } LOG_INFO("gfra l:%u x:%hu, y:%hu, o:%u s:%u", length, artwork.x, artwork.y, offset, size); @@ -849,9 +853,6 @@ static void visu_handler( u8_t *data, int len) { visu.border = htonl(pkt->border); bars = htonl(pkt->bars); visu.spectrum_scale = htonl(pkt->spectrum_scale) / 100.; - - // might have a race condition with scroller message, so update width in case - if (scroller.active) scroller.back.width = displayer.width - visu.width; } else { // full screen visu, try to use bottom screen if available visu.width = displayer.width; diff --git a/plugin/SqueezeESP32.zip b/plugin/SqueezeESP32.zip index 2a3b0eeb..cf1d7f50 100644 Binary files a/plugin/SqueezeESP32.zip and b/plugin/SqueezeESP32.zip differ diff --git a/plugin/SqueezeESP32/Graphics.pm b/plugin/SqueezeESP32/Graphics.pm index a8dead59..f90134ac 100644 --- a/plugin/SqueezeESP32/Graphics.pm +++ b/plugin/SqueezeESP32/Graphics.pm @@ -109,7 +109,7 @@ sub build_modes { my $artwork = $cprefs->get('artwork'); # if artwork is in main display, reduce width - $width = $artwork->{'x'} - 1 if $artwork->{'enable'} && $artwork->{y} < 32; + $width = $artwork->{'x'} if $artwork->{'enable'} && $artwork->{y} < 32; my $small_VU = $cprefs->get('small_VU'); my $spectrum = $cprefs->get('spectrum'); @@ -119,7 +119,7 @@ sub build_modes { }; my $small_VU_pos = { x => $width - int ($small_VU * $width / 100), width => int ($small_VU * $width / 100), - }; + }; my @modes = ( # mode 0 diff --git a/plugin/SqueezeESP32/Player.pm b/plugin/SqueezeESP32/Player.pm index d3692e2e..e0e6a3b7 100644 --- a/plugin/SqueezeESP32/Player.pm +++ b/plugin/SqueezeESP32/Player.pm @@ -42,6 +42,11 @@ sub hasScrolling { return 1; } +sub reconnect { + my $client = shift; + $client->pluginData('artwork_md5', ''); + $client->SUPER::reconnect(@_); +} sub directMetadata { my $client = shift; diff --git a/plugin/SqueezeESP32/PlayerSettings.pm b/plugin/SqueezeESP32/PlayerSettings.pm index 1ff4f7b9..4fd57722 100644 --- a/plugin/SqueezeESP32/PlayerSettings.pm +++ b/plugin/SqueezeESP32/PlayerSettings.pm @@ -54,6 +54,9 @@ sub handler { $cprefs->set('artwork', $artwork); $client->display->modes($client->display->build_modes); $client->display->update; + + # force update + Plugins::SqueezeESP32::Plugin::update_artwork($client, 1) if $artwork->{'enable'}; } # as there is nothing captured, we need to re-set these variables diff --git a/plugin/SqueezeESP32/Plugin.pm b/plugin/SqueezeESP32/Plugin.pm index 22a462d6..37dcc055 100644 --- a/plugin/SqueezeESP32/Plugin.pm +++ b/plugin/SqueezeESP32/Plugin.pm @@ -33,38 +33,44 @@ sub initPlugin { Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' }); $log->info("Added class 100 for SqueezeESP32"); - Slim::Control::Request::subscribe(\&update_artwork, [ ['newmetadata'] ] ); - Slim::Control::Request::subscribe(\&update_artwork, [ ['playlist'], ['open', 'newsong'] ]); + Slim::Control::Request::subscribe(\&onNotification, [ ['newmetadata'] ] ); + Slim::Control::Request::subscribe(\&onNotification, [ ['playlist'], ['open', 'newsong'] ]); +} + +sub onNotification { + my $request = shift; + my $client = $request->client; + + my $reqstr = $request->getRequestString(); + $log->info("artwork update notification $reqstr"); + #my $path = $request->getParam('_path'); + + update_artwork($client); } sub update_artwork { - my $request = shift; - my $client = $request->client; + my $client = shift; + my $force = shift || 0; my $cprefs = $prefs->client($client); my $artwork = $cprefs->get('artwork'); return unless $client->model eq 'squeezeesp32' && $artwork->{'enable'}; - my $reqstr = $request->getRequestString(); - #my $path = $request->getParam('_path'); - my $s = $artwork->{'y'} >= 32 ? $cprefs->get('height') - $artwork->{'y'} : 32; $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, undef, \&send_artwork, undef, HTTP::Response->new); + my $body = Slim::Web::Graphics::artworkRequest($client, $path, $force, \&send_artwork, undef, HTTP::Response->new); send_artwork($client, undef, \$body) if $body; - - $log->info("artwork update notification $reqstr with $path"); } sub send_artwork { - my ($client, $params, $dataref) = @_; + my ($client, $force, $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; + return if $client->pluginData('artwork_md5') eq $md5 && !$force; $client->pluginData('artwork', $dataref); $client->pluginData('artwork_md5', $md5); diff --git a/plugin/SqueezeESP32/SqueezeESP32.zip b/plugin/SqueezeESP32/SqueezeESP32.zip deleted file mode 100644 index 2a3b0eeb..00000000 Binary files a/plugin/SqueezeESP32/SqueezeESP32.zip and /dev/null differ diff --git a/plugin/SqueezeESP32/install.xml b/plugin/SqueezeESP32/install.xml index 14f6f93a..f2c4e542 100644 --- a/plugin/SqueezeESP32/install.xml +++ b/plugin/SqueezeESP32/install.xml @@ -10,6 +10,6 @@ PLUGIN_SQUEEZEESP32 PLUGIN_SQUEEZEESP32_DESC Plugins::SqueezeESP32::Plugin - 0.40 + 0.41 Philippe diff --git a/plugin/repo.xml b/plugin/repo.xml index e0c81729..41953d0e 100644 --- a/plugin/repo.xml +++ b/plugin/repo.xml @@ -1,10 +1,10 @@ - + https://github.com/sle118/squeezelite-esp32 Philippe - aa122a85db949c903ffa978d3e3b4ee3205e4ec2 + 88ecf433757f057351bcb88461c1db040caef884 philippe_44@outlook.com SqueezeESP32 additional player id (100) http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip