Merge remote-tracking branch 'origin/master' into master-cmake

This commit is contained in:
Sebastien
2020-04-20 09:16:00 -04:00
11 changed files with 107 additions and 70 deletions

View File

@@ -23,6 +23,7 @@
#include "esp_pthread.h" #include "esp_pthread.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_timer.h" #include "esp_timer.h"
#include "esp_wifi.h"
void get_mac(u8_t mac[]) { void get_mac(u8_t mac[]) {
esp_read_mac(mac, ESP_MAC_WIFI_STA); esp_read_mac(mac, ESP_MAC_WIFI_STA);
@@ -58,3 +59,11 @@ void embedded_init(void) {
sb_controls_init(); sb_controls_init();
if (sb_display_init()) custom_player_id = 100; if (sb_display_init()) custom_player_id = 100;
} }
u16_t get_RSSI(void) {
wifi_ap_record_t wifidata;
esp_wifi_sta_get_ap_info(&wifidata);
// we'll assume dBm, -30 to -100
if (wifidata.primary != 0) return 100 + wifidata.rssi + 30;
else return 0xffff;
}

View File

@@ -62,6 +62,9 @@ void register_external(void);
void deregister_external(void); void deregister_external(void);
void decode_restore(int external); void decode_restore(int external);
// must provide or define as 0xffff
u16_t get_RSSI(void);
// to be defined to nothing if you don't want to support these // to be defined to nothing if you don't want to support these
extern struct visu_export_s { extern struct visu_export_s {
pthread_mutex_t mutex; pthread_mutex_t mutex;

View File

@@ -45,11 +45,18 @@ void equalizer_open(u32_t sample_rate) {
equalizer.update = false; equalizer.update = false;
if (equalizer.handle) { if (equalizer.handle) {
LOG_INFO("equalizer initialized"); bool active = false;
for (int i = 0; i < EQ_BANDS; i++) { for (int i = 0; i < EQ_BANDS; i++) {
esp_equalizer_set_band_value(equalizer.handle, equalizer.gain[i], i, 0); esp_equalizer_set_band_value(equalizer.handle, equalizer.gain[i], i, 0);
esp_equalizer_set_band_value(equalizer.handle, equalizer.gain[i], i, 1); esp_equalizer_set_band_value(equalizer.handle, equalizer.gain[i], i, 1);
active |= equalizer.gain[i] != 0;
} }
// do not activate equalizer if all gain are 0
if (!active) equalizer_close();
LOG_INFO("equalizer initialized %u", active);
} else { } else {
LOG_WARN("can't init equalizer"); LOG_WARN("can't init equalizer");
} }

View File

@@ -183,7 +183,11 @@ static void sendSTAT(const char *event, u32_t server_timestamp) {
packN(&pkt.stream_buffer_size, status.stream_size); packN(&pkt.stream_buffer_size, status.stream_size);
packN(&pkt.bytes_received_H, (u64_t)status.stream_bytes >> 32); packN(&pkt.bytes_received_H, (u64_t)status.stream_bytes >> 32);
packN(&pkt.bytes_received_L, (u64_t)status.stream_bytes & 0xffffffff); packN(&pkt.bytes_received_L, (u64_t)status.stream_bytes & 0xffffffff);
#if EMBEDDED
packn(&pkt.signal_strength, get_RSSI());
#else
pkt.signal_strength = 0xffff; pkt.signal_strength = 0xffff;
#endif
packN(&pkt.jiffies, now); packN(&pkt.jiffies, now);
packN(&pkt.output_buffer_size, status.output_size); packN(&pkt.output_buffer_size, status.output_size);
packN(&pkt.output_buffer_fullness, status.output_full); packN(&pkt.output_buffer_fullness, status.output_full);

Binary file not shown.

View File

@@ -1,39 +1,42 @@
[% PROCESS settings/header.html %] [% PROCESS settings/header.html %]
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_WIDTH" desc="PLUGIN_SQUEEZEESP32_WIDTH_DESC" %] [% IF prefs.pref_width %]
<!--<input type="text" readonly class="stdedit" name="pref_width" id="width" value="[% prefs.pref_width %]" size="3">--> [% WRAPPER setting title="PLUGIN_SQUEEZEESP32_WIDTH" desc="PLUGIN_SQUEEZEESP32_WIDTH_DESC" %]
[% prefs.pref_width %] <!--<input type="text" readonly class="stdedit" name="pref_width" id="width" value="[% prefs.pref_width %]" size="3">-->
[% END %] [% prefs.pref_width %]
[% END %]
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_SMALL_VU" desc="PLUGIN_SQUEEZEESP32_SMALL_VU_DESC" %] [% 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"> <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 %] [% END %]
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_SPECTRUM_SCALE" desc="PLUGIN_SQUEEZEESP32_SPECTRUM_SCALE_DESC" %] [% 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="[% prefs.pref_spectrum.scale %]" size="3"> <input type="number" min="10" max= "50" step="5" class="stdedit" name="pref_spectrum_scale" id="spectrum_scale" value="[% prefs.pref_spectrum.scale %]" size="3">
[% END %] [% END %]
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM" desc="PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_DESC" %] [% WRAPPER setting title="PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM" desc="PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_DESC" %]
[% "PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_SIZE" | string %]&nbsp [% "PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_SIZE" | string %]&nbsp
<input type="number" min="10" max= "50" step="5"class="stdedit" name="pref_spectrum_small_size" id="spectrum_small_size" value="[% prefs.pref_spectrum.small.size %]" size="3"> <input type="number" min="10" max= "50" step="5"class="stdedit" name="pref_spectrum_small_size" id="spectrum_small_size" value="[% prefs.pref_spectrum.small.size %]" size="3">
[% "PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_BAND" | string %]&nbsp [% "PLUGIN_SQUEEZEESP32_SMALL_SPECTRUM_BAND" | string %]&nbsp
<input type="text" class="stdedit" name="pref_spectrum_small_band" id="spectrum_small_band" value="[% prefs.pref_spectrum.small.band %]" size="3"> <input type="text" class="stdedit" name="pref_spectrum_small_band" id="spectrum_small_band" value="[% prefs.pref_spectrum.small.band %]" size="3">
[% END %] [% END %]
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND" desc="PLUGIN_SQUEEZEESP32_FULL_SPECTRUM_BAND_DESC" %] [% 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="[% prefs.pref_spectrum.full.band %]" size="3"> <input type="text" class="stdedit" name="pref_spectrum_full_band" id="spectrum_full_band" value="[% prefs.pref_spectrum.full.band %]" size="3">
[% END %] [% END %]
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_ARTWORK" desc="PLUGIN_SQUEEZEESP32_ARTWORK_DESC" %] [% WRAPPER setting title="PLUGIN_SQUEEZEESP32_ARTWORK" desc="PLUGIN_SQUEEZEESP32_ARTWORK_DESC" %]
[% "PLUGIN_SQUEEZEESP32_ARTWORK_ENABLE" | string %]&nbsp [% "PLUGIN_SQUEEZEESP32_ARTWORK_ENABLE" | string %]&nbsp
<input type="checkbox" name="pref_artwork_enable" [% IF prefs.pref_artwork.enable %] checked [% END %]> <input type="checkbox" name="pref_artwork_enable" [% IF prefs.pref_artwork.enable %] checked [% END %]>
[% "PLUGIN_SQUEEZEESP32_ARTWORK_X" | string %]&nbsp [% "PLUGIN_SQUEEZEESP32_ARTWORK_X" | string %]&nbsp
<input type="text" class="stdedit" name="pref_artwork_x" id="artwork_x" value="[% prefs.pref_artwork.x %]" size="2"> <input type="text" class="stdedit" name="pref_artwork_x" id="artwork_x" value="[% prefs.pref_artwork.x %]" size="2">
[% "PLUGIN_SQUEEZEESP32_ARTWORK_Y" | string %]&nbsp [% "PLUGIN_SQUEEZEESP32_ARTWORK_Y" | string %]&nbsp
<input type="text" class="stdedit" name="pref_artwork_y" id="artwork_y" value="[% prefs.pref_artwork.y %]" size="2"> <input type="text" class="stdedit" name="pref_artwork_y" id="artwork_y" value="[% prefs.pref_artwork.y %]" size="2">
[% END %] [% END %]
<hr> <hr>
[% END %]
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_EQUALIZER" desc="" %] [% WRAPPER setting title="PLUGIN_SQUEEZEESP32_EQUALIZER" desc="" %]
[% END %] [% END %]

View File

@@ -15,12 +15,6 @@ sub hasIR { 0 }
sub init { sub init {
my $client = shift; my $client = shift;
$prefs->client($client)->init( {
eq => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
}
);
$client->SUPER::init(@_); $client->SUPER::init(@_);
Plugins::SqueezeESP32::Plugin::config_artwork($client); Plugins::SqueezeESP32::Plugin::config_artwork($client);
} }
@@ -61,7 +55,6 @@ sub reconnect {
my $client = shift; my $client = shift;
$client->pluginData('artwork_md5', ''); $client->pluginData('artwork_md5', '');
$client->SUPER::reconnect(@_); $client->SUPER::reconnect(@_);
Plugins::SqueezeESP32::Plugin::send_equalizer($client);
} }
1; 1;

View File

@@ -21,7 +21,7 @@ sub needsClient {
sub validFor { sub validFor {
my ($class, $client) = @_; my ($class, $client) = @_;
return $client->model eq 'squeezeesp32' && $client->displayWidth; return $client->model eq 'squeezeesp32';
} }
sub page { sub page {
@@ -40,45 +40,51 @@ sub handler {
my ($cprefs, @prefs) = $class->prefs($client); my ($cprefs, @prefs) = $class->prefs($client);
if ($paramRef->{'saveSettings'}) { if ($paramRef->{'saveSettings'}) {
$cprefs->set('small_VU', $paramRef->{'pref_small_VU'}); if ($client->displayWidth) {
my $spectrum = { scale => $paramRef->{'pref_spectrum_scale'}, $cprefs->set('small_VU', $paramRef->{'pref_small_VU'});
small => { size => $paramRef->{'pref_spectrum_small_size'}, my $spectrum = { scale => $paramRef->{'pref_spectrum_scale'},
band => $paramRef->{'pref_spectrum_small_band'} }, small => { size => $paramRef->{'pref_spectrum_small_size'},
full => { band => $paramRef->{'pref_spectrum_full_band'} }, band => $paramRef->{'pref_spectrum_small_band'} },
}; full => { band => $paramRef->{'pref_spectrum_full_band'} },
$cprefs->set('spectrum', $spectrum); };
my $artwork = { enable => $paramRef->{'pref_artwork_enable'}, $cprefs->set('spectrum', $spectrum);
x => $paramRef->{'pref_artwork_x'},
y => $paramRef->{'pref_artwork_y'}, my $artwork = { enable => $paramRef->{'pref_artwork_enable'},
}; x => $paramRef->{'pref_artwork_x'},
$cprefs->set('artwork', $artwork); y => $paramRef->{'pref_artwork_y'},
$client->display->modes($client->display->build_modes); };
$client->display->update; $cprefs->set('artwork', $artwork);
$client->display->modes($client->display->build_modes);
$client->display->update;
# force update or disable artwork
if ($artwork->{'enable'}) {
Plugins::SqueezeESP32::Plugin::update_artwork($client, 1);
} else {
Plugins::SqueezeESP32::Plugin::config_artwork($client);
}
}
my $eq = $cprefs->get('eq'); my $eq = $cprefs->get('eq');
for my $i (0 .. $#{$eq}) { for my $i (0 .. $#{$eq}) {
$eq->[$i] = $paramRef->{"pref_eq.$i"}; $eq->[$i] = $paramRef->{"pref_eq.$i"};
} }
$cprefs->set('eq', $eq); $cprefs->set('eq', $eq);
Plugins::SqueezeESP32::Plugin::send_equalizer($client); Plugins::SqueezeESP32::Plugin::send_equalizer($client);
# force update or disable artwork
if ($artwork->{'enable'}) {
Plugins::SqueezeESP32::Plugin::update_artwork($client, 1);
} else {
Plugins::SqueezeESP32::Plugin::config_artwork($client);
}
} }
# as there is nothing captured, we need to re-set these variables if ($client->displayWidth) {
$paramRef->{'pref_width'} = $cprefs->get('width'); # 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
# 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');
}
# 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
# 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');
$paramRef->{'pref_eq'} = $cprefs->get('eq'); $paramRef->{'pref_eq'} = $cprefs->get('eq');
return $class->SUPER::handler($client, $paramRef); return $class->SUPER::handler($client, $paramRef);

View File

@@ -36,6 +36,7 @@ sub initPlugin {
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['newmetadata'] ] ); Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['newmetadata'] ] );
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['playlist'], ['open', 'newsong'] ]); Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['playlist'], ['open', 'newsong'] ]);
Slim::Control::Request::subscribe( \&onStopClear, [ ['playlist'], ['stop', 'clear'] ]); Slim::Control::Request::subscribe( \&onStopClear, [ ['playlist'], ['stop', 'clear'] ]);
Slim::Control::Request::subscribe( \&onPlayer,[ ['client'], [ 'new', 'reconnect' ] ] );
} }
sub onStopClear { sub onStopClear {
@@ -50,6 +51,17 @@ sub onStopClear {
} }
} }
sub onPlayer {
my $request = shift;
my $client = $request->client;
if ($client->model eq 'squeezeesp32') {
$prefs->client($client)->init( {
eq => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
} );
Plugins::SqueezeESP32::Plugin::send_equalizer($client);
}
}
sub onNotification { sub onNotification {
my $request = shift; my $request = shift;

View File

@@ -10,6 +10,6 @@
<name>PLUGIN_SQUEEZEESP32</name> <name>PLUGIN_SQUEEZEESP32</name>
<description>PLUGIN_SQUEEZEESP32_DESC</description> <description>PLUGIN_SQUEEZEESP32_DESC</description>
<module>Plugins::SqueezeESP32::Plugin</module> <module>Plugins::SqueezeESP32::Plugin</module>
<version>0.81</version> <version>0.82</version>
<creator>Philippe</creator> <creator>Philippe</creator>
</extensions> </extensions>

View File

@@ -1,10 +1,10 @@
<?xml version='1.0' standalone='yes'?> <?xml version='1.0' standalone='yes'?>
<extensions> <extensions>
<plugins> <plugins>
<plugin version="0.81" name="SqueezeESP32" minTarget="7.5" maxTarget="*"> <plugin version="0.82" name="SqueezeESP32" minTarget="7.5" maxTarget="*">
<link>https://github.com/sle118/squeezelite-esp32</link> <link>https://github.com/sle118/squeezelite-esp32</link>
<creator>Philippe</creator> <creator>Philippe</creator>
<sha>dcd91eaeb065cf3e90e964ea40a883ed5480093e</sha> <sha>55eb14f12790d71306d143689d9b3d47f9820731</sha>
<email>philippe_44@outlook.com</email> <email>philippe_44@outlook.com</email>
<desc lang="EN">SqueezeESP32 additional player id (100)</desc> <desc lang="EN">SqueezeESP32 additional player id (100)</desc>
<url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url> <url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url>