airplay artwork update - release

This commit is contained in:
Philippe G
2022-01-09 23:19:33 -08:00
parent a4d2017a07
commit 10e36b0599

View File

@@ -52,7 +52,8 @@ static EXT_RAM_ATTR struct {
bool visible; bool visible;
} duration; } duration;
struct { struct {
bool enable, fit; bool enable, active;
bool fit;
bool updated; bool updated;
int tick; int tick;
int offset; int offset;
@@ -245,7 +246,7 @@ static void displayer_task(void *args) {
GDS_TextLine(display, 1, GDS_TEXT_RIGHT, GDS_TEXT_UPDATE, _line); GDS_TextLine(display, 1, GDS_TEXT_RIGHT, GDS_TEXT_UPDATE, _line);
// if we have not received artwork after 5s, display a default icon // if we have not received artwork after 5s, display a default icon
if (displayer.artwork.enable && !displayer.artwork.updated && tick - displayer.artwork.tick > pdMS_TO_TICKS(5000)) { if (displayer.artwork.active && !displayer.artwork.updated && tick - displayer.artwork.tick > pdMS_TO_TICKS(5000)) {
ESP_LOGI(TAG, "no artwork received, setting default"); ESP_LOGI(TAG, "no artwork received, setting default");
displayer_artwork((uint8_t*) default_artwork); displayer_artwork((uint8_t*) default_artwork);
} }
@@ -265,7 +266,7 @@ static void displayer_task(void *args) {
* *
*/ */
void displayer_artwork(uint8_t *data) { void displayer_artwork(uint8_t *data) {
if (!displayer.artwork.enable) return; if (!displayer.artwork.active) return;
int x = displayer.artwork.offset ? displayer.artwork.offset + ARTWORK_BORDER : 0; int x = displayer.artwork.offset ? displayer.artwork.offset + ARTWORK_BORDER : 0;
int y = x ? 0 : 32; int y = x ? 0 : 32;
@@ -420,7 +421,7 @@ void displayer_control(enum displayer_cmd_e cmd, ...) {
switch(cmd) { switch(cmd) {
case DISPLAYER_ACTIVATE: { case DISPLAYER_ACTIVATE: {
char *header = va_arg(args, char*); char *header = va_arg(args, char*);
bool artwork = va_arg(args, int); displayer.artwork.active = displayer.artwork.enable && va_arg(args, int);
strncpy(displayer.header, header, HEADER_SIZE); strncpy(displayer.header, header, HEADER_SIZE);
displayer.header[HEADER_SIZE] = '\0'; displayer.header[HEADER_SIZE] = '\0';
displayer.state = DISPLAYER_ACTIVE; displayer.state = DISPLAYER_ACTIVE;
@@ -431,19 +432,20 @@ void displayer_control(enum displayer_cmd_e cmd, ...) {
displayer.duration.visible = false; displayer.duration.visible = false;
displayer.offset = displayer.boundary = 0; displayer.offset = displayer.boundary = 0;
display_bus(&displayer, DISPLAY_BUS_TAKE); display_bus(&displayer, DISPLAY_BUS_TAKE);
if (artwork) GDS_SetTextWidth(display, displayer.artwork.offset); if (displayer.artwork.active) GDS_SetTextWidth(display, displayer.artwork.offset);
vTaskResume(displayer.task); vTaskResume(displayer.task);
break; break;
} }
case DISPLAYER_SUSPEND: case DISPLAYER_SUSPEND:
// task will display the line 2 from beginning and suspend // task will display the line 2 from beginning and suspend
displayer.state = DISPLAYER_IDLE; displayer.state = DISPLAYER_IDLE;
displayer_artwork(NULL);
display_bus(&displayer, DISPLAY_BUS_GIVE); display_bus(&displayer, DISPLAY_BUS_GIVE);
break; break;
case DISPLAYER_SHUTDOWN: case DISPLAYER_SHUTDOWN:
// let the task self-suspend (we might be doing i2c_write) // let the task self-suspend (we might be doing i2c_write)
GDS_SetTextWidth(display, 0); GDS_SetTextWidth(display, 0);
GDS_Clear(display, GDS_COLOR_BLACK); displayer_artwork(NULL);
displayer.state = DISPLAYER_DOWN; displayer.state = DISPLAYER_DOWN;
display_bus(&displayer, DISPLAY_BUS_GIVE); display_bus(&displayer, DISPLAY_BUS_GIVE);
break; break;