|
@@ -33,6 +33,8 @@ static const char *TAG = "display";
|
|
|
#define DEFAULT_SLEEP 3600
|
|
|
#define ARTWORK_BORDER 1
|
|
|
|
|
|
+extern const uint8_t default_artwork[] asm("_binary_note_jpg_start");
|
|
|
+
|
|
|
static EXT_RAM_ATTR struct {
|
|
|
TaskHandle_t task;
|
|
|
SemaphoreHandle_t mutex;
|
|
@@ -51,6 +53,8 @@ static EXT_RAM_ATTR struct {
|
|
|
} duration;
|
|
|
struct {
|
|
|
bool enable, fit;
|
|
|
+ bool updated;
|
|
|
+ int tick;
|
|
|
int offset;
|
|
|
} artwork;
|
|
|
TickType_t tick;
|
|
@@ -239,7 +243,12 @@ static void displayer_task(void *args) {
|
|
|
// just re-write the whole line it's easier
|
|
|
GDS_TextLine(display, 1, GDS_TEXT_LEFT, GDS_TEXT_CLEAR, displayer.header);
|
|
|
GDS_TextLine(display, 1, GDS_TEXT_RIGHT, GDS_TEXT_UPDATE, _line);
|
|
|
-
|
|
|
+
|
|
|
+ // 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)) {
|
|
|
+ ESP_LOGI(TAG, "no artwork received, setting default");
|
|
|
+ displayer_artwork((uint8_t*) default_artwork);
|
|
|
+ }
|
|
|
timer_sleep = 1000;
|
|
|
} else timer_sleep = max(1000 - elapsed, 0);
|
|
|
} else timer_sleep = DEFAULT_SLEEP;
|
|
@@ -252,7 +261,6 @@ static void displayer_task(void *args) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/****************************************************************************************
|
|
|
*
|
|
|
*/
|
|
@@ -262,7 +270,14 @@ void displayer_artwork(uint8_t *data) {
|
|
|
int x = displayer.artwork.offset ? displayer.artwork.offset + ARTWORK_BORDER : 0;
|
|
|
int y = x ? 0 : 32;
|
|
|
GDS_ClearWindow(display, x, y, -1, -1, GDS_COLOR_BLACK);
|
|
|
- if (data) GDS_DrawJPEG(display, data, x, y, GDS_IMAGE_CENTER | (displayer.artwork.fit ? GDS_IMAGE_FIT : 0));
|
|
|
+ if (data) {
|
|
|
+ displayer.artwork.updated = true;
|
|
|
+ GDS_DrawJPEG(display, data, x, y, GDS_IMAGE_CENTER | (displayer.artwork.fit ? GDS_IMAGE_FIT : 0));
|
|
|
+ } else {
|
|
|
+ displayer.artwork.updated = false;
|
|
|
+ displayer.artwork.tick = xTaskGetTickCount();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/****************************************************************************************
|
|
@@ -428,6 +443,7 @@ void displayer_control(enum displayer_cmd_e cmd, ...) {
|
|
|
case DISPLAYER_SHUTDOWN:
|
|
|
// let the task self-suspend (we might be doing i2c_write)
|
|
|
GDS_SetTextWidth(display, 0);
|
|
|
+ GDS_Clear(display, GDS_COLOR_BLACK);
|
|
|
displayer.state = DISPLAYER_DOWN;
|
|
|
display_bus(&displayer, DISPLAY_BUS_GIVE);
|
|
|
break;
|