diff --git a/components/display/core/gds.c b/components/display/core/gds.c index d315b027..26242a60 100644 --- a/components/display/core/gds.c +++ b/components/display/core/gds.c @@ -60,6 +60,10 @@ void GDS_Clear( struct GDS_Device* Device, int Color ) { } void GDS_ClearWindow( struct GDS_Device* Device, int x1, int y1, int x2, int y2, int Color ) { + // -1 means up to width/height + if (x2 < 0) x2 = Device->Width - 1; + if (y2 < 0) y2 = Device->Height - 1; + // driver can provide own optimized clear window if (Device->ClearWindow) { Device->ClearWindow( Device, x1, y1, x2, y2, Color ); diff --git a/components/display/core/gds_image.c b/components/display/core/gds_image.c index a5919f74..ebd274e1 100644 --- a/components/display/core/gds_image.c +++ b/components/display/core/gds_image.c @@ -218,8 +218,10 @@ bool GDS_DrawJPEG( struct GDS_Device* Device, uint8_t *Source, int x, int y, int // then place it if (Fit & GDS_IMAGE_CENTER_X) Context.XOfs = (Device->Width + x - Context.Width) / 2; + else if (Fit & GDS_IMAGE_RIGHT) Context.XOfs = Device->Width - Context.Width; if (Fit & GDS_IMAGE_CENTER_Y) Context.YOfs = (Device->Height + y - Context.Height) / 2; - + else if (Fit & GDS_IMAGE_BOTTOM) Context.YOfs = Device->Height - Context.Height; + Context.XMin = x - Context.XOfs; Context.YMin = y - Context.YOfs; diff --git a/components/display/core/gds_image.h b/components/display/core/gds_image.h index fa87001a..0becd94a 100644 --- a/components/display/core/gds_image.h +++ b/components/display/core/gds_image.h @@ -9,8 +9,11 @@ struct GDS_Device; enum { GDS_RGB565, GDS_RGB555, GDS_RGB444 }; -#define GDS_IMAGE_TOP 0x00 +#define GDS_IMAGE_LEFT 0x00 #define GDS_IMAGE_CENTER_X 0x01 +#define GDS_IMAGE_RIGHT 0x04 +#define GDS_IMAGE_TOP 0x00 +#define GDS_IMAGE_BOTTOM 0x08 #define GDS_IMAGE_CENTER_Y 0x02 #define GDS_IMAGE_CENTER (GDS_IMAGE_CENTER_X | GDS_IMAGE_CENTER_Y) #define GDS_IMAGE_FIT 0x10 diff --git a/components/squeezelite/display.c b/components/squeezelite/display.c index 555ee983..c85cf4a2 100644 --- a/components/squeezelite/display.c +++ b/components/squeezelite/display.c @@ -62,7 +62,9 @@ struct grfg_packet { struct grfa_packet { char opcode[4]; - u32_t length; + u32_t length; + u16_t x; + u16_t y; u32_t offset; }; @@ -140,6 +142,7 @@ static struct scroller_s { static struct { u8_t *data; u32_t size; + u16_t x, y; } artwork; #define MAX_BARS 32 @@ -313,7 +316,7 @@ static void send_server(void) { pkt_header.length = htonl(sizeof(pkt_header) - 8); pkt_header.mode = ANIC_resp; - send_packet((u8_t *)&pkt_header, sizeof(pkt_header)); + send_packet((uint8_t *) &pkt_header, sizeof(pkt_header)); ANIC_resp = ANIM_NONE; } @@ -321,18 +324,22 @@ static void send_server(void) { if (SETD_width) { struct SETD_header pkt_header; - LOG_INFO("sending width %u", SETD_width); - memset(&pkt_header, 0, sizeof(pkt_header)); memcpy(&pkt_header.opcode, "SETD", 4); pkt_header.id = 0xfe; // id 0xfe is width S:P:Squeezebox2 - pkt_header.length = htonl(sizeof(pkt_header) + 2 - 8); + pkt_header.length = htonl(sizeof(pkt_header) + 4 - 8); + + u16_t height = GDS_GetHeight(display); + LOG_INFO("sending dimension %ux%u", SETD_width, height); SETD_width = htons(SETD_width); - send_packet((u8_t *)&pkt_header, sizeof(pkt_header)); - send_packet((uint8_t*) &SETD_width, 2); - + height = htons(height); + + send_packet((uint8_t *) &pkt_header, sizeof(pkt_header)); + send_packet((uint8_t *) &SETD_width, 2); + send_packet((uint8_t *) &height, 2); + SETD_width = 0; } @@ -661,10 +668,10 @@ static void grfa_handler(u8_t *data, int len) { int offset = htonl(pkt->offset); int length = htonl(pkt->length); - LOG_INFO("gfra l:%u o:%u s:%u", length, offset, size); - // new grfa artwork, allocate memory if (!offset) { + artwork.x = htons(pkt->x); + artwork.y = htons(pkt->y); if (artwork.data) free(artwork.data); artwork.data = malloc(length); artwork.size = 0; @@ -674,8 +681,14 @@ static void grfa_handler(u8_t *data, int len) { memcpy(artwork.data + offset, data + sizeof(struct grfa_packet), size); artwork.size += size; if (artwork.size == length) { - GDS_DrawJPEG(display, artwork.data, 0, 32, GDS_IMAGE_CENTER); - } + GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK); + GDS_DrawJPEG(display, artwork.data, artwork.x, artwork.y, artwork.y < 32 ? (GDS_IMAGE_RIGHT | GDS_IMAGE_TOP) : GDS_IMAGE_CENTER); + free(artwork.data); + artwork.data = NULL; + artwork.size = 0; + } + + LOG_INFO("gfra l:%u x:%hu, y:%hu, o:%u s:%u", length, artwork.x, artwork.y, offset, size); } /**************************************************************************************** @@ -820,7 +833,7 @@ static void visu_handler( u8_t *data, int len) { visu.mode = pkt->which; // little trick to clean the taller screens when switching visu - if (visu.row >= SB_HEIGHT) GDS_ClearExt(display, false, true, visu.col, visu.row, visu.col + visu.width - 1, visu.row - visu.height - 1); + if (visu.row >= SB_HEIGHT) GDS_ClearExt(display, false, true, visu.col, visu.row, visu.col + visu.width - 1, visu.row + visu.height - 1); if (visu.mode) { if (pkt->count >= 4) { @@ -878,7 +891,7 @@ static void visu_handler( u8_t *data, int len) { // reset bars maximum for (int i = visu.n; --i >= 0;) visu.bars[i].max = 0; - GDS_ClearExt(display, false, true, visu.col, visu.row, visu.col + visu.width - 1, visu.row - visu.height - 1); + GDS_ClearExt(display, false, true, visu.col, visu.row, visu.col + visu.width - 1, visu.row + visu.height - 1); LOG_INFO("Visualizer with %u bars of width %d:%d:%d:%d (%w:%u,h:%u,c:%u,r:%u,s:%.02f)", visu.n, visu.bar_border, visu.bar_width, visu.bar_gap, visu.border, visu.width, visu.height, visu.col, visu.row, visu.spectrum_scale); } else { diff --git a/plugin/SqueezeESP32.zip b/plugin/SqueezeESP32.zip index 871345cc..2a3b0eeb 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 225c907b..a8dead59 100644 --- a/plugin/SqueezeESP32/Graphics.pm +++ b/plugin/SqueezeESP32/Graphics.pm @@ -71,7 +71,12 @@ sub displayWidth { } if ($display->widthOverride) { - return $display->widthOverride + ($display->modes->[$mode || 0]{_width} || 0); + my $artwork = $prefs->client($client)->get('artwork'); + if ($artwork->{'enable'} && $artwork->{'y'} < 32) { + return $artwork->{x} + ($display->modes->[$mode || 0]{_width} || 0); + } else { + return $display->widthOverride + ($display->modes->[$mode || 0]{_width} || 0); + } } else { return $display->modes->[$mode || 0]{width}; } @@ -101,9 +106,21 @@ sub build_modes { my $cprefs = $prefs->client($client); my $width = shift || $cprefs->get('width') || 128; + my $artwork = $cprefs->get('artwork'); + + # if artwork is in main display, reduce width + $width = $artwork->{'x'} - 1 if $artwork->{'enable'} && $artwork->{y} < 32; + my $small_VU = $cprefs->get('small_VU'); my $spectrum = $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'], @@ -135,14 +152,14 @@ sub build_modes { params => [$VISUALIZER_NONE] }, # mode 7 { desc => ['VISUALIZER_VUMETER_SMALL'], - bar => 0, secs => 0, width => $width, _width => int -($small_VU*$width/100), + 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, int ($small_VU*$width/100), 32, int -($small_VU*$width/100), 0, 2] }, + params => [$VISUALIZER_VUMETER, $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 => int -($spectrum->{small}->{size}*$width/100), + 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) - 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}] }, + params => [$VISUALIZER_SPECTRUM_ANALYZER, $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, diff --git a/plugin/SqueezeESP32/HTML/EN/plugins/SqueezeESP32/settings/basic.html b/plugin/SqueezeESP32/HTML/EN/plugins/SqueezeESP32/settings/basic.html deleted file mode 100644 index fdf77916..00000000 --- a/plugin/SqueezeESP32/HTML/EN/plugins/SqueezeESP32/settings/basic.html +++ /dev/null @@ -1,20 +0,0 @@ -[% PROCESS settings/header.html %] - - [% WRAPPER setting title="PLUGIN_SQUEEZEESP32_BANNER" %] -