Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-cmake' into master-cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
sle118 committed Dec 21, 2020
2 parents 7c13c13 + 1a3c888 commit 0140305
Show file tree
Hide file tree
Showing 31 changed files with 194 additions and 55 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Expand Up @@ -18,8 +18,6 @@ RUN wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a
RUN tar -xzf xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
RUN rm xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz

# Patch I2S in esp-idf
RUN cp /workspace/squeezelite-esp32/idf-patch/i2s.c /workspace/esp-idf/components/driver/i2s.c
RUN rm -r /workspace/squeezelite-esp32
RUN mkdir /workspace/squeezelite-esp32

Expand Down
2 changes: 1 addition & 1 deletion build-scripts/I2S-4MFlash-sdkconfig.defaults
Expand Up @@ -457,9 +457,9 @@ CONFIG_LWIP_SO_REUSE=y
CONFIG_LWIP_SO_REUSE_RXTOALL=y
# CONFIG_LWIP_SO_RCVBUF is not set
# CONFIG_LWIP_IP_FRAG is not set
#CONFIG_LWIP_IP_REASSEMBLY is not set
# CONFIG_LWIP_STATS is not set
# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set
CONFIG_LWIP_IP_REASSEMBLY=y
CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
CONFIG_LWIP_GARP_TMR_INTERVAL=60
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/SqueezeAmp-sdkconfig.defaults
Expand Up @@ -457,7 +457,7 @@ CONFIG_LWIP_MAX_SOCKETS=16
# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
CONFIG_LWIP_SO_REUSE=y
CONFIG_LWIP_SO_REUSE_RXTOALL=y
#CONFIG_LWIP_IP_REASSEMBLY is not set
CONFIG_LWIP_IP_REASSEMBLY=y
CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
CONFIG_LWIP_GARP_TMR_INTERVAL=60
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32
Expand Down
1 change: 1 addition & 0 deletions components/squeezelite/controls.c
Expand Up @@ -279,6 +279,7 @@ static void notify(in_addr_t ip, u16_t hport, u16_t cport) {

if (connect(cli_sock, (struct sockaddr *) &addr, addrlen) < 0) {
LOG_ERROR("unable to connect to server %s:%hu with cli", inet_ntoa(server_ip), server_cport);
closesocket(cli_sock);
cli_sock = -1;
}

Expand Down
35 changes: 26 additions & 9 deletions components/squeezelite/display.c
Expand Up @@ -808,6 +808,8 @@ static void grfa_handler(u8_t *data, int len) {
artwork.y = htons(pkt->y);
} else if (artwork.size) GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK);

LOG_INFO("gfra en:%u x:%hu, y:%hu", artwork.enable, artwork.x, artwork.y);

