diff --git a/plugin/SqueezeESP32.zip b/plugin/SqueezeESP32.zip
index a64028a7..743e2fe5 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 db58703d..f6a92158 100644
--- a/plugin/SqueezeESP32/Graphics.pm
+++ b/plugin/SqueezeESP32/Graphics.pm
@@ -21,13 +21,22 @@ my $VISUALIZER_WAVEFORM = 3;
__PACKAGE__->mk_accessor('rw', qw(vfdmodel));
}
-use Data::Dumper;
-
sub new {
my $class = shift;
my $client = shift;
my $display = $class->SUPER::new($client);
+ my $cprefs = $prefs->client($client);
+
+ $cprefs->init( {
+ width => 128,
+ small_VU => 15,
+ spectrum => { scale => 25,
+ small => { size => 25, band => 5.33 },
+ full => { band => 8 },
+ },
+ }
+ );
$display->init_accessor(
modes => $display->build_modes,
@@ -44,14 +53,13 @@ sub modes {
=cut
sub nmodes {
- # -1 for LMS bug workaround
- return scalar(@{shift->modes}) - 1;
+ return scalar($#{shift->modes()});
}
sub displayWidth {
my $display = shift;
my $client = $display->client;
-
+
# if we're showing the always-on visualizer & the current buttonmode
# hasn't overridden, then use the playing display mode to index
# into the display width, otherwise, it's fullscreen.
@@ -88,22 +96,13 @@ sub displayHeight {
return 32;
}
-=comment
-sub vfdmodel {
- return 'graphic-'.$width.'x32';
-}
-=cut
-
sub build_modes {
my $client = shift->client;
- print("CLIENT IN BUILD MODE $client\n");
my $cprefs = $prefs->client($client);
- my $width = shift || $cprefs->get('width') || $prefs->get('width') || 128;
- my $small_VU = shift || $cprefs->get('small_vu') || 0.15;
- my $small_spectrum = shift || $cprefs->get('small_spectrum') || 0.25;
- my $spectrum_bar = shift || $cprefs->get('spectrum_bar') || { 'small' => 0.1875, 'full' => 0.125 };
- my $spectrum_scale = shift || $cprefs->get('spectrum_scale') || $prefs->get('spectrum_scale') || 50;
+ my $width = shift || $cprefs->get('width') || 128;
+ my $small_VU = $cprefs->get('small_VU');
+ my $spectrum = $cprefs->get('spectrum');
my @modes = (
# mode 0
@@ -136,14 +135,14 @@ sub build_modes {
params => [$VISUALIZER_NONE] },
# mode 7
{ desc => ['VISUALIZER_VUMETER_SMALL'],
- bar => 0, secs => 0, width => $width, _width => int -($small_VU*$width),
+ bar => 0, secs => 0, width => $width, _width => int -($small_VU*$width/100),
# extra parameters (width, height, col (< 0 = from right), row (< 0 = from bottom), left_space)
- params => [$VISUALIZER_VUMETER, int ($small_VU* $width), 32, int -($small_VU*$width), 0, 2] },
+ params => [$VISUALIZER_VUMETER, int ($small_VU*$width/100), 32, int -($small_VU*$width/100), 0, 2] },
# mode 8
{ desc => ['VISUALIZER_SPECTRUM_ANALYZER_SMALL'],
- bar => 0, secs => 0, width => $width, _width => int -($small_spectrum*$width),
+ bar => 0, secs => 0, width => $width, _width => int -($spectrum->{small}->{size}*$width/100),
# extra parameters (width, height, col (< 0 = from right), row (< 0 = from bottom), left_space, bars)
- params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($small_spectrum*$width), 32, int -($small_spectrum*$width), 0, 2, int ($small_spectrum*$width*$spectrum_bar->{small}), $spectrum_scale] },
+ 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}/100] },
# mode 9
{ desc => ['VISUALIZER_VUMETER'],
bar => 0, secs => 0, width => $width,
@@ -152,7 +151,7 @@ sub build_modes {
{ desc => ['VISUALIZER_SPECTRUM_ANALYZER'],
bar => 0, secs => 0, width => $width,
# extra parameters (bars)
- params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width * $spectrum_bar->{full}), $spectrum_scale] },
+ params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width/$spectrum->{full}->{band}), $spectrum->{scale}/100] },
# mode 11
{ desc => ['VISUALIZER_VUMETER', 'AND', 'ELAPSED'],
bar => 0, secs => 1, width => $width,
@@ -161,7 +160,7 @@ sub build_modes {
{ desc => ['VISUALIZER_SPECTRUM_ANALYZER', 'AND', 'ELAPSED'],
bar => 0, secs => 1, width => $width,
# extra parameters (bars)
- params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width * $spectrum_bar->{full}), $spectrum_scale] },
+ params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width/$spectrum->{full}->{band}), $spectrum->{scale}/100] },
# mode 13
{ desc => ['VISUALIZER_VUMETER', 'AND', 'REMAINING'],
bar => 0, secs => -1, width => $width,
@@ -170,9 +169,7 @@ sub build_modes {
{ desc => ['VISUALIZER_SPECTRUM_ANALYZER', 'AND', 'REMAINING'],
bar => 0, secs => -1, width => $width,
# extra parameters (bars)
- params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width * $spectrum_bar->{full}), $spectrum_scale] },
- # dummy for LMS bug workaround
- { desc => [], bar => 0, secs => -1, width => $width,params => [] },
+ params => [$VISUALIZER_SPECTRUM_ANALYZER, int ($width/$spectrum->{full}->{band}), $spectrum->{scale}/100] },
);
return \@modes;
diff --git a/plugin/SqueezeESP32/HTML/EN/plugins/SqueezeESP32/settings/player.html b/plugin/SqueezeESP32/HTML/EN/plugins/SqueezeESP32/settings/player.html
new file mode 100644
index 00000000..17589674
--- /dev/null
+++ b/plugin/SqueezeESP32/HTML/EN/plugins/SqueezeESP32/settings/player.html
@@ -0,0 +1,28 @@
+[% PROCESS settings/header.html %]
+
+ [% WRAPPER setting title="PLUGIN_SQUEEZEESP32_WIDTH" desc="PLUGIN_SQUEEZEESP32_WIDTH_DESC" %]
+
+ [% prefs.pref_width %]
+ [% END %]
+
+ [% WRAPPER setting title="PLUGIN_SQUEEZEESP32_SMALL_VU" desc="PLUGIN_SQUEEZEESP32_SMALL_VU_DESC" %]
+
+ [% END %]
+
+ [% WRAPPER setting title="PLUGIN_SQUEEZEESP32_SPECTRUM_SCALE" desc="PLUGIN_SQUEEZEESP32_SPECTRUM_SCALE_DESC" %]
+
+ [% END %]
+
+ [% WRAPPER setting title="PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM" desc="PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_DESC" %]
+ [% "PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_SIZE" | string %] 
+
+ [% "PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_BAND" | string %] 
+
+ [% END %]
+
+ [% WRAPPER setting title="PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND" desc="PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND_DESC" %]
+
+ [% END %]
+
+
+[% PROCESS settings/footer.html %]
diff --git a/plugin/SqueezeESP32/Player.pm b/plugin/SqueezeESP32/Player.pm
index e694d03b..946eb303 100644
--- a/plugin/SqueezeESP32/Player.pm
+++ b/plugin/SqueezeESP32/Player.pm
@@ -25,6 +25,7 @@ sub playerSettingsFrame {
if ($id == 0xfe) {
$value = (unpack('Cn', $$data_ref))[1];
if ($value > 100 && $value < 400) {
+ $prefs->client($client)->set('width', $value);
$client->display->modes($client->display->build_modes($value));
$client->display->widthOverride(1, $value);
$client->update;
diff --git a/plugin/SqueezeESP32/PlayerSettings.pm b/plugin/SqueezeESP32/PlayerSettings.pm
new file mode 100644
index 00000000..f4fc24b0
--- /dev/null
+++ b/plugin/SqueezeESP32/PlayerSettings.pm
@@ -0,0 +1,66 @@
+package Plugins::SqueezeESP32::PlayerSettings;
+
+use strict;
+use base qw(Slim::Web::Settings);
+use List::Util qw(first);
+
+use Slim::Utils::Log;
+use Slim::Utils::Prefs;
+
+my $sprefs = preferences('server');
+my $prefs = preferences('plugin.squeezeesp32');
+my $log = logger('plugin.squeezeesp32');
+
+sub name {
+ return Slim::Web::HTTP::CSRF->protectName('PLUGIN_SQUEEZEESP32_PLAYERSETTINGS');
+}
+
+sub needsClient {
+ return 1;
+}
+
+sub validFor {
+ my ($class, $client) = @_;
+ return $client->model eq 'squeezeesp32';
+}
+
+sub page {
+ return Slim::Web::HTTP::CSRF->protectURI('plugins/SqueezeESP32/settings/player.html');
+}
+
+sub prefs {
+ my ($class, $client) = @_;
+ my @prefs = qw(width small_VU spectrum);
+ return ($prefs->client($client), @prefs);
+}
+
+sub handler {
+ my ($class, $client, $paramRef) = @_;
+
+ my ($cprefs, @prefs) = $class->prefs($client);
+
+ if ($paramRef->{'saveSettings'}) {
+ $cprefs->set('small_VU', $paramRef->{'pref_small_VU'});
+ my $spectrum = { 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);
+ $client->display->modes($client->display->build_modes);
+ $client->display->update;
+ }
+
+ # as there is nothing captured, we need to re-set these variables
+ $paramRef->{'pref_width'} = $cprefs->get('width');
+
+ # 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
+ # logic of "Settings" is beyond me and I really hate it
+ $paramRef->{'pref_spectrum'} = $cprefs->get('spectrum');
+
+ return $class->SUPER::handler($client, $paramRef);
+}
+
+1;
\ No newline at end of file
diff --git a/plugin/SqueezeESP32/Plugin.pm b/plugin/SqueezeESP32/Plugin.pm
index e39979bf..5078f66c 100644
--- a/plugin/SqueezeESP32/Plugin.pm
+++ b/plugin/SqueezeESP32/Plugin.pm
@@ -8,11 +8,6 @@ use Slim::Utils::Log;
my $prefs = preferences('plugin.squeezeesp32');
-$prefs->init({
- width => 128,
- spectrum_scale => 50,
-});
-
my $log = Slim::Utils::Log->addLogCategory({
'category' => 'plugin.squeezeesp32',
'defaultLevel' => 'INFO',
@@ -23,10 +18,13 @@ sub initPlugin {
my $class = shift;
if ( main::WEBUI ) {
- require Plugins::SqueezeESP32::Settings;
- Plugins::SqueezeESP32::Settings->new;
+ require Plugins::SqueezeESP32::PlayerSettings;
+ Plugins::SqueezeESP32::PlayerSettings->new;
+
+ # require Plugins::SqueezeESP32::Settings;
+ # Plugins::SqueezeESP32::Settings->new;
}
-
+
$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");
diff --git a/plugin/SqueezeESP32/install.xml b/plugin/SqueezeESP32/install.xml
index 812417df..38f410ad 100644
--- a/plugin/SqueezeESP32/install.xml
+++ b/plugin/SqueezeESP32/install.xml
@@ -10,6 +10,6 @@
PLUGIN_SQUEEZEESP32
PLUGIN_SQUEEZEESP32_DESC
Plugins::SqueezeESP32::Plugin
- 0.21
+ 0.30
Philippe
diff --git a/plugin/SqueezeESP32/strings.txt b/plugin/SqueezeESP32/strings.txt
index d00ff9b5..1dd9e492 100644
--- a/plugin/SqueezeESP32/strings.txt
+++ b/plugin/SqueezeESP32/strings.txt
@@ -13,13 +13,43 @@ PLUGIN_SQUEEZEESP32_BANNER_TEXT
PLUGIN_SQUEEZEESP32_DESC
EN Adds a new player id (100) to enable display with SqueezeESP32
+PLUGIN_SQUEEZEESP32_PLAYERSETTINGS
+ EN Display (ESP32)
+
PLUGIN_SQUEEZEESP32_WIDTH
EN Screen width
+
+PLUGIN_SQUEEZEESP32_WIDTH_DESC
+ EN Width of the display in pixel as reported by the player
+
+PLUGIN_SQUEEZEESP32_SMALL_VU
+ EN Small VU size
+
+PLUGIN_SQUEEZEESP32_SMALL_VU_DESC
+ EN % of the display used for small VU (right-justified)
PLUGIN_SQUEEZEESP32_SPECTRUM_SCALE
- EN Spectrum scale
-
+ EN Spectrum scaling
+
PLUGIN_SQUEEZEESP32_SPECTRUM_SCALE_DESC
- EN Sets the scale factor % of spectrum visualizer by halves for better representation.
- EN For example, 50 means that 50% of spectrum is displayed in 1/2 of the screen, so it's linear...
+ EN % of Spectrum displayed in first half of the screen. For example, 50 means that 50% of spectrum is displayed in 1/2 of the screen
EN But 25 means that only 25% of spectrum is displayed in 1/2 of the screen, so it's a sort of log
+
+PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM
+ EN Small spectrum options
+
+PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_DESC
+ EN Size: % of the screen used by small spectrum
+ EN
Band factor: number of bands is the width of the spectrum screen divided by this factor
+
+PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_SIZE
+ EN Size
+
+PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_BAND
+ EN Band factor
+
+PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND
+ EN Full spectrum band factor
+
+PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND_DESC
+ EN The number of bands is the width of the screen divided by this factor
diff --git a/plugin/repo.xml b/plugin/repo.xml
index 91822b34..ddbdf68f 100644
--- a/plugin/repo.xml
+++ b/plugin/repo.xml
@@ -4,7 +4,7 @@
https://github.com/sle118/squeezelite-esp32
Philippe
- f1955a3c930a0c1809a1d2dac85970905c9b68a0
+ a110570f53f24c571492b13cf225cbfd1bdf9a52
philippe_44@outlook.com
SqueezeESP32 additional player id (100)
http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip