diff --git a/plugin/SqueezeESP32.zip b/plugin/SqueezeESP32.zip index 34a0ec1a..1d8b8c75 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 b23cf95b..6f763be7 100644 --- a/plugin/SqueezeESP32/Graphics.pm +++ b/plugin/SqueezeESP32/Graphics.pm @@ -78,7 +78,7 @@ sub displayWidth { if ($display->widthOverride) { my $artwork = $prefs->client($client)->get('artwork'); if ($artwork->{'enable'} && $artwork->{'y'} < 32 && ($client->isPlaying || $client->isPaused)) { - return $artwork->{x} + ($display->modes->[$mode || 0]{_width} || 0); + return ($artwork->{x} || $display->widthOverride) + ($display->modes->[$mode || 0]{_width} || 0); } else { return $display->widthOverride + ($display->modes->[$mode || 0]{_width} || 0); } @@ -113,9 +113,9 @@ sub build_modes { my $artwork = $cprefs->get('artwork'); my $disp_width = $cprefs->get('width') || 128; - # if artwork is in main display, reduce width - my $width = ($artwork->{'enable'} && $artwork->{'y'} < 32) ? $artwork->{'x'} : $disp_width; - my $width_low = ($artwork->{'enable'} && ($artwork->{'y'} >= 32 || $disp_width - $artwork->{'x'} > 32)) ? $artwork->{'x'} : $disp_width; + # if artwork is in main display, reduce width but when artwork is (0,0) fake it + my $width = ($artwork->{'enable'} && $artwork->{'y'} < 32 && $artwork->{'x'}) ? $artwork->{'x'} : $disp_width; + my $width_low = ($artwork->{'enable'} && $artwork->{'x'} && ($artwork->{'y'} >= 32 || $disp_width - $artwork->{'x'} > 32)) ? $artwork->{'x'} : $disp_width; my $small_VU = $cprefs->get('small_VU'); my $spectrum = $cprefs->get('spectrum'); diff --git a/plugin/SqueezeESP32/Player.pm b/plugin/SqueezeESP32/Player.pm index 2e0b903d..78eba318 100644 --- a/plugin/SqueezeESP32/Player.pm +++ b/plugin/SqueezeESP32/Player.pm @@ -13,6 +13,19 @@ my $sprefs = preferences('server'); my $prefs = preferences('plugin.squeezeesp32'); my $log = logger('plugin.squeezeesp32'); +{ + __PACKAGE__->mk_accessor('rw', 'tone_update'); +} + +sub new { + my $class = shift; + my $client = $class->SUPER::new(@_); + $client->init_accessor( + tone_update => 0, + ); + return $client; +} + our $defaultPrefs = { 'analogOutMode' => 0, 'bass' => 0, @@ -44,7 +57,6 @@ sub hasIR { 1 } # TODO: add in settings when ready sub hasLineIn { 0 } sub hasHeadSubOut { 1 } -# TODO: LMS sliders are hard-coded in html file from -23 to +23 sub maxTreble { 20 } sub minTreble { -13 } sub maxBass { 20 } @@ -54,7 +66,7 @@ sub init { my $client = shift; if (!$handlersAdded) { - + # Add a handler for line-in/out status changes Slim::Networking::Slimproto::addHandler( LIOS => \&lineInOutStatus ); @@ -117,25 +129,41 @@ sub playerSettingsFrame { } sub bass { - return tone(2, @_); -} - -sub treble { - return tone(8, @_); + my ($client, $new) = @_; + my $value = $client->SUPER::bass($new); + + $client->update_equalizer($value, [2, 1, 3]) if defined $new; + + return $value; } -sub tone { - my ($center, $client, $value) = @_; - my $equalizer = $prefs->client($client)->get('equalizer'); +sub treble { + my ($client, $new) = @_; + my $value = $client->SUPER::treble($new); - if (defined($value)) { - $equalizer->[$center-1] = int($value * 0.2 + 0.5); - $equalizer->[$center] = int($value * 0.7 + 0.5); - $equalizer->[$center+1] = int($value * 0.1 + 0.5); - $prefs->client($client)->set('equalizer', $equalizer); - } + $client->update_equalizer($value, [8, 9, 7]) if defined $new; - return int($equalizer->[$center-1] * 0.2 + $equalizer->[$center] * 0.7 + $equalizer->[$center+1] * 0.1); + return $value; +} + +sub update_equalizer { + my ($client, $value, $index) = @_; + return if $client->tone_update; + + my $equalizer = $prefs->client($client)->get('equalizer'); + $equalizer->[$index->[0]] = $value; + $equalizer->[$index->[1]] = int($value / 2 + 0.5); + $equalizer->[$index->[2]] = int($value / 4 + 0.5); + $prefs->client($client)->set('equalizer', $equalizer); +} + +sub update_tones { + my ($client, $equalizer) = @_; + + $client->tone_update(1); + $sprefs->client($client)->set('bass', int(($equalizer->[1] * 2 + $equalizer->[2] + $equalizer->[3] * 4) / 7 + 0.5)); + $sprefs->client($client)->set('treble', int(($equalizer->[7] * 4 + $equalizer->[8] + $equalizer->[9] * 2) / 7 + 0.5)); + $client->tone_update(0); } sub update_artwork { @@ -193,6 +221,11 @@ sub clear_artwork { if ($artwork && $artwork->{'enable'}) { main::INFOLOG && $log->is_info && $log->info("artwork stop/clear " . $request->getRequestString()); $client->pluginData('artwork_md5', ''); + # refresh screen and disable artwork when artwork was full screen (hack) + if (!$artwork->{'x'} && !$artwork->{'y'}) { + $client->sendFrame(grfa => \("\x00"x4)) unless $artwork->{'x'} || $artwork->{'y'}; + $client->display->update; + } } } diff --git a/plugin/SqueezeESP32/PlayerSettings.pm b/plugin/SqueezeESP32/PlayerSettings.pm index 4f0af9cf..cde4bb0c 100644 --- a/plugin/SqueezeESP32/PlayerSettings.pm +++ b/plugin/SqueezeESP32/PlayerSettings.pm @@ -31,7 +31,7 @@ sub page { sub prefs { my ($class, $client) = @_; my @prefs; - push @prefs, qw(width small_VU) if $client->displayWidth; + push @prefs, qw(width small_VU) if defined $client->displayWidth; return ($prefs->client($client), @prefs); } @@ -41,7 +41,7 @@ sub handler { my ($cprefs, @prefs) = $class->prefs($client); if ($paramRef->{'saveSettings'}) { - if ($client->displayWidth) { + if (defined $client->displayWidth) { $cprefs->set('small_VU', $paramRef->{'pref_small_VU'} || 15); my $spectrum = { scale => $paramRef->{'pref_spectrum_scale'} || 25, @@ -73,9 +73,10 @@ sub handler { $equalizer->[$i] = $paramRef->{"pref_equalizer.$i"} || 0; } $cprefs->set('equalizer', $equalizer); + $client->update_tones($equalizer); } - if ($client->displayWidth) { + if (defined $client->displayWidth) { # the Settings super class can't handle anything but scalar values # we need to populate the $paramRef for the other prefs manually $paramRef->{'pref_spectrum'} = $cprefs->get('spectrum'); diff --git a/plugin/SqueezeESP32/install.xml b/plugin/SqueezeESP32/install.xml index d6062cce..ef8c3894 100644 --- a/plugin/SqueezeESP32/install.xml +++ b/plugin/SqueezeESP32/install.xml @@ -10,6 +10,6 @@ PLUGIN_SQUEEZEESP32 PLUGIN_SQUEEZEESP32_DESC Plugins::SqueezeESP32::Plugin - 0.100 + 0.104 Philippe diff --git a/plugin/repo.xml b/plugin/repo.xml index a573f19c..8a7a7cac 100644 --- a/plugin/repo.xml +++ b/plugin/repo.xml @@ -1,10 +1,10 @@ - + https://github.com/sle118/squeezelite-esp32 Philippe - 572fa8afeaa3bc3cfb245b8d42ba05739aec584b + 79e505a30d7b6dbf43893acab176d57438e2a4a1 philippe_44@outlook.com SqueezeESP32 additional player id (100) http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip