Skip to content

Commit

Permalink
mirror make branch changes on plugin (need to point there ...)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippe44 committed Dec 2, 2020
1 parent 3dc2ed9 commit 99019cd
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 30 deletions.
47 changes: 35 additions & 12 deletions plugin/SqueezeESP32/Graphics.pm
Expand Up @@ -17,6 +17,17 @@ my $VISUALIZER_WAVEFORM = 3;
my $VISUALIZER_VUMETER_ESP32 = 0x11;
my $VISUALIZER_SPECTRUM_ANALYZER_ESP32 = 0x12;

my %SPECTRUM_DEFAULTS = (
scale => 25,
small => {
size => 25,
band => 5.33
},
full => {
band => 8
},
);

{
#__PACKAGE__->mk_accessor('array', 'modes');
__PACKAGE__->mk_accessor('rw', 'modes');
Expand All @@ -33,14 +44,16 @@ sub new {
$cprefs->init( {
width => 128,
small_VU => 15,
spectrum => { scale => 25,
small => { size => 25, band => 5.33 },
full => { band => 8 },
},
}
);

$display->init_accessor(
spectrum => \%SPECTRUM_DEFAULTS,
} );

$prefs->migrateClient(2, sub {
my ($cprefs, $client) = @_;
sanitizeSpectrum($cprefs->get('spectrum'));
1;
});

$display->init_accessor(
modes => $display->build_modes,
# 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
Expand Down Expand Up @@ -106,6 +119,16 @@ sub displayHeight {
return 32;
}

sub sanitizeSpectrum {
my ($spectrum) = shift;

$spectrum->{small}->{size} ||= $SPECTRUM_DEFAULTS{small}->{size};
$spectrum->{small}->{band} ||= $SPECTRUM_DEFAULTS{small}->{band};
$spectrum->{full}->{band} ||= $SPECTRUM_DEFAULTS{full}->{band};

return $spectrum;
}

sub build_modes {
my $client = shift->client;
my $cprefs = $prefs->client($client);
Expand All @@ -118,9 +141,9 @@ sub build_modes {
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');
my $small_spectrum_pos = { x => $width - int ($spectrum->{small}->{size} * $width / 100),
my $spectrum = sanitizeSpectrum($cprefs->get('sprectrum'));

my $small_spectrum_pos = { x => $width - int ($spectrum->{small}->{size} * $width / 100),
width => int ($spectrum->{small}->{size} * $width / 100),
};
my $small_VU_pos = { x => $width - int ($small_VU * $width / 100),
Expand Down Expand Up @@ -224,7 +247,7 @@ my @extra = (
);

@modes = (@modes, @extra) if $cprefs->get('height') > 32;

return \@modes;
}

Expand Down
23 changes: 16 additions & 7 deletions plugin/SqueezeESP32/Player.pm
Expand Up @@ -91,16 +91,19 @@ sub init {
}

$client->SUPER::init(@_);
$client->config_artwork;
$client->send_equalizer;

main::INFOLOG && $log->is_info && $log->info("SqueezeESP player connected: " . $client->id);
}

sub initPrefs {
my $client = shift;

$sprefs->client($client)->init($defaultPrefs);
$prefs->client($client)->init( { equalizer => [(0) x 10] } );

$prefs->client($client)->init( {
equalizer => [(0) x 10],
artwork => undef,
} );

$client->SUPER::initPrefs;
}

Expand Down Expand Up @@ -184,11 +187,13 @@ sub update_artwork {
my $cprefs = $prefs->client($client);

my $artwork = $cprefs->get('artwork') || return;

return unless $artwork->{'enable'};

my $header = pack('Nnn', $artwork->{'enable'}, $artwork->{'x'}, $artwork->{'y'});
$client->sendFrame( grfa => \$header );
$client->display->update;

my $s = min($cprefs->get('height') - $artwork->{'y'}, $cprefs->get('width') - $artwork->{'x'});

my $params = { force => shift || 0 };
my $path = 'music/current/cover_' . $s . 'x' . $s . '_o.jpg';
my $body = Slim::Web::Graphics::artworkRequest($client, $path, $params, \&send_artwork, undef, HTTP::Response->new);
Expand Down Expand Up @@ -248,13 +253,17 @@ sub config_artwork {
if ( my $artwork = $prefs->client($client)->get('artwork') ) {
my $header = pack('Nnn', $artwork->{'enable'}, $artwork->{'x'}, $artwork->{'y'});
$client->sendFrame( grfa => \$header );
$client->display->update;
}
}

sub reconnect {
my $client = shift;
$client->pluginData('artwork_md5', '');
$client->SUPER::reconnect(@_);

$client->pluginData('artwork_md5', '');
$client->config_artwork;
$client->send_equalizer;
}

# Change the analog output mode between headphone and sub-woofer
Expand Down
24 changes: 16 additions & 8 deletions plugin/SqueezeESP32/PlayerSettings.pm
Expand Up @@ -43,29 +43,37 @@ sub handler {
if ($paramRef->{'saveSettings'}) {
if ($client->displayWidth) {
$cprefs->set('small_VU', $paramRef->{'pref_small_VU'} || 15);
my $spectrum = {
scale => $paramRef->{'pref_spectrum_scale'} || 25,
small => { size => $paramRef->{'pref_spectrum_small_size'} || 25,
band => $paramRef->{'pref_spectrum_small_band'} || 5.33 },
full => { band => $paramRef->{'pref_spectrum_full_band'} } || 8,
};

require Plugins::SqueezeESP32::Graphics;
my $spectrum = Plugins::SqueezeESP32::Graphics::sanitizeSpectrum({
scale => $paramRef->{'pref_spectrum_scale'},
small => {
size => $paramRef->{'pref_spectrum_small_size'},
band => $paramRef->{'pref_spectrum_small_band'}
},
full => {
band => $paramRef->{'pref_spectrum_full_band'}
},
});
$cprefs->set('spectrum', $spectrum);

my $artwork = {
enable => $paramRef->{'pref_artwork_enable'},
enable => $paramRef->{'pref_artwork_enable'} eq 'on',
x => $paramRef->{'pref_artwork_x'} || 0,
y => $paramRef->{'pref_artwork_y'} || 0,
};

$cprefs->set('artwork', $artwork);
$client->display->modes($client->display->build_modes);
$client->display->update;
# the display update will be done below, after all is completed

# force update or disable artwork
if ($artwork->{'enable'}) {
$client->update_artwork(1);
} else {
$client->config_artwork();
}

}

my $equalizer = $cprefs->get('equalizer');
Expand Down
6 changes: 6 additions & 0 deletions plugin/SqueezeESP32/Plugin.pm
Expand Up @@ -24,6 +24,12 @@ $prefs->migrateClient(1, sub {
1;
});

$prefs->migrateClient(2, sub {
my ($cprefs, $client) = @_;
$cprefs->set('artwork', undef) if $cprefs->get('artwork') && ref $cprefs->get('artwork') ne 'HASH';
1;
});

$prefs->setChange(sub {
$_[2]->send_equalizer;
}, 'equalizer');
Expand Down
2 changes: 1 addition & 1 deletion plugin/SqueezeESP32/install.xml
Expand Up @@ -10,6 +10,6 @@
<name>PLUGIN_SQUEEZEESP32</name>
<description>PLUGIN_SQUEEZEESP32_DESC</description>
<module>Plugins::SqueezeESP32::Plugin</module>
<version>0.200</version>
<version>0.210</version>
<creator>Philippe</creator>
</extensions>
6 changes: 4 additions & 2 deletions plugin/SqueezeESP32/strings.txt
Expand Up @@ -80,8 +80,10 @@ PLUGIN_SQUEEZEESP32_ARTWORK
PLUGIN_SQUEEZEESP32_ARTWORK_DESC
DE Wenn die Y Position kleiner als 32 ist, dann werden Plattenhüllen auf der rechten Seite angezeigt, und x definiert die Startposition.
DE Plattenhüllen werden auf Displays mit weniger als 16 Graustufen in sehr geringer Qualität angezeigt.
EN When Y position is less than 32, then artwork is displayed at the right of the main screen and x defines the starting position
EN Using artwork on less than 16-levels grayscale display if really poor quality
EN When Y position is less than 32, then artwork is displayed at the right of the main screen and X defines the starting position
EN <br>On large screen, it's possible to rotate the VU/Spectrum by setting a small X offset (typically 32). That will push the
EN artwork to the right and make space for a vertical VU to its left.
EN <br>Note that using artwork on less than 16-levels grayscale display if really poor quality

PLUGIN_SQUEEZEESP32_ARTWORK_ENABLE
DE Aktivieren
Expand Down

0 comments on commit 99019cd

Please sign in to comment.