mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 12:07:09 +03:00
use TJPGD in flash
This commit is contained in:
16
.gitignore
vendored
16
.gitignore
vendored
@@ -1,30 +1,16 @@
|
|||||||
|
|
||||||
build/
|
build/
|
||||||
|
|
||||||
.vscode/c_cpp_properties.json
|
.vscode/c_cpp_properties.json
|
||||||
|
|
||||||
.vscode/launch.json
|
.vscode/launch.json
|
||||||
|
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
|
|
||||||
.vscode/tasks.json
|
.vscode/tasks.json
|
||||||
|
|
||||||
alltags.txt
|
alltags.txt
|
||||||
|
|
||||||
components/wifi-manager/network_manager_handlers.multi
|
components/wifi-manager/network_manager_handlers.multi
|
||||||
|
|
||||||
esp32.code-workspace
|
esp32.code-workspace
|
||||||
|
|
||||||
sdkconfig.old
|
sdkconfig.old
|
||||||
|
|
||||||
test/.vscode/c_cpp_properties.json
|
test/.vscode/c_cpp_properties.json
|
||||||
|
|
||||||
test/.vscode/launch.json
|
test/.vscode/launch.json
|
||||||
|
|
||||||
test/.vscode/settings.json
|
test/.vscode/settings.json
|
||||||
|
|
||||||
test/.vscode/tasks.json
|
test/.vscode/tasks.json
|
||||||
|
|
||||||
test/sdkconfig
|
test/sdkconfig
|
||||||
|
|
||||||
components/wifi-manager/UML-State-Machine-in-C
|
components/wifi-manager/UML-State-Machine-in-C
|
||||||
|
*.bak
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
|
# the JPEG library is in ROM but seems to fail randomly (PSRAM issue?)
|
||||||
|
set(TJPGD tjpgd)
|
||||||
|
|
||||||
idf_component_register(SRC_DIRS . core core/ifaces fonts
|
idf_component_register(SRC_DIRS . core core/ifaces fonts
|
||||||
INCLUDE_DIRS . fonts core
|
INCLUDE_DIRS . fonts core
|
||||||
REQUIRES platform_config tools esp_common
|
REQUIRES platform_config tools esp_common
|
||||||
PRIV_REQUIRES services freertos driver
|
PRIV_REQUIRES services freertos driver ${TJPGD}
|
||||||
EMBED_FILES note.jpg
|
EMBED_FILES note.jpg )
|
||||||
)
|
|
||||||
|
if (NOT TJPGD)
|
||||||
|
add_compile_definitions(TJPGD_ROM)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_source_files_properties(display.c
|
set_source_files_properties(display.c
|
||||||
PROPERTIES COMPILE_FLAGS
|
PROPERTIES COMPILE_FLAGS
|
||||||
-Wno-format-overflow
|
-Wno-format-overflow )
|
||||||
)
|
|
||||||
|
|||||||
@@ -8,7 +8,11 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
#ifdef TJPGD_ROM
|
||||||
#include "esp32/rom/tjpgd.h"
|
#include "esp32/rom/tjpgd.h"
|
||||||
|
#else
|
||||||
|
#include "tjpgd.h"
|
||||||
|
#endif
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
#include "gds.h"
|
#include "gds.h"
|
||||||
@@ -24,7 +28,6 @@ typedef struct {
|
|||||||
const unsigned char *InData; // Pointer to jpeg data
|
const unsigned char *InData; // Pointer to jpeg data
|
||||||
int InPos; // Current position in jpeg data
|
int InPos; // Current position in jpeg data
|
||||||
int Width, Height;
|
int Width, Height;
|
||||||
uint32_t Pixels;
|
|
||||||
uint8_t Mode;
|
uint8_t Mode;
|
||||||
union {
|
union {
|
||||||
void *OutData;
|
void *OutData;
|
||||||
@@ -144,8 +147,6 @@ static unsigned OutHandlerDirect(JDEC *Decoder, void *Bitmap, JRECT *Frame) {
|
|||||||
uint8_t *Pixels = (uint8_t*) Bitmap;
|
uint8_t *Pixels = (uint8_t*) Bitmap;
|
||||||
int Shift = 8 - Context->Depth;
|
int Shift = 8 - Context->Depth;
|
||||||
|
|
||||||
Context->Pixels += (Frame->bottom - Frame->top + 1) * (Frame->right - Frame->left + 1); \
|
|
||||||
|
|
||||||
// decoded image is RGB888, shift only make sense for grayscale
|
// decoded image is RGB888, shift only make sense for grayscale
|
||||||
if (Context->Mode == GDS_RGB888) {
|
if (Context->Mode == GDS_RGB888) {
|
||||||
OUTHANDLERDIRECT(Scaler888, 0);
|
OUTHANDLERDIRECT(Scaler888, 0);
|
||||||
@@ -421,11 +422,10 @@ bool GDS_DrawJPEG(struct GDS_Device* Device, uint8_t *Source, int x, int y, int
|
|||||||
Context.XMin = x - Context.XOfs;
|
Context.XMin = x - Context.XOfs;
|
||||||
Context.YMin = y - Context.YOfs;
|
Context.YMin = y - Context.YOfs;
|
||||||
Context.Mode = Device->Mode;
|
Context.Mode = Device->Mode;
|
||||||
Context.Pixels = 0;
|
|
||||||
|
|
||||||
// do decompress & draw
|
// do decompress & draw
|
||||||
Res = jd_decomp(&Decoder, OutHandlerDirect, N);
|
Res = jd_decomp(&Decoder, OutHandlerDirect, N);
|
||||||
if (Res == JDR_OK && Context.Pixels == Context.Width * Context.Height) {
|
if (Res == JDR_OK) {
|
||||||
Device->Dirty = true;
|
Device->Dirty = true;
|
||||||
Ret = true;
|
Ret = true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -864,7 +864,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);
|
} 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;
|
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
|
// done in any case
|
||||||
return;
|
return;
|
||||||
@@ -882,25 +882,34 @@ static void grfa_handler(u8_t *data, int len) {
|
|||||||
artwork.x = htons(pkt->x);
|
artwork.x = htons(pkt->x);
|
||||||
artwork.y = htons(pkt->y);
|
artwork.y = htons(pkt->y);
|
||||||
artwork.full = artwork.enable && artwork.x == 0 && artwork.y == 0;
|
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);
|
if (artwork.data) free(artwork.data);
|
||||||
artwork.data = malloc(length);
|
artwork.data = malloc(length);
|
||||||
|
#ifdef TJPGD_ROM
|
||||||
|
xSemaphoreGive(displayer.mutex);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy artwork data
|
// copy artwork data
|
||||||
memcpy(artwork.data + offset, data + sizeof(struct grfa_packet), size);
|
memcpy(artwork.data + offset, data + sizeof(struct grfa_packet), size);
|
||||||
artwork.size += size;
|
artwork.size += size;
|
||||||
if (artwork.size == length) {
|
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);
|
GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK);
|
||||||
xSemaphoreTake(displayer.mutex, portMAX_DELAY);
|
GDS_DrawJPEG(display, artwork.data, artwork.x, artwork.y, artwork.y < displayer.height ? (GDS_IMAGE_RIGHT | GDS_IMAGE_TOP) : GDS_IMAGE_CENTER);
|
||||||
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);
|
|
||||||
free(artwork.data);
|
free(artwork.data);
|
||||||
artwork.data = NULL;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
@@ -1320,7 +1329,17 @@ static void displayer_task(void *args) {
|
|||||||
// need to make sure we own display
|
// need to make sure we own display
|
||||||
if (display && displayer.owned) GDS_Update(display);
|
if (display && displayer.owned) GDS_Update(display);
|
||||||
else if (!led_display) displayer.wake = LONG_WAKE;
|
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
|
// release semaphore and sleep what's needed
|
||||||
xSemaphoreGive(displayer.mutex);
|
xSemaphoreGive(displayer.mutex);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user