mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 12:37:01 +03:00
Use TJPGD in flash (stack in PSRAM?) - release
This commit is contained in:
@@ -177,6 +177,9 @@ static struct {
|
||||
u32_t size;
|
||||
u16_t x, y;
|
||||
bool enable, full;
|
||||
#ifdef TJPGD_ROM
|
||||
bool ready;
|
||||
#endif
|
||||
} artwork;
|
||||
|
||||
#define MAX_BARS 32
|
||||
@@ -848,7 +851,7 @@ static void grfa_handler(u8_t *data, int len) {
|
||||
} else if (artwork.size) GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK);
|
||||
|
||||
artwork.full = artwork.enable && artwork.x == 0 && artwork.y == 0;
|
||||
LOG_INFO("gfra en:%u x:%hu, y:%hu", artwork.enable, artwork.x, artwork.y);
|
||||
LOG_DEBUG("gfra en:%u x:%hu, y:%hu", artwork.enable, artwork.x, artwork.y);
|
||||
|
||||
// done in any case
|
||||
return;
|
||||
@@ -866,25 +869,34 @@ static void grfa_handler(u8_t *data, int len) {
|
||||
artwork.x = htons(pkt->x);
|
||||
artwork.y = htons(pkt->y);
|
||||
artwork.full = artwork.enable && artwork.x == 0 && artwork.y == 0;
|
||||
#ifdef TJPGD_ROM
|
||||
xSemaphoreTake(displayer.mutex, portMAX_DELAY);
|
||||
artwork.ready = false;
|
||||
#endif
|
||||
if (artwork.data) free(artwork.data);
|
||||
artwork.data = malloc(length);
|
||||
artwork.data = malloc(length);
|
||||
#ifdef TJPGD_ROM
|
||||
xSemaphoreGive(displayer.mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
// copy artwork data
|
||||
memcpy(artwork.data + offset, data + sizeof(struct grfa_packet), size);
|
||||
artwork.size += size;
|
||||
if (artwork.size == length) {
|
||||
xSemaphoreTake(displayer.mutex, portMAX_DELAY);
|
||||
#ifdef TJPGD_ROM
|
||||
artwork.ready = true;
|
||||
#else
|
||||
GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK);
|
||||
xSemaphoreTake(displayer.mutex, portMAX_DELAY);
|
||||
for (int i = 0; i < 2 && !GDS_DrawJPEG(display, artwork.data, artwork.x, artwork.y, artwork.y < displayer.height ? (GDS_IMAGE_RIGHT | GDS_IMAGE_TOP) : GDS_IMAGE_CENTER); i++) {
|
||||
LOG_WARN("JPEG decoding error, pass %d", i+1);
|
||||
}
|
||||
xSemaphoreGive(displayer.mutex);
|
||||
GDS_DrawJPEG(display, artwork.data, artwork.x, artwork.y, artwork.y < displayer.height ? (GDS_IMAGE_RIGHT | GDS_IMAGE_TOP) : GDS_IMAGE_CENTER);
|
||||
free(artwork.data);
|
||||
artwork.data = NULL;
|
||||
#endif
|
||||
xSemaphoreGive(displayer.mutex);
|
||||
}
|
||||
|
||||
LOG_INFO("gfra l:%u x:%hu, y:%hu, o:%u s:%u", length, artwork.x, artwork.y, offset, size);
|
||||
|
||||
LOG_DEBUG("gfra l:%u x:%hu, y:%hu, o:%u s:%u", length, artwork.x, artwork.y, offset, size);
|
||||
}
|
||||
|
||||
/****************************************************************************************
|
||||
@@ -1304,7 +1316,17 @@ static void displayer_task(void *args) {
|
||||
// need to make sure we own display
|
||||
if (display && displayer.owned) GDS_Update(display);
|
||||
else if (!led_display) displayer.wake = LONG_WAKE;
|
||||
|
||||
|
||||
#ifdef TJPGD_ROM
|
||||
if (artwork.ready) {
|
||||
GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK);
|
||||
GDS_DrawJPEG(display, artwork.data, artwork.x, artwork.y, artwork.y < displayer.height ? (GDS_IMAGE_RIGHT | GDS_IMAGE_TOP) : GDS_IMAGE_CENTER);
|
||||
free(artwork.data);
|
||||
artwork.data = NULL;
|
||||
artwork.ready = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// release semaphore and sleep what's needed
|
||||
xSemaphoreGive(displayer.mutex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user