mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-10 05:27:01 +03:00
remove plugin from master
This commit is contained in:
Binary file not shown.
@@ -1,237 +0,0 @@
|
||||
package Plugins::SqueezeESP32::FirmwareHelper;
|
||||
|
||||
use strict;
|
||||
|
||||
use File::Basename qw(basename);
|
||||
use File::Spec::Functions qw(catfile);
|
||||
use JSON::XS::VersionOneAndTwo;
|
||||
|
||||
use Slim::Utils::Log;
|
||||
use Slim::Utils::Prefs;
|
||||
|
||||
use constant FIRMWARE_POLL_INTERVAL => 3600 * (5 + rand());
|
||||
use constant GITHUB_RELEASES_URI => "https://api.github.com/repos/sle118/squeezelite-esp32/releases";
|
||||
use constant GITHUB_ASSET_URI => GITHUB_RELEASES_URI . "/assets/";
|
||||
use constant GITHUB_DOWNLOAD_URI => "https://github.com/sle118/squeezelite-esp32/releases/download/";
|
||||
my $FW_DOWNLOAD_ID_REGEX = qr|plugins/SqueezeESP32/firmware/(-?\d+)|;
|
||||
my $FW_DOWNLOAD_REGEX = qr|plugins/SqueezeESP32/firmware/([-a-z0-9-/.]+\.bin)$|i;
|
||||
my $FW_FILENAME_REGEX = qr/^squeezelite-esp32-.*\.bin(\.tmp)?$/;
|
||||
my $FW_TAG_REGEX = qr/\/(ESP32-A1S|SqueezeAmp|I2S-4MFlash)\.(16|32)\.(\d+)\.(.*)\//;
|
||||
|
||||
my $prefs = preferences('plugin.squeezeesp32');
|
||||
my $log = logger('plugin.squeezeesp32');
|
||||
|
||||
sub init {
|
||||
Slim::Web::Pages->addRawFunction($FW_DOWNLOAD_ID_REGEX, \&handleFirmwareDownload);
|
||||
Slim::Web::Pages->addRawFunction($FW_DOWNLOAD_REGEX, \&handleFirmwareDownloadDirect);
|
||||
|
||||
# start checking for firmware updates
|
||||
Slim::Utils::Timers::setTimer(undef, Time::HiRes::time() + 30 + rand(30), \&prefetchFirmware);
|
||||
}
|
||||
|
||||
sub prefetchFirmware {
|
||||
Slim::Utils::Timers::killTimers(undef, \&prefetchFirmware);
|
||||
my $releaseInfo = $prefs->get('lastReleaseTagUsed');
|
||||
|
||||
Slim::Networking::SimpleAsyncHTTP->new(
|
||||
sub {
|
||||
my $http = shift;
|
||||
my $content = eval { from_json( $http->content ) };
|
||||
|
||||
if (!$content || !ref $content) {
|
||||
$@ && $log->error("Failed to parse response: $@");
|
||||
}
|
||||
|
||||
my $regex = $releaseInfo->{model} . '\.' . $releaseInfo->{res} . '\.\d+\.' . $releaseInfo->{branch};
|
||||
my $url;
|
||||
foreach (@$content) {
|
||||
if ($_->{tag_name} =~ /$regex/ && $_->{assets} && ref $_->{assets}) {
|
||||
($url) = grep /\.bin$/, map {
|
||||
$_->{browser_download_url}
|
||||
} @{$_->{assets}};
|
||||
|
||||
last if $url;
|
||||
}
|
||||
}
|
||||
|
||||
downloadFirmwareFile(sub {
|
||||
main::INFOLOG && $log->is_info && $log->info("Pre-cached firmware file: " . $_[0]);
|
||||
}, sub {
|
||||
my ($http, $error, $url, $code) = @_;
|
||||
$error ||= ($http && $http->error) || 'unknown error';
|
||||
$url ||= ($http && $http->url) || 'no URL';
|
||||
|
||||
$log->error(sprintf("Failed to get firmware image from Github: %s (%s)", $error || $http->error, $url));
|
||||
}, $url) if $url && $url =~ /^https?/;
|
||||
|
||||
},
|
||||
sub {
|
||||
my ($http, $error) = @_;
|
||||
$log->error("Failed to get releases from Github: $error");
|
||||
},
|
||||
{
|
||||
timeout => 10,
|
||||
cache => 1,
|
||||
expires => 3600
|
||||
}
|
||||
)->get(GITHUB_RELEASES_URI) if $releaseInfo;
|
||||
|
||||
Slim::Utils::Timers::setTimer(undef, Time::HiRes::time() + FIRMWARE_POLL_INTERVAL, \&prefetchFirmware);
|
||||
}
|
||||
|
||||
sub handleFirmwareDownload {
|
||||
my ($httpClient, $response) = @_;
|
||||
|
||||
my $request = $response->request;
|
||||
|
||||
my $_errorDownloading = sub {
|
||||
_errorDownloading($httpClient, $response, @_);
|
||||
};
|
||||
|
||||
my $id;
|
||||
if (!defined $request || !(($id) = $request->uri =~ $FW_DOWNLOAD_ID_REGEX)) {
|
||||
return $_errorDownloading->(undef, 'Invalid request', $request->uri, 400);
|
||||
}
|
||||
|
||||
# this is the magic number used on the client to figure out whether the plugin does support download proxying
|
||||
if ($id == -99) {
|
||||
$response->code(204);
|
||||
$response->header('Access-Control-Allow-Origin' => '*');
|
||||
|
||||
$httpClient->send_response($response);
|
||||
return Slim::Web::HTTP::closeHTTPSocket($httpClient);
|
||||
}
|
||||
|
||||
Slim::Networking::SimpleAsyncHTTP->new(
|
||||
sub {
|
||||
my $http = shift;
|
||||
my $content = eval { from_json( $http->content ) };
|
||||
|
||||
if (!$content || !ref $content) {
|
||||
$@ && $log->error("Failed to parse response: $@");
|
||||
return $_errorDownloading->($http);
|
||||
}
|
||||
elsif (!$content->{browser_download_url} || !$content->{name}) {
|
||||
return $_errorDownloading->($http, 'No download URL found');
|
||||
}
|
||||
|
||||
downloadFirmwareFile(sub {
|
||||
my $firmwareFile = shift;
|
||||
$response->code(200);
|
||||
Slim::Web::HTTP::sendStreamingFile($httpClient, $response, 'application/octet-stream', $firmwareFile, undef, 1);
|
||||
}, $_errorDownloading, $content->{browser_download_url}, $content->{name});
|
||||
},
|
||||
$_errorDownloading,
|
||||
{
|
||||
timeout => 10,
|
||||
cache => 1,
|
||||
expires => 86400
|
||||
}
|
||||
)->get(GITHUB_ASSET_URI . $id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sub handleFirmwareDownloadDirect {
|
||||
my ($httpClient, $response) = @_;
|
||||
|
||||
my $request = $response->request;
|
||||
|
||||
my $_errorDownloading = sub {
|
||||
_errorDownloading($httpClient, $response, @_);
|
||||
};
|
||||
|
||||
my $path;
|
||||
if (!defined $request || !(($path) = $request->uri =~ $FW_DOWNLOAD_REGEX)) {
|
||||
return $_errorDownloading->(undef, 'Invalid request', $request->uri, 400);
|
||||
}
|
||||
|
||||
main::INFOLOG && $log->is_info && $log->info("Requesting firmware from: $path");
|
||||
|
||||
downloadFirmwareFile(sub {
|
||||
my $firmwareFile = shift;
|
||||
$response->code(200);
|
||||
Slim::Web::HTTP::sendStreamingFile($httpClient, $response, 'application/octet-stream', $firmwareFile, undef, 1);
|
||||
}, $_errorDownloading, GITHUB_DOWNLOAD_URI . $path);
|
||||
}
|
||||
|
||||
sub downloadFirmwareFile {
|
||||
my ($cb, $ecb, $url, $name) = @_;
|
||||
|
||||
# keep track of the last firmware we requested, to prefetch it in the future
|
||||
_getFirmwareTag($url);
|
||||
|
||||
$name ||= basename($url);
|
||||
|
||||
if ($name !~ $FW_FILENAME_REGEX) {
|
||||
return $ecb->(undef, 'Unexpected firmware image name: ' . $name, $url, 400);
|
||||
}
|
||||
|
||||
my $updatesDir = Slim::Utils::OSDetect::dirsFor('updates');
|
||||
my $firmwareFile = catfile($updatesDir, $name);
|
||||
Slim::Utils::Misc::deleteFiles($updatesDir, $FW_FILENAME_REGEX, $firmwareFile);
|
||||
|
||||
if (-f $firmwareFile) {
|
||||
main::INFOLOG && $log->is_info && $log->info("Found cached firmware file");
|
||||
return $cb->($firmwareFile);
|
||||
}
|
||||
|
||||
Slim::Networking::SimpleAsyncHTTP->new(
|
||||
sub {
|
||||
my $http = shift;
|
||||
|
||||
if ($http->code != 200 || !-e "$firmwareFile.tmp") {
|
||||
return $ecb->($http, $http->mess);
|
||||
}
|
||||
|
||||
rename "$firmwareFile.tmp", $firmwareFile or return $ecb->($http, "Unable to rename temporary $firmwareFile file" );
|
||||
|
||||
return $cb->($firmwareFile);
|
||||
},
|
||||
$ecb,
|
||||
{
|
||||
saveAs => "$firmwareFile.tmp",
|
||||
}
|
||||
)->get($url);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sub _getFirmwareTag {
|
||||
my ($url) = @_;
|
||||
|
||||
if (my ($model, $resolution, $version, $branch) = $url =~ $FW_TAG_REGEX) {
|
||||
my $releaseInfo = {
|
||||
model => $model,
|
||||
res => $resolution,
|
||||
version => $version,
|
||||
branch => $branch
|
||||
};
|
||||
|
||||
$prefs->set('lastReleaseTagUsed', $releaseInfo);
|
||||
|
||||
return $releaseInfo;
|
||||
}
|
||||
}
|
||||
|
||||
sub _errorDownloading {
|
||||
my ($httpClient, $response, $http, $error, $url, $code) = @_;
|
||||
|
||||
$error ||= ($http && $http->error) || 'unknown error';
|
||||
$url ||= ($http && $http->url) || 'no URL';
|
||||
$code ||= ($http && $http->code) || 500;
|
||||
|
||||
$log->error(sprintf("Failed to get data from Github: %s (%s)", $error || $http->error, $url));
|
||||
|
||||
$response->headers->remove_content_headers;
|
||||
$response->code($code);
|
||||
$response->content_type('text/plain');
|
||||
$response->header('Connection' => 'close');
|
||||
$response->content('');
|
||||
|
||||
$httpClient->send_response($response);
|
||||
Slim::Web::HTTP::closeHTTPSocket($httpClient);
|
||||
};
|
||||
|
||||
|
||||
1;
|
||||
@@ -1,254 +0,0 @@
|
||||
package Plugins::SqueezeESP32::Graphics;
|
||||
|
||||
use strict;
|
||||
|
||||
use base qw(Slim::Display::Squeezebox2);
|
||||
|
||||
use Slim::Utils::Prefs;
|
||||
use Slim::Utils::Log;
|
||||
|
||||
my $prefs = preferences('plugin.squeezeesp32');
|
||||
my $log = logger('plugin.squeezeesp32');
|
||||
|
||||
my $VISUALIZER_NONE = 0;
|
||||
my $VISUALIZER_VUMETER = 1;
|
||||
my $VISUALIZER_SPECTRUM_ANALYZER = 2;
|
||||
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');
|
||||
__PACKAGE__->mk_accessor('rw', qw(vfdmodel));
|
||||
}
|
||||
|
||||
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 => \%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
|
||||
# compromise
|
||||
vfdmodel => 'graphic-160x32',
|
||||
);
|
||||
|
||||
return $display;
|
||||
}
|
||||
|
||||
=comment
|
||||
sub modes {
|
||||
return \@modes;
|
||||
}
|
||||
=cut
|
||||
|
||||
sub nmodes {
|
||||
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.
|
||||
my $mode = 0;
|
||||
|
||||
if ( $display->showVisualizer() && !defined($client->modeParam('visu')) ) {
|
||||
my $cprefs = preferences('server')->client($client);
|
||||
$mode = $cprefs->get('playingDisplayModes')->[ $cprefs->get('playingDisplayMode') ];
|
||||
}
|
||||
|
||||
if ($display->widthOverride) {
|
||||
my $artwork = $prefs->client($client)->get('artwork');
|
||||
if ($artwork->{'enable'} && $artwork->{'y'} < 32 && ($client->isPlaying || $client->isPaused)) {
|
||||
return ($artwork->{x} || $display->widthOverride) + ($display->modes->[$mode || 0]{_width} || 0);
|
||||
} else {
|
||||
return $display->widthOverride + ($display->modes->[$mode || 0]{_width} || 0);
|
||||
}
|
||||
} else {
|
||||
return $display->modes->[$mode || 0]{width};
|
||||
}
|
||||
}
|
||||
|
||||
sub brightnessMap {
|
||||
return (0 .. 5);
|
||||
}
|
||||
|
||||
=comment
|
||||
sub bytesPerColumn {
|
||||
return 4;
|
||||
}
|
||||
=cut
|
||||
|
||||
# I don't think LMS renderer handles properly screens other than 32 pixels. It
|
||||
# seems that all we get is a 32 pixel-tall data with anything else padded to 0
|
||||
# i.e. if we try 64 pixels height, bytes 0..3 and 4..7 will contains the same
|
||||
# pattern than the 32 pixels version, where one would have expected bytes 4..7
|
||||
# to be empty
|
||||
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);
|
||||
|
||||
my $artwork = $cprefs->get('artwork');
|
||||
my $disp_width = $cprefs->get('width') || 128;
|
||||
|
||||
# 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 = sanitizeSpectrum($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'],
|
||||
bar => 0, secs => 0, width => $width,
|
||||
params => [$VISUALIZER_NONE] },
|
||||
# mode 1
|
||||
{ desc => ['PROGRESS_BAR'],
|
||||
bar => 1, secs => 0, width => $width,
|
||||
params => [$VISUALIZER_NONE] },
|
||||
# mode 2
|
||||
{ desc => ['ELAPSED'],
|
||||
bar => 0, secs => 1, width => $width,
|
||||
params => [$VISUALIZER_NONE] },
|
||||
# mode 3
|
||||
{ desc => ['ELAPSED', 'AND', 'PROGRESS_BAR'],
|
||||
bar => 1, secs => 1, width => $width,
|
||||
params => [$VISUALIZER_NONE] },
|
||||
# mode 4
|
||||
{ desc => ['REMAINING'],
|
||||
bar => 0, secs => -1, width => $width,
|
||||
params => [$VISUALIZER_NONE] },
|
||||
# mode 5
|
||||
{ desc => ['CLOCK'],
|
||||
bar => 0, secs => 0, width => $width, clock => 1,
|
||||
params => [$VISUALIZER_NONE] },
|
||||
# mode 6
|
||||
{ desc => ['SETUP_SHOWBUFFERFULLNESS'],
|
||||
bar => 0, secs => 0, width => $width, fullness => 1,
|
||||
params => [$VISUALIZER_NONE] },
|
||||
# mode 7
|
||||
{ desc => ['VISUALIZER_VUMETER_SMALL'],
|
||||
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_ESP32, $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 => -$small_spectrum_pos->{'width'},
|
||||
# extra parameters (width, height, col (< 0 = from right), row (< 0 = from bottom), left_space, #bars, scale)
|
||||
params => [$VISUALIZER_SPECTRUM_ANALYZER_ESP32, $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,
|
||||
params => [$VISUALIZER_VUMETER_ESP32, $width_low, 0] },
|
||||
# mode 10
|
||||
{ desc => ['VISUALIZER_ANALOG_VUMETER'],
|
||||
bar => 0, secs => 0, width => $width,
|
||||
params => [$VISUALIZER_VUMETER_ESP32, $width_low, 1] },
|
||||
# mode 11
|
||||
{ desc => ['VISUALIZER_SPECTRUM_ANALYZER'],
|
||||
bar => 0, secs => 0, width => $width,
|
||||
# extra parameters (bars)
|
||||
params => [$VISUALIZER_SPECTRUM_ANALYZER_ESP32, $width_low, int ($width/$spectrum->{full}->{band}), $spectrum->{scale}] },
|
||||
);
|
||||
|
||||
my @extra = (
|
||||
# mode E1
|
||||
{ desc => ['VISUALIZER_VUMETER', 'AND', 'ELAPSED'],
|
||||
bar => 0, secs => 1, width => $width,
|
||||
params => [$VISUALIZER_VUMETER_ESP32, $width_low, 0] },
|
||||
# mode E2
|
||||
{ desc => ['VISUALIZER_ANALOG_VUMETER', 'AND', 'ELAPSED'],
|
||||
bar => 0, secs => 1, width => $width,
|
||||
params => [$VISUALIZER_VUMETER_ESP32, $width_low, 1] },
|
||||
# mode E3
|
||||
{ desc => ['VISUALIZER_SPECTRUM_ANALYZER', 'AND', 'ELAPSED'],
|
||||
bar => 0, secs => 1, width => $width,
|
||||
# extra parameters (bars)
|
||||
params => [$VISUALIZER_SPECTRUM_ANALYZER_ESP32, $width_low, int ($width/$spectrum->{full}->{band}), $spectrum->{scale}] },
|
||||
# mode E4
|
||||
{ desc => ['VISUALIZER_VUMETER', 'AND', 'REMAINING'],
|
||||
bar => 0, secs => -1, width => $width,
|
||||
params => [$VISUALIZER_VUMETER_ESP32, $width_low, 0] },
|
||||
# mode E5
|
||||
{ desc => ['VISUALIZER_ANALOG_VUMETER', 'AND', 'REMAINING'],
|
||||
bar => 0, secs => -1, width => $width,
|
||||
params => [$VISUALIZER_VUMETER_ESP32, $width_low, 1] },
|
||||
# mode E6
|
||||
{ desc => ['VISUALIZER_SPECTRUM_ANALYZER', 'AND', 'REMAINING'],
|
||||
bar => 0, secs => -1, width => $width,
|
||||
# extra parameters (bars)
|
||||
params => [$VISUALIZER_SPECTRUM_ANALYZER_ESP32, $width_low, int ($width/$spectrum->{full}->{band}), $spectrum->{scale}] },
|
||||
# mode E7
|
||||
{ desc => ['VISUALIZER_VUMETER', 'AND', 'PROGRESS_BAR', 'AND', 'REMAINING'],
|
||||
bar => 1, secs => -1, width => $width,
|
||||
params => [$VISUALIZER_VUMETER_ESP32, $width_low, 0] },
|
||||
# mode E8
|
||||
{ desc => ['VISUALIZER_ANALOG_VUMETER', 'AND', 'PROGRESS_BAR', 'AND', 'REMAINING'],
|
||||
bar => 1, secs => -1, width => $width,
|
||||
params => [$VISUALIZER_VUMETER_ESP32, $width_low, 1] },
|
||||
# mode E9
|
||||
{ desc => ['VISUALIZER_SPECTRUM_ANALYZER', 'AND', 'PROGRESS_BAR', 'AND', 'REMAINING'],
|
||||
bar => 1, secs => -1, width => $width,
|
||||
# extra parameters (bars)
|
||||
params => [$VISUALIZER_SPECTRUM_ANALYZER_ESP32, $width_low, int ($width/$spectrum->{full}->{band}), $spectrum->{scale}] },
|
||||
);
|
||||
|
||||
@modes = (@modes, @extra) if $cprefs->get('height') > 32;
|
||||
|
||||
return \@modes;
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,106 +0,0 @@
|
||||
[% PROCESS settings/header.html %]
|
||||
|
||||
[% IF prefs.pref_width %]
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_WIDTH" desc="PLUGIN_SQUEEZEESP32_WIDTH_DESC" %]
|
||||
<!--<input type="text" readonly class="stdedit" name="pref_width" id="width" value="[% prefs.pref_width %]" size="3">-->
|
||||
<input type="hidden" name="pref_width" value="[% prefs.pref_width %]">
|
||||
[% prefs.pref_width %]
|
||||
[% END %]
|
||||
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_SMALL_VU" desc="PLUGIN_SQUEEZEESP32_SMALL_VU_DESC" %]
|
||||
<input type="number" min="10" max= "50" step="5"class="stdedit" name="pref_small_VU" id="small_VU" value="[% prefs.pref_small_VU %]" 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="spectrum_scale" value="[% pref_spectrum.scale %]" size="3">
|
||||
[% END %]
|
||||
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM" desc="PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_DESC" %]
|
||||
[% "PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_SIZE" | string %] 
|
||||
<input type="number" min="10" max= "50" step="5"class="stdedit" name="pref_spectrum_small_size" id="spectrum_small_size" value="[% pref_spectrum.small.size %]" size="3">
|
||||
[% "PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_BAND" | string %] 
|
||||
<input type="text" class="stdedit" name="pref_spectrum_small_band" id="spectrum_small_band" value="[% pref_spectrum.small.band %]" size="3">
|
||||
[% END %]
|
||||
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND" desc="PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND_DESC" %]
|
||||
<input type="text" class="stdedit" name="pref_spectrum_full_band" id="spectrum_full_band" value="[% pref_spectrum.full.band %]" size="3">
|
||||
[% END %]
|
||||
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_ARTWORK" desc="PLUGIN_SQUEEZEESP32_ARTWORK_DESC" %]
|
||||
[% "PLUGIN_SQUEEZEESP32_ARTWORK_ENABLE" | string %] 
|
||||
<input type="checkbox" name="pref_artwork_enable" [% IF pref_artwork.enable %] checked [% END %]>
|
||||
[% "PLUGIN_SQUEEZEESP32_ARTWORK_X" | string %] 
|
||||
<input type="text" class="stdedit" name="pref_artwork_x" id="artwork_x" value="[% pref_artwork.x %]" size="2">
|
||||
[% "PLUGIN_SQUEEZEESP32_ARTWORK_Y" | string %] 
|
||||
<input type="text" class="stdedit" name="pref_artwork_y" id="artwork_y" value="[% pref_artwork.y %]" size="2">
|
||||
[% END %]
|
||||
|
||||
<hr>
|
||||
[% END %]
|
||||
|
||||
[% IF pref_equalizer %]
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_EQUALIZER" desc="" %]
|
||||
<div>[% "PLUGIN_SQUEEZEESP32_EQUALIZER_SAVE" | string %]</div>
|
||||
[% END %]
|
||||
|
||||
<script TYPE="text/javascript">
|
||||
if (Ext) {
|
||||
Ext.onReady(function () {
|
||||
new Ext.util.TaskRunner().start({
|
||||
run: checkEq,
|
||||
interval: 1000
|
||||
});
|
||||
});
|
||||
|
||||
function checkEq() {
|
||||
var eqValues = [];
|
||||
this.lastValues = this.lastValues || [];
|
||||
|
||||
for (var x = 0; x < 10; x++) {
|
||||
eqValues[x] = Ext.get('pref_equalizer.' + x).dom.value || 0;
|
||||
}
|
||||
|
||||
if (eqValues.join() != this.lastValues.join()) {
|
||||
this.lastValues = eqValues;
|
||||
SqueezeJS.Controller.request({
|
||||
params: ['[% playerid %]', ['squeezeesp32', 'seteq', eqValues.join()]]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
[% WRAPPER settingSection %]
|
||||
[% WRAPPER settingGroup title='31Hz' desc="" %]
|
||||
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.0" id="pref_equalizer.0" value="[% pref_equalizer.0 %]" size="2"">
|
||||
[% END %]
|
||||
[% WRAPPER settingGroup title='62Hz' desc="" %]
|
||||
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.1" id="pref_equalizer.1" value="[% pref_equalizer.1 %]" size="2">
|
||||
[% END %]
|
||||
[% WRAPPER settingGroup title='125Hz' desc="" %]
|
||||
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.2" id="pref_equalizer.2" value="[% pref_equalizer.2 %]" size="2">
|
||||
[% END %]
|
||||
[% WRAPPER settingGroup title='250Hz' desc="" %]
|
||||
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.3" id="pref_equalizer.3" value="[% pref_equalizer.3 %]" size="2">
|
||||
[% END %]
|
||||
[% WRAPPER settingGroup title='500Hz' desc="" %]
|
||||
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.4" id="pref_equalizer.4" value="[% pref_equalizer.4 %]" size="2">
|
||||
[% END %]
|
||||
[% WRAPPER settingGroup title='1kHz' desc="" %]
|
||||
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.5" id="pref_equalizer.5" value="[% pref_equalizer.5 %]" size="2">
|
||||
[% END %]
|
||||
[% WRAPPER settingGroup title='2kHz' desc="" %]
|
||||
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.6" id="pref_equalizer.6" value="[% pref_equalizer.6 %]" size="2">
|
||||
[% END %]
|
||||
[% WRAPPER settingGroup title='4kHz' desc="" %]
|
||||
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.7" id="pref_equalizer.7" value="[% pref_equalizer.7 %]" size="2">
|
||||
[% END %]
|
||||
[% WRAPPER settingGroup title='8kHz' desc="" %]
|
||||
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.8" id="pref_equalizer.8" value="[% pref_equalizer.8 %]" size="2">
|
||||
[% END %]
|
||||
[% WRAPPER settingGroup title='16kHz' desc="" %]
|
||||
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.9" id="pref_equalizer.9" value="[% pref_equalizer.9 %]" size="2">
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% PROCESS settings/footer.html %]
|
||||
@@ -1,351 +0,0 @@
|
||||
package Plugins::SqueezeESP32::Player;
|
||||
|
||||
use strict;
|
||||
use base qw(Slim::Player::SqueezePlay);
|
||||
|
||||
use Digest::MD5 qw(md5);
|
||||
use List::Util qw(min);
|
||||
|
||||
use Slim::Utils::Log;
|
||||
use Slim::Utils::Prefs;
|
||||
|
||||
my $sprefs = preferences('server');
|
||||
my $prefs = preferences('plugin.squeezeesp32');
|
||||
my $log = logger('plugin.squeezeesp32');
|
||||
|
||||
{
|
||||
__PACKAGE__->mk_accessor('rw', qw(tone_update depth));
|
||||
}
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $client = $class->SUPER::new(@_);
|
||||
$client->init_accessor(
|
||||
tone_update => 0,
|
||||
);
|
||||
return $client;
|
||||
}
|
||||
|
||||
our $defaultPrefs = {
|
||||
'analogOutMode' => 0,
|
||||
'bass' => 0,
|
||||
'treble' => 0,
|
||||
'lineInAlwaysOn' => 0,
|
||||
'lineInLevel' => 50,
|
||||
'menuItem' => [qw(
|
||||
NOW_PLAYING
|
||||
BROWSE_MUSIC
|
||||
RADIO
|
||||
PLUGIN_MY_APPS_MODULE_NAME
|
||||
PLUGIN_APP_GALLERY_MODULE_NAME
|
||||
FAVORITES
|
||||
GLOBAL_SEARCH
|
||||
PLUGIN_LINE_IN
|
||||
PLUGINS
|
||||
SETTINGS
|
||||
SQUEEZENETWORK_CONNECT
|
||||
)],
|
||||
};
|
||||
|
||||
my $handlersAdded;
|
||||
|
||||
sub model { 'squeezeesp32' }
|
||||
sub modelName { 'SqueezeESP32' }
|
||||
|
||||
sub hasScrolling { 1 }
|
||||
sub hasIR { 1 }
|
||||
# TODO: add in settings when ready
|
||||
sub hasLineIn { 0 }
|
||||
sub hasHeadSubOut { 1 }
|
||||
sub maxTreble { 20 }
|
||||
sub minTreble { -13 }
|
||||
sub maxBass { 20 }
|
||||
sub minBass { -13 }
|
||||
|
||||
sub init {
|
||||
my $client = shift;
|
||||
my ($id, $caps) = @_;
|
||||
|
||||
my ($depth) = $caps =~ /Depth=(\d+)/;
|
||||
$client->depth($depth || 16);
|
||||
|
||||
if (!$handlersAdded) {
|
||||
|
||||
# Add a handler for line-in/out status changes
|
||||
Slim::Networking::Slimproto::addHandler( LIOS => \&lineInOutStatus );
|
||||
|
||||
# Create a new event for sending LIOS updates
|
||||
Slim::Control::Request::addDispatch(
|
||||
['lios', '_state'],
|
||||
[1, 0, 0, undef],
|
||||
);
|
||||
|
||||
Slim::Control::Request::addDispatch(
|
||||
['lios', 'linein', '_state'],
|
||||
[1, 0, 0, undef],
|
||||
);
|
||||
|
||||
Slim::Control::Request::addDispatch(
|
||||
['lios', 'lineout', '_state'],
|
||||
[1, 0, 0, undef],
|
||||
);
|
||||
|
||||
$handlersAdded = 1;
|
||||
|
||||
}
|
||||
|
||||
$client->SUPER::init(@_);
|
||||
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],
|
||||
artwork => undef,
|
||||
} );
|
||||
|
||||
$client->SUPER::initPrefs;
|
||||
}
|
||||
|
||||
sub power {
|
||||
my $client = shift;
|
||||
my $on = shift;
|
||||
|
||||
my $res = $client->SUPER::power($on, @_);
|
||||
return $res unless defined $on;
|
||||
|
||||
if ($on) {
|
||||
$client->update_artwork(1);
|
||||
} else {
|
||||
$client->clear_artwork(1);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
# Allow the player to define it's display width (and probably more)
|
||||
sub playerSettingsFrame {
|
||||
my $client = shift;
|
||||
my $data_ref = shift;
|
||||
|
||||
my $value;
|
||||
my $id = unpack('C', $$data_ref);
|
||||
|
||||
# New SETD command 0xfe for display width & height
|
||||
if ($id == 0xfe) {
|
||||
$value = (unpack('Cn', $$data_ref))[1];
|
||||
if ($value > 100 && $value < 400) {
|
||||
$prefs->client($client)->set('width', $value);
|
||||
|
||||
my $height = (unpack('Cnn', $$data_ref))[2];
|
||||
$prefs->client($client)->set('height', $height || 0);
|
||||
|
||||
$client->display->modes($client->display->build_modes);
|
||||
$client->display->widthOverride(1, $value);
|
||||
$client->update;
|
||||
|
||||
main::INFOLOG && $log->is_info && $log->info("Setting player $value" . "x" . "$height for ", $client->name);
|
||||
}
|
||||
}
|
||||
|
||||
$client->SUPER::playerSettingsFrame($data_ref);
|
||||
}
|
||||
|
||||
sub bass {
|
||||
my ($client, $new) = @_;
|
||||
my $value = $client->SUPER::bass($new);
|
||||
|
||||
$client->update_equalizer($value, [2, 1, 3]) if defined $new;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
sub treble {
|
||||
my ($client, $new) = @_;
|
||||
my $value = $client->SUPER::treble($new);
|
||||
|
||||
$client->update_equalizer($value, [8, 9, 7]) if defined $new;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
sub send_equalizer {
|
||||
my ($client, $equalizer) = @_;
|
||||
|
||||
$equalizer ||= $prefs->client($client)->get('equalizer') || [(0) x 10];
|
||||
my $size = @$equalizer;
|
||||
my $data = pack("c[$size]", @{$equalizer});
|
||||
$client->sendFrame( eqlz => \$data );
|
||||
}
|
||||
|
||||
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 {
|
||||
my $client = shift;
|
||||
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);
|
||||
|
||||
send_artwork($client, undef, \$body) if $body;
|
||||
}
|
||||
|
||||
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 && !$params->{'force'};
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
sub clear_artwork {
|
||||
my ($client, $force, $from) = @_;
|
||||
|
||||
my $artwork = $prefs->client($client)->get('artwork');
|
||||
|
||||
if ($artwork && $artwork->{'enable'}) {
|
||||
main::INFOLOG && $log->is_info && $log->info("artwork stop/clear " . ($from || ""));
|
||||
$client->pluginData('artwork_md5', '');
|
||||
# refresh screen and disable artwork when artwork was full screen (hack)
|
||||
if ((!$artwork->{'x'} && !$artwork->{'y'}) || $force) {
|
||||
$client->sendFrame(grfa => \("\x00"x4));
|
||||
$client->display->update;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub config_artwork {
|
||||
my ($client) = @_;
|
||||
|
||||
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->SUPER::reconnect(@_);
|
||||
|
||||
$client->pluginData('artwork_md5', '');
|
||||
$client->config_artwork;
|
||||
$client->send_equalizer;
|
||||
}
|
||||
|
||||
# Change the analog output mode between headphone and sub-woofer
|
||||
# If no mode is specified, the value of the client's analogOutMode preference is used.
|
||||
# Otherwise the mode is temporarily changed to the given value without altering the preference.
|
||||
sub setAnalogOutMode {
|
||||
my $client = shift;
|
||||
# 0 = headphone (internal speakers off), 1 = sub out,
|
||||
# 2 = always on (internal speakers on), 3 = always off
|
||||
my $mode = shift;
|
||||
|
||||
if (! defined $mode) {
|
||||
$mode = $sprefs->client($client)->get('analogOutMode');
|
||||
}
|
||||
|
||||
my $data = pack('C', $mode);
|
||||
$client->sendFrame('audo', \$data);
|
||||
}
|
||||
|
||||
# LINE_IN 0x01
|
||||
# LINE_OUT 0x02
|
||||
# HEADPHONE 0x04
|
||||
|
||||
sub lineInConnected {
|
||||
my $state = Slim::Networking::Slimproto::voltage(shift) || return 0;
|
||||
return $state & 0x01 || 0;
|
||||
}
|
||||
|
||||
sub lineOutConnected {
|
||||
my $state = Slim::Networking::Slimproto::voltage(shift) || return 0;
|
||||
return $state & 0x02 || 0;
|
||||
}
|
||||
|
||||
sub lineInOutStatus {
|
||||
my ( $client, $data_ref ) = @_;
|
||||
|
||||
my $state = unpack 'n', $$data_ref;
|
||||
|
||||
my $oldState = {
|
||||
in => $client->lineInConnected(),
|
||||
out => $client->lineOutConnected(),
|
||||
};
|
||||
|
||||
Slim::Networking::Slimproto::voltage( $client, $state );
|
||||
|
||||
Slim::Control::Request::notifyFromArray( $client, [ 'lios', $state ] );
|
||||
|
||||
if ($oldState->{in} != $client->lineInConnected()) {
|
||||
Slim::Control::Request::notifyFromArray( $client, [ 'lios', 'linein', $client->lineInConnected() ] );
|
||||
if ( Slim::Utils::PluginManager->isEnabled('Slim::Plugin::LineIn::Plugin')) {
|
||||
Slim::Plugin::LineIn::Plugin::lineInItem($client, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldState->{out} != $client->lineOutConnected()) {
|
||||
Slim::Control::Request::notifyFromArray( $client, [ 'lios', 'lineout', $client->lineOutConnected() ] );
|
||||
}
|
||||
}
|
||||
|
||||
sub voltage {
|
||||
my $voltage = Slim::Networking::Slimproto::voltage(shift) || return 0;
|
||||
return sprintf("%.2f", ($voltage >> 4) / 128);
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,101 +0,0 @@
|
||||
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;
|
||||
push @prefs, qw(width small_VU) if $client->displayWidth;
|
||||
return ($prefs->client($client), @prefs);
|
||||
}
|
||||
|
||||
sub handler {
|
||||
my ($class, $client, $paramRef) = @_;
|
||||
|
||||
my ($cprefs, @prefs) = $class->prefs($client);
|
||||
|
||||
if ($paramRef->{'saveSettings'}) {
|
||||
if ($client->displayWidth) {
|
||||
$cprefs->set('small_VU', $paramRef->{'pref_small_VU'} || 15);
|
||||
|
||||
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'} 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);
|
||||
# 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($client->depth == 16) {
|
||||
my $equalizer = $cprefs->get('equalizer');
|
||||
for my $i (0 .. $#{$equalizer}) {
|
||||
$equalizer->[$i] = $paramRef->{"pref_equalizer.$i"} || 0;
|
||||
}
|
||||
$cprefs->set('equalizer', $equalizer);
|
||||
$client->update_tones($equalizer);
|
||||
}
|
||||
}
|
||||
|
||||
if ($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');
|
||||
$paramRef->{'pref_artwork'} = $cprefs->get('artwork');
|
||||
}
|
||||
|
||||
$paramRef->{'pref_equalizer'} = $cprefs->get('equalizer') if $client->depth == 16;
|
||||
|
||||
return $class->SUPER::handler($client, $paramRef);
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,106 +0,0 @@
|
||||
package Plugins::SqueezeESP32::Plugin;
|
||||
|
||||
use strict;
|
||||
|
||||
use base qw(Slim::Plugin::Base);
|
||||
|
||||
use Slim::Utils::Prefs;
|
||||
use Slim::Utils::Log;
|
||||
use Slim::Web::ImageProxy;
|
||||
|
||||
use Plugins::SqueezeESP32::FirmwareHelper;
|
||||
|
||||
my $prefs = preferences('plugin.squeezeesp32');
|
||||
|
||||
my $log = Slim::Utils::Log->addLogCategory({
|
||||
'category' => 'plugin.squeezeesp32',
|
||||
'defaultLevel' => 'INFO',
|
||||
'description' => 'PLUGIN_SQUEEZEESP32',
|
||||
});
|
||||
|
||||
# migrate 'eq' pref, as that's a reserved word and could cause problems in the future
|
||||
$prefs->migrateClient(1, sub {
|
||||
my ($cprefs, $client) = @_;
|
||||
$cprefs->set('equalizer', $cprefs->get('eq'));
|
||||
$cprefs->remove('eq');
|
||||
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');
|
||||
|
||||
sub initPlugin {
|
||||
my $class = shift;
|
||||
|
||||
if ( main::WEBUI ) {
|
||||
require Plugins::SqueezeESP32::PlayerSettings;
|
||||
Plugins::SqueezeESP32::PlayerSettings->new;
|
||||
|
||||
# require Plugins::SqueezeESP32::Settings;
|
||||
# Plugins::SqueezeESP32::Settings->new;
|
||||
}
|
||||
|
||||
$class->SUPER::initPlugin(@_);
|
||||
# no name can be a subset of others due to a bug in addPlayerClass
|
||||
Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32-basic', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' });
|
||||
Slim::Networking::Slimproto::addPlayerClass($class, 101, 'squeezeesp32-graphic', { client => 'Plugins::SqueezeESP32::Player', display => 'Slim::Display::NoDisplay' });
|
||||
main::INFOLOG && $log->is_info && $log->info("Added class 100 and 101 for SqueezeESP32");
|
||||
|
||||
# register a command to set the EQ - without saving the values! Send params as single comma separated list of values
|
||||
Slim::Control::Request::addDispatch(['squeezeesp32', 'seteq', '_eq'], [1, 0, 0, \&setEQ]);
|
||||
|
||||
# Note for some forgetful know-it-all: we need to wrap the callback to make it unique. Otherwise subscriptions would overwrite each other.
|
||||
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['newmetadata'] ] );
|
||||
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['playlist'], ['open', 'newsong'] ]);
|
||||
Slim::Control::Request::subscribe( \&onStopClear, [ ['playlist'], ['stop', 'clear'] ]);
|
||||
|
||||
Plugins::SqueezeESP32::FirmwareHelper->init();
|
||||
}
|
||||
|
||||
sub onStopClear {
|
||||
my $request = shift;
|
||||
my $client = $request->client || return;
|
||||
|
||||
if ($client->isa('Plugins::SqueezeESP32::Player')) {
|
||||
$client->clear_artwork(0, $request->getRequestString());
|
||||
}
|
||||
}
|
||||
|
||||
sub onNotification {
|
||||
my $request = shift;
|
||||
my $client = $request->client || return;
|
||||
|
||||
foreach my $player ($client->syncGroupActiveMembers) {
|
||||
next unless $player->isa('Plugins::SqueezeESP32::Player');
|
||||
$player->update_artwork;
|
||||
}
|
||||
}
|
||||
|
||||
sub setEQ {
|
||||
my $request = shift;
|
||||
|
||||
# check this is the correct command.
|
||||
if ($request->isNotCommand([['squeezeesp32'],['seteq']])) {
|
||||
$request->setStatusBadDispatch();
|
||||
return;
|
||||
}
|
||||
|
||||
# get our parameters
|
||||
my $client = $request->client();
|
||||
my @eqParams = split(/,/, $request->getParam('_eq') || '');
|
||||
|
||||
for (my $x = 0; $x < 10; $x++) {
|
||||
$eqParams[$x] ||= 0;
|
||||
}
|
||||
|
||||
$client->send_equalizer(\@eqParams);
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,12 +0,0 @@
|
||||
package Plugins::SqueezeESP32::Text;
|
||||
|
||||
use strict;
|
||||
|
||||
use base qw(Slim::Display::Text);
|
||||
|
||||
# we don't want the special Noritake codes
|
||||
sub vfdmodel {
|
||||
return 'squeezeslave';
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version='1.0' standalone='yes'?>
|
||||
<extensions>
|
||||
<defaultState>enabled</defaultState>
|
||||
<email>philippe_44@outlook.com</email>
|
||||
<targetApplication>
|
||||
<minVersion>7.9</minVersion>
|
||||
<maxVersion>*</maxVersion>
|
||||
<id>SlimServer</id>
|
||||
</targetApplication>
|
||||
<name>PLUGIN_SQUEEZEESP32</name>
|
||||
<description>PLUGIN_SQUEEZEESP32_DESC</description>
|
||||
<module>Plugins::SqueezeESP32::Plugin</module>
|
||||
<version>0.310</version>
|
||||
<creator>Philippe</creator>
|
||||
</extensions>
|
||||
@@ -1,104 +0,0 @@
|
||||
WELCOME_TO_SQUEEZEESP32
|
||||
DE Willkommen bei SqueezeESP32!
|
||||
EN Welcome to SqueezeESP32
|
||||
|
||||
PLUGIN_SQUEEZEESP32
|
||||
EN SqueezeESP32
|
||||
|
||||
PLUGIN_SQUEEZEESP32_BANNER
|
||||
DE WARNUNG
|
||||
EN WARNING
|
||||
|
||||
PLUGIN_SQUEEZEESP32_BANNER_TEXT
|
||||
DE Sie müssen LMS neu starten, damit diese Einstellungen aktiv werden
|
||||
EN You need to restart LMS for these parameters to be taken into account
|
||||
|
||||
PLUGIN_SQUEEZEESP32_DESC
|
||||
DE Konfiguriert eine neue Player ID (100), um Displays an SqueezeESP32 zu unterstützen
|
||||
EN Adds a new player id (100) to enable display with SqueezeESP32
|
||||
|
||||
PLUGIN_SQUEEZEESP32_PLAYERSETTINGS
|
||||
DE ESP32 Einstellungen
|
||||
EN ESP32 settings
|
||||
|
||||
PLUGIN_SQUEEZEESP32_WIDTH
|
||||
DE Displaybreite
|
||||
EN Screen width
|
||||
|
||||
PLUGIN_SQUEEZEESP32_WIDTH_DESC
|
||||
DE Breite des Displays in Pixeln, wie es vom Player angegeben wird
|
||||
EN Width of the display in pixel as reported by the player
|
||||
|
||||
PLUGIN_SQUEEZEESP32_SMALL_VU
|
||||
DE Kleine VU Grösse
|
||||
EN Small VU size
|
||||
|
||||
PLUGIN_SQUEEZEESP32_SMALL_VU_DESC
|
||||
DE Prozentsatz des Displays, das für den kleinen VU verwendet wird (rechts ausgerichtet)
|
||||
EN % of the display used for small VU (right-justified)
|
||||
|
||||
PLUGIN_SQUEEZEESP32_SPECTRUM_SCALE
|
||||
DE Spektrum-Skalierung
|
||||
EN Spectrum scaling
|
||||
|
||||
PLUGIN_SQUEEZEESP32_SPECTRUM_SCALE_DESC
|
||||
DE Prozentsatz des Spektrums, das in der ersten Hälfte des Bildschirms angezeigt wird. Z.B. 50 bedeutet 50% des Spektrums wird auf dem halben Bildschirm angezeigt.
|
||||
DE Aber 25 bedeutet, dass nur 25% des Spektrums auf dem halben Bildschirm angezeigt wird.
|
||||
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
|
||||
DE Kleines Spektrum
|
||||
EN Small spectrum options
|
||||
|
||||
PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_DESC
|
||||
DE <i>Grösse</i>: Prozentsatz des Displays, das für das kleine Spektrum verwendet wird.
|
||||
DE <br><i>Band-Faktor</i>: die Anzahl Bänder ist die Breite der <b>Spektrumsanzeige</b> dividiert durch diesen Faktor.
|
||||
EN <i>Size</i>: % of the screen used by small spectrum
|
||||
EN <br><i>Band factor</i>: number of bands is the width of the <b>spectrum</b> screen divided by this factor
|
||||
|
||||
PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_SIZE
|
||||
DE Grösse
|
||||
EN Size
|
||||
|
||||
PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_BAND
|
||||
DE Band-Faktor
|
||||
EN Band factor
|
||||
|
||||
PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND
|
||||
DE Band-Faktor für ganzes Spektrum
|
||||
EN Full spectrum band factor
|
||||
|
||||
PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND_DESC
|
||||
DE Die Anzahl Bänder ist die Breite der Anzeige dividiert durch diesen Faktor.
|
||||
EN The number of bands is the width of the screen divided by this factor
|
||||
|
||||
PLUGIN_SQUEEZEESP32_ARTWORK
|
||||
DE Plattenhüllen
|
||||
EN 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 <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
|
||||
EN Enable
|
||||
|
||||
PLUGIN_SQUEEZEESP32_ARTWORK_X
|
||||
EN X
|
||||
|
||||
PLUGIN_SQUEEZEESP32_ARTWORK_Y
|
||||
EN Y
|
||||
|
||||
PLUGIN_SQUEEZEESP32_EQUALIZER
|
||||
DE Parametrischer Equalizer
|
||||
EN Parametric equalizer
|
||||
|
||||
PLUGIN_SQUEEZEESP32_EQUALIZER_SAVE
|
||||
DE Bitte speichern Sie die Equalizer Einstellungen, falls das Gerät diese dauerhaft verwenden soll. Ansonsten werden sie beim nächsten Start zurückgesetzt.
|
||||
EN Don't forget to save the Equalizer settings if you want them to stick. Otherwise they'll be reset next time you restart the device.
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version='1.0' standalone='yes'?>
|
||||
<extensions>
|
||||
<plugins>
|
||||
<plugin version="0.310" name="SqueezeESP32" minTarget="7.9" maxTarget="*">
|
||||
<plugin version="0.350" name="SqueezeESP32" minTarget="7.9" maxTarget="*">
|
||||
<link>https://github.com/sle118/squeezelite-esp32</link>
|
||||
<creator>Philippe</creator>
|
||||
<sha>39e70a87ce903cc8651e6b3bb2dc86609a8d0541</sha>
|
||||
<sha>9f495e973ccb573bf671187dc0a49c510124fbcc</sha>
|
||||
<email>philippe_44@outlook.com</email>
|
||||
<desc lang="EN">SqueezeESP32 additional player id (100)</desc>
|
||||
<url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url>
|
||||
<desc lang="EN">SqueezeESP32 additional player id (100/101)</desc>
|
||||
<url>http://github.com/sle118/squeezelite-esp32/raw/master-cmake/plugin/SqueezeESP32.zip</url>
|
||||
<title lang="EN">SqueezeESP32</title>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
Reference in New Issue
Block a user