mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-09 13:07:03 +03:00
merge changes from led_visu to v4.3
This commit is contained in:
@@ -106,6 +106,34 @@
|
||||
<hr>
|
||||
[% END %]
|
||||
|
||||
[% IF prefs.pref_led_config %]
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_LED_CONFIG" desc="PLUGIN_SQUEEZEESP32_LED_CONFIG_DESC" %]
|
||||
<!--<input type="text" readonly class="stdedit" name="pref_led_config" id="led_config" value="[% prefs.pref_led_config %]" size="3">-->
|
||||
<input type="hidden" name="pref_led_config" value="[% prefs.pref_led_config %]">
|
||||
[% prefs.pref_led_config %]
|
||||
[% END %]
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_LED_VISUALIZER" desc="PLUGIN_SQUEEZEESP32_LED_VISUALIZER_DESC" %]
|
||||
<select class="stdedit" name="pref_led_visualizer" id="led_visualizer">
|
||||
[% num = 1 %][% last = 1 %]
|
||||
[% FOREACH option = ledVisualModes.keys.nsort %]
|
||||
<option [% IF prefs.pref_led_visualizer == option %]selected [% ELSIF num == 1 && option == '-1' %]selected [% END %]value="[% option %]">[% ledVisualModes.$option %]</option>
|
||||
[%- END -%]
|
||||
</select>
|
||||
[% END %]
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_LED_BRIGHTNESS" desc="PLUGIN_SQUEEZEESP32_LED_BRIGHTNESS_DESC" %]
|
||||
<input type="text" class="stdedit sliderInput_0_255" name="pref_led_brightness" id="led_brightness" value="[% prefs.pref_led_brightness %]" size="2">
|
||||
[% END %]
|
||||
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_LED_DATA" desc="PLUGIN_SQUEEZEESP32_LED_DATA_DESC" %]
|
||||
<input type="button" name="led_data_send" onclick="SqueezeJS.Controller.request({params: ['[% playerid %]', ['dmx', document.getElementById('led_data_cmd').value, document.getElementById('led_data_x').value]] });" value="[% "PLUGIN_SQUEEZEESP32_LED_DATA_SEND" | string %]">
|
||||
[% "PLUGIN_SQUEEZEESP32_LED_DATA_X" | string %] 
|
||||
<input type="text" class="stdedit" name="pref_led_data_x" id="led_data_x" value="0" size="2">
|
||||
[% "PLUGIN_SQUEEZEESP32_LED_DATA_CMD" | string %] 
|
||||
<input type="text" class="stdedit" name="pref_led_data_cmd" id="led_data_cmd" value="80,0,0,0,80,0,0,0,80" size="50">
|
||||
[% END %]
|
||||
<hr>
|
||||
[% END %]
|
||||
|
||||
[% IF pref_equalizer %]
|
||||
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_EQUALIZER" desc="" %]
|
||||
<div>[% "PLUGIN_SQUEEZEESP32_EQUALIZER_SAVE" | string %]</div>
|
||||
|
||||
@@ -10,6 +10,7 @@ use Slim::Utils::Log;
|
||||
use Slim::Utils::Prefs;
|
||||
|
||||
use Plugins::SqueezeESP32::FirmwareHelper;
|
||||
use Plugins::SqueezeESP32::RgbLed;
|
||||
|
||||
my $sprefs = preferences('server');
|
||||
my $prefs = preferences('plugin.squeezeesp32');
|
||||
@@ -63,6 +64,10 @@ sub maxTreble { 20 }
|
||||
sub minTreble { -13 }
|
||||
sub maxBass { 20 }
|
||||
sub minBass { -13 }
|
||||
sub hasLED {
|
||||
my $client = shift;
|
||||
return $prefs->client($client)->get('led_config') || 0;
|
||||
}
|
||||
|
||||
sub init {
|
||||
my $client = shift;
|
||||
@@ -98,6 +103,7 @@ sub init {
|
||||
|
||||
$client->SUPER::init(@_);
|
||||
Plugins::SqueezeESP32::FirmwareHelper::init($client);
|
||||
Plugins::SqueezeESP32::RgbLed::init($client);
|
||||
|
||||
main::INFOLOG && $log->is_info && $log->info("SqueezeESP player connected: " . $client->id);
|
||||
}
|
||||
@@ -110,6 +116,9 @@ sub initPrefs {
|
||||
$prefs->client($client)->init( {
|
||||
equalizer => [(0) x 10],
|
||||
artwork => undef,
|
||||
led_config => 0,
|
||||
led_visualizer => 0,
|
||||
led_brightness => 20,
|
||||
} );
|
||||
|
||||
$prefs->setValidate({
|
||||
@@ -169,6 +178,9 @@ sub playerSettingsFrame {
|
||||
|
||||
main::INFOLOG && $log->is_info && $log->info("Setting player $value" . "x" . "$height for ", $client->name);
|
||||
}
|
||||
my $led_config = (unpack('Cnnn',$$data_ref))[3];
|
||||
$prefs->client($client)->set('led_config', $led_config);
|
||||
main::INFOLOG && $log->is_info && $led_config && $log->info("Setting led length $led_config for ", $client->name);
|
||||
}
|
||||
|
||||
$client->SUPER::playerSettingsFrame($data_ref);
|
||||
|
||||
@@ -7,6 +7,7 @@ use List::Util qw(first min max);
|
||||
|
||||
use Slim::Utils::Log;
|
||||
use Slim::Utils::Prefs;
|
||||
use Slim::Utils::Strings qw(string cstring);
|
||||
|
||||
my $sprefs = preferences('server');
|
||||
my $prefs = preferences('plugin.squeezeesp32');
|
||||
@@ -33,6 +34,7 @@ sub prefs {
|
||||
my ($class, $client) = @_;
|
||||
my @prefs;
|
||||
push @prefs, qw(width small_VU) if $client->displayWidth;
|
||||
push @prefs, qw(led_config led_visualizer led_brightness);# if $client->hasLED;
|
||||
return ($prefs->client($client), @prefs);
|
||||
}
|
||||
|
||||
@@ -86,6 +88,12 @@ sub handler {
|
||||
$cprefs->set('equalizer', $equalizer);
|
||||
$client->update_tones($equalizer);
|
||||
}
|
||||
|
||||
if ($client->hasLED) {
|
||||
$cprefs->set('led_visualizer', $paramRef->{'pref_led_visualizer'} || 0);
|
||||
$cprefs->set('led_brightness', $paramRef->{'pref_led_brightness'} || 20);
|
||||
Plugins::SqueezeESP32::RgbLed::updateLED($client);
|
||||
}
|
||||
}
|
||||
|
||||
if ($client->displayWidth) {
|
||||
@@ -95,6 +103,10 @@ sub handler {
|
||||
$paramRef->{'pref_artwork'} = $cprefs->get('artwork');
|
||||
}
|
||||
|
||||
if ($client->hasLED) {
|
||||
$paramRef->{'ledVisualModes'} = Plugins::SqueezeESP32::RgbLed::ledVisualModeOptions($client);
|
||||
}
|
||||
|
||||
$paramRef->{'pref_equalizer'} = $cprefs->get('equalizer') if $client->can('depth') && $client->depth == 16;
|
||||
$paramRef->{'player_ip'} = $client->ip;
|
||||
|
||||
|
||||
188
plugin/SqueezeESP32/RgbLed.pm
Normal file
188
plugin/SqueezeESP32/RgbLed.pm
Normal file
@@ -0,0 +1,188 @@
|
||||
package Plugins::SqueezeESP32::RgbLed;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Plugins::SqueezeESP32::RgbLed
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
L<Plugins::SqueezeESP32::RgbLed>
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use Slim::Utils::Strings qw(string cstring);
|
||||
|
||||
use Slim::Utils::Log;
|
||||
use Slim::Utils::Prefs;
|
||||
use Plugins::SqueezeESP32::Player
|
||||
|
||||
my $log = logger('player.RgbLed');
|
||||
|
||||
my $prefs = preferences('plugin.squeezeesp32');
|
||||
my $log = logger('plugin.squeezeesp32');
|
||||
|
||||
sub init {
|
||||
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['playlist'], ['open', 'pause', 'resume', 'stop', 'clear'] ]);
|
||||
|
||||
# register led visualizer comands to allow independant update and command line controls.
|
||||
Slim::Control::Request::addDispatch([ 'dmx', '_data', '_xoff'], [1, 0, 0, \&sendDMX]);
|
||||
Slim::Control::Request::addDispatch([ 'led_visual', '_mode', '_bright'], [1, 0, 0, \&setLEDVisu]);
|
||||
}
|
||||
|
||||
my $VISUALIZER_NONE = 0;
|
||||
my $VISUALIZER_VUMETER = 1;
|
||||
my $VISUALIZER_SPECTRUM_ANALYZER = 2;
|
||||
my $VISUALIZER_WAVEFORM = 3;
|
||||
my @ledvisualizers = (
|
||||
{ desc => ['BLANK'],
|
||||
params => [$VISUALIZER_NONE],
|
||||
},
|
||||
{ desc => ['VISUALIZER_ANALOG_VUMETER'],
|
||||
params => [$VISUALIZER_VUMETER, 0],
|
||||
},
|
||||
{ desc => ['VISUALIZER_DIGITAL_VUMETER'],
|
||||
params => [$VISUALIZER_VUMETER, 1],
|
||||
},
|
||||
{ desc => ['VISUALIZER_SPECTRUM_ANALYZER'],
|
||||
params => [$VISUALIZER_SPECTRUM_ANALYZER, 0],
|
||||
},
|
||||
{ desc => ['VISUALIZER_SPECTRUM_ANALYZER','2'],
|
||||
params => [$VISUALIZER_SPECTRUM_ANALYZER, 1],
|
||||
},
|
||||
{ desc => ['PLUGIN_SQUEEZEESP32_WAVEFORM'],
|
||||
params => [$VISUALIZER_WAVEFORM, 0],
|
||||
},
|
||||
{ desc => ['PLUGIN_SQUEEZEESP32_WAVEFORM','2'],
|
||||
params => [$VISUALIZER_WAVEFORM, 1],
|
||||
},
|
||||
);
|
||||
|
||||
my $nledvisualizers = $#ledvisualizers;
|
||||
|
||||
sub ledVisualizerModes {
|
||||
return \@ledvisualizers;
|
||||
}
|
||||
|
||||
sub ledVisualizerNModes {
|
||||
return $nledvisualizers;
|
||||
}
|
||||
|
||||
sub updateLED {
|
||||
my $client = shift;
|
||||
my $cprefs = $prefs->client($client);
|
||||
|
||||
my $visu = $cprefs->get('led_visualizer') || 0;
|
||||
my $bright = $cprefs->get('led_brightness') || 20;
|
||||
|
||||
$visu = 0 if ($visu < 0 || $visu > ledVisualizerNModes || !(Slim::Player::Source::playmode($client) eq 'play'));
|
||||
my $modes = ledVisualizerModes;
|
||||
my $params = $modes->[$visu]{'params'};
|
||||
my $data = pack('CCC', $params->[0], $params->[1], $bright);
|
||||
main::INFOLOG && $log->is_debug && $log->info("Sending visu mode $visu ", $client->name);
|
||||
|
||||
$client->sendFrame( ledv => \$data );
|
||||
}
|
||||
|
||||
sub ledVisualParams {
|
||||
my $client = shift;
|
||||
|
||||
my $visu = $prefs->client($client)->get('led_visualizer') || 0;
|
||||
|
||||
return $ledvisualizers[$visu]{params};
|
||||
}
|
||||
|
||||
sub ledVisualModeOptions {
|
||||
my $client = shift;
|
||||
|
||||
my $display = {
|
||||
'-1' => ' '
|
||||
};
|
||||
|
||||
my $modes = ledVisualizerModes;
|
||||
my $nmodes = ledVisualizerNModes;
|
||||
|
||||
for (my $i = 0; $i <= $nmodes; $i++) {
|
||||
|
||||
my $desc = $modes->[$i]{'desc'};
|
||||
|
||||
for (my $j = 0; $j < scalar @$desc; $j++) {
|
||||
|
||||
$display->{$i} .= ' ' if ($j > 0);
|
||||
$display->{$i} .= string(@{$desc}[$j]) || @{$desc}[$j];
|
||||
}
|
||||
}
|
||||
|
||||
return $display;
|
||||
}
|
||||
|
||||
sub sendDMX {
|
||||
my $request = shift;
|
||||
|
||||
# check this is the correct command.
|
||||
if ($request->isNotCommand([['dmx']])) {
|
||||
$request->setStatusBadDispatch();
|
||||
return;
|
||||
}
|
||||
|
||||
# get our parameters
|
||||
my $client = $request->client();
|
||||
|
||||
my $count = 0;
|
||||
my $outData;
|
||||
my @values = split(',', $request->getParam('_data') || '');
|
||||
foreach my $val (@values) {
|
||||
$outData .= pack ( 'C', $val);
|
||||
$count++;
|
||||
}
|
||||
$count /= 3;
|
||||
|
||||
my $data = pack('nn', $request->getParam('_xoff') || 0, $count ) . $outData;
|
||||
|
||||
# changed from dmxt to ledd (matches 'ledc' for tricolor led in receiver player)
|
||||
$client->sendFrame( ledd => \$data );
|
||||
}
|
||||
|
||||
sub setLEDVisu {
|
||||
my $request = shift;
|
||||
|
||||
# check this is the correct command.
|
||||
if ($request->isNotCommand([['led_visual']])) {
|
||||
$request->setStatusBadDispatch();
|
||||
return;
|
||||
}
|
||||
|
||||
my $client = $request->client();
|
||||
return if (!$client->hasLED);
|
||||
|
||||
my $cprefs = $prefs->client($client);
|
||||
|
||||
my $visu = $cprefs->get('led_visualizer') || 0;
|
||||
my $mode = $request->getParam('_mode') || -1;
|
||||
if ($mode == -1) {
|
||||
$visu+=1;
|
||||
} else {
|
||||
$visu = $mode;
|
||||
}
|
||||
$visu = 0 if ($visu < 0 || $visu > ledVisualizerNModes);
|
||||
$cprefs->set('led_visualizer', $visu);
|
||||
|
||||
my $bright = $request->getParam('_bright') || -1;
|
||||
if ($bright >= 0 && $bright < 256) {
|
||||
$cprefs->set('led_brightness', $bright);
|
||||
}
|
||||
|
||||
updateLED($client);
|
||||
}
|
||||
|
||||
sub onNotification {
|
||||
my $request = shift;
|
||||
my $client = $request->client || return;
|
||||
|
||||
foreach my $player ($client->syncGroupActiveMembers) {
|
||||
next unless $player->isa('Plugins::SqueezeESP32::Player');
|
||||
updateLED($player) if $player->hasLED;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -106,6 +106,44 @@ PLUGIN_SQUEEZEESP32_ARTWORK_X
|
||||
PLUGIN_SQUEEZEESP32_ARTWORK_Y
|
||||
EN Y
|
||||
|
||||
PLUGIN_SQUEEZEESP32_LED_CONFIG
|
||||
EN Led RGB Strip
|
||||
|
||||
PLUGIN_SQUEEZEESP32_LED_CONFIG_DESC
|
||||
EN Length of the Led strip reported by the player
|
||||
|
||||
PLUGIN_SQUEEZEESP32_LED_VISUALIZER
|
||||
EN Led Visualizer
|
||||
|
||||
PLUGIN_SQUEEZEESP32_LED_VISUALIZER_DESC
|
||||
EN Select Led Visualizer from the built in effects
|
||||
|
||||
PLUGIN_SQUEEZEESP32_LED_BRIGHTNESS
|
||||
EN Led Brghtness
|
||||
|
||||
PLUGIN_SQUEEZEESP32_LED_BRIGHTNESS_DESC
|
||||
EN Sets the brightness of the Led Visualizer effects
|
||||
|
||||
PLUGIN_SQUEEZEESP32_LED_DATA
|
||||
EN Led Test
|
||||
|
||||
PLUGIN_SQUEEZEESP32_LED_DATA_DESC
|
||||
EN Sends custom RGB data to the Led Strip.
|
||||
EN <br>Enter R,G,B values (comma delimited). Repeat RGB for multiple Led sequences. Use the Offset to specifiy the first LED of the sequence.
|
||||
EN <br>Use the Set button the transmit.
|
||||
|
||||
PLUGIN_SQUEEZEESP32_LED_DATA_SEND
|
||||
EN Set
|
||||
|
||||
PLUGIN_SQUEEZEESP32_LED_DATA_X
|
||||
EN Offset
|
||||
|
||||
PLUGIN_SQUEEZEESP32_LED_DATA_CMD
|
||||
EN Command
|
||||
|
||||
PLUGIN_SQUEEZEESP32_WAVEFORM
|
||||
EN Waveform Visualizer
|
||||
|
||||
PLUGIN_SQUEEZEESP32_EQUALIZER
|
||||
DE Grafischer Equalizer
|
||||
EN Graphic equalizer
|
||||
|
||||
Reference in New Issue
Block a user