mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 22:17:17 +03:00
1st artwork version
This commit is contained in:
@@ -71,7 +71,12 @@ sub displayWidth {
|
||||
}
|
||||
|
||||
if ($display->widthOverride) {
|
||||
return $display->widthOverride + ($display->modes->[$mode || 0]{_width} || 0);
|
||||
my $artwork = $prefs->client($client)->get('artwork');
|
||||
if ($artwork->{'enable'} && $artwork->{'y'} < 32) {
|
||||
return $artwork->{x} + ($display->modes->[$mode || 0]{_width} || 0);
|
||||
} else {
|
||||
return $display->widthOverride + ($display->modes->[$mode || 0]{_width} || 0);
|
||||
}
|
||||
} else {
|
||||
return $display->modes->[$mode || 0]{width};
|
||||
}
|
||||
@@ -101,9 +106,21 @@ sub build_modes {
|
||||
my $cprefs = $prefs->client($client);
|
||||
|
||||
my $width = shift || $cprefs->get('width') || 128;
|
||||
my $artwork = $cprefs->get('artwork');
|
||||
|
||||
# if artwork is in main display, reduce width
|
||||
$width = $artwork->{'x'} - 1 if $artwork->{'enable'} && $artwork->{y} < 32;
|
||||
|
||||
my $small_VU = $cprefs->get('small_VU');
|
||||
my $spectrum = $cprefs->get('spectrum');
|
||||
|
||||
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),
|
||||
width => int ($small_VU * $width / 100),
|
||||
};
|
||||
|
||||
my @modes = (
|
||||
# mode 0
|
||||
{ desc => ['BLANK'],
|
||||
@@ -135,14 +152,14 @@ sub build_modes {
|
||||
params => [$VISUALIZER_NONE] },
|
||||
# mode 7
|
||||
{ desc => ['VISUALIZER_VUMETER_SMALL'],
|
||||
bar => 0, secs => 0, width => $width, _width => int -($small_VU*$width/100),
|
||||
bar => 0, secs => 0, width => $width, _width => -$small_VU_pos->{'width'},
|
||||
# extra parameters (width, height, col (< 0 = from right), row (< 0 = from bottom), left_space)
|
||||
params => [$VISUALIZER_VUMETER, int ($small_VU*$width/100), 32, int -($small_VU*$width/100), 0, 2] },
|
||||
params => [$VISUALIZER_VUMETER, $small_VU_pos->{'width'}, 32, $small_VU_pos->{'x'}, 0, 2] },
|
||||
# mode 8
|
||||
{ desc => ['VISUALIZER_SPECTRUM_ANALYZER_SMALL'],
|
||||
bar => 0, secs => 0, width => $width, _width => int -($spectrum->{small}->{size}*$width/100),
|
||||
bar => 0, secs => 0, width => $width, _width => -$small_spectrum_pos->{'width'},
|
||||
# extra parameters (width, height, col (< 0 = from right), row (< 0 = from bottom), left_space, bars)
|
||||
params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($spectrum->{small}->{size}*$width/100), 32, int -($spectrum->{small}->{size}*$width/100), 0, 2, int ($spectrum->{small}->{size}/100*$width/$spectrum->{small}->{band}), $spectrum->{scale}] },
|
||||
params => [$VISUALIZER_SPECTRUM_ANALYZER, $small_spectrum_pos->{width}, 32, $small_spectrum_pos->{'x'}, 0, 2, $small_spectrum_pos->{'width'} / $spectrum->{small}->{band}, $spectrum->{scale}] },
|
||||
# mode 9
|
||||
{ desc => ['VISUALIZER_VUMETER'],
|
||||
bar => 0, secs => 0, width => $width,
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
[% PROCESS settings/header.html %]
|
||||
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_BANNER" %]
|
||||
<div>[% "PLUGIN_SQUEEZEESP32_BANNER_TEXT" | string %]</div>
|
||||
[% END %]
|
||||
|
||||
<div class="prefDesc">
|
||||
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_WIDTH" desc="PLUGIN_SQUEEZEESP32_WIDTH_DESC" %]
|
||||
<input type="text" class="stdedit" name="pref_width" id="pref_width" value="[% prefs.pref_width %]" size="3">
|
||||
[% END %]
|
||||
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_SPECTRUM_SCALE" desc="PLUGIN_SQUEEZEESP32_SPECTRUM_SCALE_DESC" %]
|
||||
<input type="number" min="10" max= "50" step="5" class="stdedit" name="pref_spectrum_scale" id="pref_spectrum_scale" value="[% prefs.pref_spectrum_scale %]" size="3">
|
||||
[% END %]
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
[% PROCESS settings/footer.html %]
|
||||
@@ -20,8 +20,8 @@ sub playerSettingsFrame {
|
||||
|
||||
my $value;
|
||||
my $id = unpack('C', $$data_ref);
|
||||
|
||||
# New SETD command 0xfe for display width
|
||||
|
||||
# New SETD command 0xfe for display width & height
|
||||
if ($id == 0xfe) {
|
||||
$value = (unpack('Cn', $$data_ref))[1];
|
||||
if ($value > 100 && $value < 400) {
|
||||
@@ -30,7 +30,9 @@ sub playerSettingsFrame {
|
||||
$client->display->widthOverride(1, $value);
|
||||
$client->update;
|
||||
}
|
||||
$log->info("Setting player width $value for ", $client->name);
|
||||
my $height = (unpack('Cnn', $$data_ref))[2];
|
||||
$prefs->client($client)->set('height', $height || 0);
|
||||
$log->info("Setting player $value" . "x" . "$height for ", $client->name);
|
||||
}
|
||||
|
||||
$client->SUPER::playerSettingsFrame($data_ref);
|
||||
@@ -40,4 +42,11 @@ sub hasScrolling {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
sub directMetadata {
|
||||
my $client = shift;
|
||||
$client->SUPER::directMetadata(@_);
|
||||
Slim::Control::Request::notifyFromArray( $client, [ 'newmetadata' ] );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -30,7 +30,7 @@ sub page {
|
||||
|
||||
sub prefs {
|
||||
my ($class, $client) = @_;
|
||||
my @prefs = qw(width small_VU spectrum);
|
||||
my @prefs = qw(width small_VU spectrum artwork);
|
||||
return ($prefs->client($client), @prefs);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,11 @@ sub handler {
|
||||
full => { band => $paramRef->{'pref_spectrum_full_band'} },
|
||||
};
|
||||
$cprefs->set('spectrum', $spectrum);
|
||||
my $artwork = { enable => $paramRef->{'pref_artwork_enable'},
|
||||
x => $paramRef->{'pref_artwork_x'},
|
||||
y => $paramRef->{'pref_artwork_y'},
|
||||
};
|
||||
$cprefs->set('artwork', $artwork);
|
||||
$client->display->modes($client->display->build_modes);
|
||||
$client->display->update;
|
||||
}
|
||||
@@ -56,9 +61,10 @@ sub handler {
|
||||
|
||||
# here I don't know why you need to set again spectrum which is a reference
|
||||
# to a hash. Using $paramRef->{prefs} does not work either. It seems that
|
||||
# soem are copies of value, some are references, can't figure out.This whole
|
||||
# some are copies of value, some are references, can't figure out. This whole
|
||||
# logic of "Settings" is beyond me and I really hate it
|
||||
$paramRef->{'pref_spectrum'} = $cprefs->get('spectrum');
|
||||
$paramRef->{'pref_artwork'} = $cprefs->get('artwork');
|
||||
|
||||
return $class->SUPER::handler($client, $paramRef);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,12 @@ package Plugins::SqueezeESP32::Plugin;
|
||||
use strict;
|
||||
|
||||
use base qw(Slim::Plugin::Base);
|
||||
|
||||
use Digest::MD5 qw(md5);
|
||||
use List::Util qw(min);
|
||||
use Slim::Utils::Prefs;
|
||||
use Slim::Utils::Log;
|
||||
use Slim::Web::ImageProxy;
|
||||
|
||||
my $prefs = preferences('plugin.squeezeesp32');
|
||||
|
||||
@@ -28,6 +32,61 @@ sub initPlugin {
|
||||
$class->SUPER::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'] ]);
|
||||
}
|
||||
|
||||
sub update_artwork {
|
||||
my $request = shift;
|
||||
my $client = $request->client;
|
||||
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);
|
||||
|
||||
send_artwork($client, undef, \$body) if $body;
|
||||
|
||||
$log->info("artwork update notification $reqstr with $path");
|
||||
}
|
||||
|
||||
sub send_artwork {
|
||||
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;
|
||||
|
||||
$client->pluginData('artwork', $dataref);
|
||||
$client->pluginData('artwork_md5', $md5);
|
||||
|
||||
my $artwork = $prefs->client($client)->get('artwork');
|
||||
my $length = length $$dataref;
|
||||
my $offset = 0;
|
||||
|
||||
$log->info("got resized artwork (length: ", length $$dataref, ")");
|
||||
|
||||
my $header = pack('Nnn', $length, $artwork->{'x'}, $artwork->{'y'});
|
||||
|
||||
while ($length > 0) {
|
||||
$length = 1280 if $length > 1280;
|
||||
$log->info("sending grfa $length");
|
||||
|
||||
my $data = $header . pack('N', $offset) . substr( $$dataref, 0, $length, '' );
|
||||
|
||||
$client->sendFrame( grfa => \$data );
|
||||
$offset += $length;
|
||||
$length = length $$dataref;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package Plugins::SqueezeESP32::Settings;
|
||||
use base qw(Slim::Web::Settings);
|
||||
|
||||
use strict;
|
||||
|
||||
use Slim::Utils::Prefs;
|
||||
use Slim::Utils::Log;
|
||||
|
||||
my $log = logger('plugin.squeezeesp32');
|
||||
|
||||
sub name {
|
||||
return 'PLUGIN_SQUEEZEESP32';
|
||||
}
|
||||
|
||||
sub page {
|
||||
return 'plugins/SqueezeESP32/settings/basic.html';
|
||||
}
|
||||
|
||||
sub prefs {
|
||||
return (preferences('plugin.squeezeesp32'), qw(width spectrum_scale));
|
||||
}
|
||||
|
||||
sub handler {
|
||||
my ($class, $client, $params, $callback, @args) = @_;
|
||||
|
||||
$callback->($client, $params, $class->SUPER::handler($client, $params), @args);
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
BIN
plugin/SqueezeESP32/SqueezeESP32.zip
Normal file
BIN
plugin/SqueezeESP32/SqueezeESP32.zip
Normal file
Binary file not shown.
@@ -10,6 +10,6 @@
|
||||
<name>PLUGIN_SQUEEZEESP32</name>
|
||||
<description>PLUGIN_SQUEEZEESP32_DESC</description>
|
||||
<module>Plugins::SqueezeESP32::Plugin</module>
|
||||
<version>0.31</version>
|
||||
<version>0.40</version>
|
||||
<creator>Philippe</creator>
|
||||
</extensions>
|
||||
|
||||
@@ -53,3 +53,19 @@ PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND
|
||||
|
||||
PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND_DESC
|
||||
EN The number of bands is the width of the screen divided by this factor
|
||||
|
||||
PLUGIN_SQUEEZEESP32_ARTWORK
|
||||
EN Artwork
|
||||
|
||||
PLUGIN_SQUEEZEESP32_ARTWORK_DESC
|
||||
EN When Y position is less than 32, then artwork is display 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
|
||||
|
||||
PLUGIN_SQUEEZEESP32_ARTWORK_ENABLE
|
||||
EN Enable
|
||||
|
||||
PLUGIN_SQUEEZEESP32_ARTWORK_X
|
||||
EN X
|
||||
|
||||
PLUGIN_SQUEEZEESP32_ARTWORK_Y
|
||||
EN Y
|
||||
|
||||
Reference in New Issue
Block a user