// done in any case
return;
}
Expand Down Expand Up @@ -875,7 +877,7 @@ static void visu_update(void) {

// convert to dB (1 bit remaining for getting X²/N, 60dB dynamic starting from 0dBFS = 3 bits back-off)
for (int i = visu.n; --i >= 0;) {
visu.bars[i].current = visu.max * (0.01667f*10*log10f(0.0000001f + (visu.bars[i].current >> (visu_export.gain == FIXED_ONE ? 7 : 1))) - 0.2543f);
visu.bars[i].current = visu.max * (0.01667f*10*log10f(0.0000001f + (visu.bars[i].current >> (visu_export.gain == FIXED_ONE ? 8 : 1))) - 0.2543f);
if (visu.bars[i].current > visu.max) visu.bars[i].current = visu.max;
else if (visu.bars[i].current < 0) visu.bars[i].current = 0;
}
Expand Down Expand Up @@ -917,7 +919,7 @@ static void visu_update(void) {
}

// convert to dB and bars, same back-off
if (power) visu.bars[i].current = visu.max * (0.01667f*10*(log10f(power) - log10f(FFT_LEN/(visu_export.gain == FIXED_ONE ? 128 : 2)*2)) - 0.2543f);
if (power) visu.bars[i].current = visu.max * (0.01667f*10*(log10f(power) - log10f(FFT_LEN*(visu_export.gain == FIXED_ONE ? 256 : 2))) - 0.2543f);
if (visu.bars[i].current > visu.max) visu.bars[i].current = visu.max;
else if (visu.bars[i].current < 0) visu.bars[i].current = 0;
}
Expand Down Expand Up @@ -1042,7 +1044,7 @@ static void visu_handler( u8_t *data, int len) {

// little trick to clean the taller screens when switching visu
if (visu.row >= displayer.height) GDS_ClearExt(display, false, true, visu.col, visu.row, visu.col + visu.width - 1, visu.row + visu.height - 1);

if (visu.mode) {
// these will be overidden if necessary
visu.col = visu.border = 0;
Expand All @@ -1065,13 +1067,27 @@ static void visu_handler( u8_t *data, int len) {
bars = htonl(pkt->bars);
visu.spectrum_scale = htonl(pkt->spectrum_scale) / 100.;
} else {
// full screen visu, try to use bottom screen if available
// full screen visu, try to optimize orientation/shape
visu.width = htonl(pkt->full.width);
visu.height = GDS_GetHeight(display) > displayer.height ? GDS_GetHeight(display) - displayer.height : GDS_GetHeight(display);
visu.row = GDS_GetHeight(display) - visu.height;
visu.height = GDS_GetHeight(display);

// try to estimate if we should rotate visu
if (visu.height > displayer.height && visu.height > 2*visu.width) visu.rotate = true;
// do we have enough height to play with layout
if (GDS_GetHeight(display) > displayer.height) {
// by default, use up to the bottom of the display
visu.height -= displayer.height;
visu.row = displayer.height;

if (artwork.enable && artwork.y) {
// server sets width to artwork X offset to tell us to rotate
if (visu.width != artwork.x) {
visu.height = artwork.y - displayer.height;
if (visu.height <= 0) {
visu.height = displayer.height;
LOG_WARN("No room left for visualizer, disable it or increase artwork offset %d", artwork.y);
}
} else visu.rotate = true;
}
} else visu.row = 0;

// is this spectrum or analogue/digital
if ((visu.mode & ~VISU_ESP32) == VISU_SPECTRUM) {
Expand All @@ -1094,9 +1110,10 @@ static void visu_handler( u8_t *data, int len) {
visu.style = htonl(pkt->classical_vu.style);
if (visu.style) visu.row = visu.height - VU_HEIGHT;
}
if (bars > MAX_BARS) bars = MAX_BARS;
}

if (bars > MAX_BARS) bars = MAX_BARS;

// for rotate, swap width & height
if (visu.rotate) visu_fit(bars, visu.height, visu.width);
else visu_fit(bars, visu.width, visu.height);
Expand Down
4 changes: 2 additions & 2 deletions components/squeezelite/output_bt.c
Expand Up @@ -124,7 +124,7 @@ static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t g
int32_t output_bt_data(uint8_t *data, int32_t len) {
int32_t iframes = len / BYTES_PER_FRAME, start_timer = 0;

if (len < 0 || data == NULL || !running) {
if (iframes <= 0 || data == NULL || !running) {
return 0;
}

Expand All @@ -135,9 +135,9 @@ int32_t output_bt_data(uint8_t *data, int32_t len) {
// for us to send. (BTC_SBC_DEC_PCM_DATA_LEN * sizeof(OI_INT16) - availPcmBytes
SET_MIN_MAX(len,req);
TIME_MEASUREMENT_START(start_timer);
SET_MIN_MAX_SIZED(_buf_used(outputbuf),bt,outputbuf->size);

LOCK;
SET_MIN_MAX_SIZED(_buf_used(outputbuf),bt,outputbuf->size);
output.device_frames = 0;
output.updated = gettime_ms();
output.frames_played_dmp = output.frames_played;
Expand Down
8 changes: 4 additions & 4 deletions components/squeezelite/slimproto.c
Expand Up @@ -822,14 +822,14 @@ in_addr_t discover_server(char *default_server, int max) {
memset(&s, 0, sizeof(s));

if (sendto(disc_sock, buf, len, 0, (struct sockaddr *)&d, sizeof(d)) < 0) {
LOG_INFO("error sending disovery");
LOG_INFO("error sending discovery");
}

if (poll(&pollinfo, 1, 5000) == 1) {
char readbuf[32], *p;
char readbuf[64], *p;
socklen_t slen = sizeof(s);
memset(readbuf, 0, 32);
recvfrom(disc_sock, readbuf, 32 - 1, 0, (struct sockaddr *)&s, &slen);
memset(readbuf, 0, sizeof(readbuf));
recvfrom(disc_sock, readbuf, sizeof(readbuf) - 1, 0, (struct sockaddr *)&s, &slen);
LOG_INFO("got response from: %s:%d", inet_ntoa(s.sin_addr), ntohs(s.sin_port));

if ((p = strstr(readbuf, port_d)) != NULL) {
Expand Down
2 changes: 1 addition & 1 deletion components/wifi-manager/CMakeLists.txt
Expand Up @@ -3,7 +3,7 @@ set( WEBPACK_DIR webapp/webpack/dist )
idf_component_register( SRC_DIRS . webapp
INCLUDE_DIRS . webapp ${IDF_PATH}/components/esp_http_server/src ${IDF_PATH}/components/esp_http_server/src/port/esp32 ${IDF_PATH}/components/esp_http_server/src/util ${IDF_PATH}/components/esp_http_server/src/
REQUIRES squeezelite-ota json mdns
PRIV_REQUIRES tools services platform_config esp_common json newlib freertos spi_flash nvs_flash mdns pthread wpa_supplicant platform_console esp_http_server console driver_bt
PRIV_REQUIRES tools services platform_config esp_common json newlib freertos spi_flash nvs_flash mdns pthread wpa_supplicant platform_console esp_http_server console driver_bt
)


Expand Down
1 change: 0 additions & 1 deletion components/wifi-manager/webapp/.gitignore
@@ -1,5 +1,4 @@
node_modules
dist
.DS_Store
.idea
package-lock.json
4 changes: 2 additions & 2 deletions components/wifi-manager/webapp/webpack.h
Expand Up @@ -2,8 +2,8 @@
webpack_headers
Hash: e644c04d107606ae748d
Version: webpack 4.44.2
Time: 6267ms
Built at: 2020-12-21 10 h 59 min 46 s
Time: 6142ms
Built at: 2020-12-21 12 h 10 min 00 s
Asset Size Chunks Chunk Names
./js/index.e644c0.bundle.js 230 KiB 0 [emitted] [immutable] index
./js/index.e644c0.bundle.js.br 31.3 KiB [emitted]
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions components/wifi-manager/webapp/webpack/dist/index.html

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions components/wifi-manager/webapp/webpack/dist/sprite.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
47 changes: 35 additions & 12 deletions plugin/SqueezeESP32/Graphics.pm
Expand Up @@ -17,6 +17,17 @@ 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');
Expand All @@ -33,14 +44,16 @@ sub new {
$cprefs->init( {
width => 128,
small_VU => 15,
spectrum => { scale => 25,
small => { size => 25, band => 5.33 },
full => { band => 8 },
},
}
);

$display->init_accessor(
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
Expand Down Expand Up @@ -106,6 +119,16 @@ 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);
Expand All @@ -118,9 +141,9 @@ sub build_modes {
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 = $cprefs->get('spectrum');
my $small_spectrum_pos = { x => $width - int ($spectrum->{small}->{size} * $width / 100),
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),
Expand Down Expand Up @@ -224,7 +247,7 @@ my @extra = (
);

@modes = (@modes, @extra) if $cprefs->get('height') > 32;

return \@modes;
}

Expand Down
23 changes: 16 additions & 7 deletions plugin/SqueezeESP32/Player.pm
Expand Up @@ -91,16 +91,19 @@ sub init {
}

$client->SUPER::init(@_);
$client->config_artwork;
$client->send_equalizer;

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] } );

$prefs->client($client)->init( {
equalizer => [(0) x 10],
artwork => undef,
} );

$client->SUPER::initPrefs;
}

Expand Down Expand Up @@ -184,11 +187,13 @@ sub update_artwork {
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);
Expand Down Expand Up @@ -248,13 +253,17 @@ sub config_artwork {
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->pluginData('artwork_md5', '');
$client->SUPER::reconnect(@_);

$client->pluginData('artwork_md5', '');
$client->config_artwork;
$client->send_equalizer;
}

# Change the analog output mode between headphone and sub-woofer
Expand Down
24 changes: 16 additions & 8 deletions plugin/SqueezeESP32/PlayerSettings.pm
Expand Up @@ -43,29 +43,37 @@ sub handler {
if ($paramRef->{'saveSettings'}) {
if ($client->displayWidth) {
$cprefs->set('small_VU', $paramRef->{'pref_small_VU'} || 15);
my $spectrum = {
scale => $paramRef->{'pref_spectrum_scale'} || 25,
small => { size => $paramRef->{'pref_spectrum_small_size'} || 25,
band => $paramRef->{'pref_spectrum_small_band'} || 5.33 },
full => { band => $paramRef->{'pref_spectrum_full_band'} } || 8,
};

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'},
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);
$client->display->update;
# 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();
}

}

my $equalizer = $cprefs->get('equalizer');
Expand Down

0 comments on commit 0140305

Please sign in to comment.