ImmichElias: dynamic display sizing for 3.5 inch (480x320)

- detect display via lv_display_get_horizontal/vertical_resolution
- img target = full width x (disp_h - overhead) for any screen
- fetch_png_from_proxy now takes req_w/h params (was hardcoded 320x240)
- proxy 8106 already handles w/h: tested 320x240 81KB, 480x320 141KB, 320x480 176KB, 800x480 297KB
- THUMB_BUF_SIZE 200KB->512KB for larger PNGs
- Works on yellow 320x240 and new 3.5 inch 480x320 both
This commit is contained in:
Hermes Reyna Bot
2026-07-25 14:32:38 -04:00
parent b03cb2b244
commit 869c97d7b9
+97 -31
View File
@@ -28,13 +28,17 @@ static const char* TAG = "ImmichElias";
#define RESIZE_PROXY_URL "http://192.168.68.110:8106" #define RESIZE_PROXY_URL "http://192.168.68.110:8106"
#define MAX_PHOTOS 50 #define MAX_PHOTOS 50
#define MAX_IMAGE_SIZE (200 * 1024) #define MAX_IMAGE_SIZE (512 * 1024)
#define JSON_BUF_SIZE (60 * 1024) #define JSON_BUF_SIZE (60 * 1024)
#define THUMB_BUF_SIZE (200 * 1024) #define THUMB_BUF_SIZE (512 * 1024)
#define PNG_PATH "/data/immich_cur.png" #define PNG_PATH "/data/immich_cur.png"
#define PNG_PATH_FB1 "/tmp/immich_cur.png" #define PNG_PATH_FB1 "/tmp/immich_cur.png"
#define PNG_PATH_FB2 "/sdcard/immich_cur.png" #define PNG_PATH_FB2 "/sdcard/immich_cur.png"
// Fallback defaults if display detection fails
#define FALLBACK_W 320
#define FALLBACK_H 240
typedef struct { typedef struct {
char id[64]; char id[64];
char thumbnail_url[256]; char thumbnail_url[256];
@@ -135,7 +139,7 @@ static int fetch_person_assets(void) {
char url[256]; char url[256];
snprintf(url, sizeof(url), "%s/api/search/metadata", IMMICH_BASE_URL); snprintf(url, sizeof(url), "%s/api/search/metadata", IMMICH_BASE_URL);
char body[256]; char body[256];
snprintf(body, sizeof(body), "{\"personIds\":[\"%s\"],\"size\":%d}", IMMICH_PERSON_ID, MAX_PHOTOS); snprintf(body, sizeof(body), "{\"personIds\": [\"%s\"], \"size\": %d}", IMMICH_PERSON_ID, MAX_PHOTOS);
int status = http_post_json(url, body, &hb); int status = http_post_json(url, body, &hb);
if (status != 200) { free(json_buf); return -1; } if (status != 200) { free(json_buf); return -1; }
json_buf[hb.len] = '\0'; json_buf[hb.len] = '\0';
@@ -197,18 +201,23 @@ static int download_thumbnail_to_buf(const char* assetId, uint8_t* buf, size_t c
return -1; return -1;
} }
static int fetch_png_from_proxy(const char* assetId, uint8_t* buf, size_t cap, size_t* out_len) { static int fetch_png_from_proxy(const char* assetId, uint8_t* buf, size_t cap, size_t* out_len, int req_w, int req_h) {
if (req_w <= 0) req_w = FALLBACK_W;
if (req_h <= 0) req_h = FALLBACK_H;
// Clamp to sane limits for ESP32 memory
if (req_w > 800) req_w = 800;
if (req_h > 600) req_h = 600;
char url[384]; char url[384];
snprintf(url, sizeof(url), "%s/resize?assetId=%s&w=320&h=240&format=png", RESIZE_PROXY_URL, assetId); snprintf(url, sizeof(url), "%s/resize?assetId=%s&w=%d&h=%d&format=png", RESIZE_PROXY_URL, assetId, req_w, req_h);
ESP_LOGI(TAG, "Fetching proxy PNG %s", url); ESP_LOGI(TAG, "Fetching proxy PNG %s (req %dx%d)", url, req_w, req_h);
HttpBuf hb = { .buf = buf, .cap = cap, .len = 0 }; HttpBuf hb = { .buf = buf, .cap = cap, .len = 0 };
int status = http_get_no_auth(url, &hb); int status = http_get_no_auth(url, &hb);
if (status == 200 && hb.len > 0) { if (status == 200 && hb.len > 0) {
if (out_len) *out_len = hb.len; if (out_len) *out_len = hb.len;
ESP_LOGI(TAG, "Proxy PNG OK %d bytes", (int)hb.len); ESP_LOGI(TAG, "Proxy PNG OK %d bytes for %dx%d", (int)hb.len, req_w, req_h);
return (int)hb.len; return (int)hb.len;
} }
ESP_LOGE(TAG, "Proxy PNG fail id %s status %d", assetId, status); ESP_LOGE(TAG, "Proxy PNG fail id %s %dx%d status %d", assetId, req_w, req_h, status);
return -1; return -1;
} }
@@ -225,7 +234,7 @@ typedef struct {
lv_obj_t* btn_next; lv_obj_t* btn_next;
lv_obj_t* btn_reload; lv_obj_t* btn_reload;
int current_idx; int current_idx;
char status_text[200]; char status_text[256];
bool fetch_in_progress; bool fetch_in_progress;
bool thumb_in_progress; bool thumb_in_progress;
uint8_t* thumb_buf; uint8_t* thumb_buf;
@@ -235,6 +244,11 @@ typedef struct {
bool stop_requested; bool stop_requested;
char saved_img_path[256]; char saved_img_path[256];
bool has_image; bool has_image;
// Dynamic display sizing for 3.5" etc.
int disp_w;
int disp_h;
int img_w;
int img_h;
} AppCtx; } AppCtx;
static void start_fetch_task(AppCtx* ctx); static void start_fetch_task(AppCtx* ctx);
@@ -243,12 +257,55 @@ static void ui_update_all(AppCtx* ctx);
static void thumb_task_fn(void* arg); static void thumb_task_fn(void* arg);
static void fetch_task_fn(void* arg); static void fetch_task_fn(void* arg);
static void detect_display_size(AppCtx* ctx, lv_obj_t* parent) {
if (!ctx) return;
int w = FALLBACK_W;
int h = FALLBACK_H;
lv_display_t* disp = NULL;
if (parent) disp = lv_obj_get_display(parent);
if (!disp) disp = lv_display_get_default();
if (disp) {
int dw = lv_display_get_horizontal_resolution(disp);
int dh = lv_display_get_vertical_resolution(disp);
if (dw > 0 && dh > 0) {
w = dw;
h = dh;
}
}
// Also try NULL arg per GameBoy pattern (returns default)
if (w == FALLBACK_W && h == FALLBACK_H) {
int dw2 = lv_display_get_horizontal_resolution(NULL);
int dh2 = lv_display_get_vertical_resolution(NULL);
if (dw2 > 0 && dh2 > 0) {
w = dw2;
h = dh2;
}
}
ctx->disp_w = w;
ctx->disp_h = h;
// Calculate image target: use full width, leave ~100-120px for toolbar/title/nav
// For landscape 3.5" 480x320, this gives 480x ~220-240; for portrait 320x480 => 320x ~360
// Better: 68% of height for image area, max filling
int overhead = 120;
if (h >= 480) overhead = 140;
else if (h <= 240) overhead = 80;
int target_h = h - overhead;
if (target_h < 120) target_h = h * 2 / 3;
int target_w = w;
// Keep some margin: if target_w > 800, clamp (proxy also clamps)
if (target_w > 800) target_w = 800;
if (target_h > 600) target_h = 600;
ctx->img_w = target_w;
ctx->img_h = target_h;
ESP_LOGI(TAG, "Display detected %dx%d -> img target %dx%d", w, h, target_w, target_h);
}
static void ui_update_all(AppCtx* ctx) { static void ui_update_all(AppCtx* ctx) {
if (!ctx || !ctx->visible) return; if (!ctx || !ctx->visible) return;
if (!tt_lvgl_lock(pdMS_TO_TICKS(1000))) return; if (!tt_lvgl_lock(pdMS_TO_TICKS(1000))) return;
if (!ctx->visible) { tt_lvgl_unlock(); return; } if (!ctx->visible) { tt_lvgl_unlock(); return; }
if (ctx->lbl_count) { if (ctx->lbl_count) {
if (photo_count > 0) lv_label_set_text_fmt(ctx->lbl_count, "%s: %d / %s - PNG via 8106", PERSON_NAME, photo_count, PERSON_COUNT_STR); if (photo_count > 0) lv_label_set_text_fmt(ctx->lbl_count, "%s: %d / %s - %dx%d PNG via 8106 (disp %dx%d)", PERSON_NAME, photo_count, PERSON_COUNT_STR, ctx->img_w, ctx->img_h, ctx->disp_w, ctx->disp_h);
else lv_label_set_text(ctx->lbl_count, ctx->status_text); else lv_label_set_text(ctx->lbl_count, ctx->status_text);
} }
if (ctx->lbl_index) { if (ctx->lbl_index) {
@@ -264,7 +321,7 @@ static void ui_update_all(AppCtx* ctx) {
if (ctx->lbl_status) { if (ctx->lbl_status) {
if (ctx->thumb_len > 0) { if (ctx->thumb_len > 0) {
Photo* p = &photos[ctx->current_idx]; Photo* p = &photos[ctx->current_idx];
if (ctx->has_image) lv_label_set_text_fmt(ctx->lbl_status, "PNG %d bytes OK\n%s\nID %.8s..", (int)ctx->thumb_len, ctx->saved_img_path, p->id); if (ctx->has_image) lv_label_set_text_fmt(ctx->lbl_status, "PNG %d bytes OK %dx%d\n%s\nID %.8s..", (int)ctx->thumb_len, ctx->img_w, ctx->img_h, ctx->saved_img_path, p->id);
else lv_label_set_text_fmt(ctx->lbl_status, "Thumb %d bytes\nID %.8s..\nSaved %s", (int)ctx->thumb_len, p->id, ctx->saved_img_path); else lv_label_set_text_fmt(ctx->lbl_status, "Thumb %d bytes\nID %.8s..\nSaved %s", (int)ctx->thumb_len, p->id, ctx->saved_img_path);
} else lv_label_set_text(ctx->lbl_status, ctx->status_text); } else lv_label_set_text(ctx->lbl_status, ctx->status_text);
} }
@@ -275,8 +332,8 @@ static void ui_update_all(AppCtx* ctx) {
else snprintf(lvgl_path, sizeof(lvgl_path), "%s", ctx->saved_img_path); else snprintf(lvgl_path, sizeof(lvgl_path), "%s", ctx->saved_img_path);
lv_image_set_src(ctx->img, lvgl_path); lv_image_set_src(ctx->img, lvgl_path);
lv_obj_clear_flag(ctx->img, LV_OBJ_FLAG_HIDDEN); lv_obj_clear_flag(ctx->img, LV_OBJ_FLAG_HIDDEN);
lv_obj_set_size(ctx->img, 320, 240); lv_obj_set_size(ctx->img, ctx->img_w, ctx->img_h);
ESP_LOGI(TAG, "lv_img_set_src %s", lvgl_path); ESP_LOGI(TAG, "lv_img_set_src %s %dx%d", lvgl_path, ctx->img_w, ctx->img_h);
} else { } else {
lv_obj_add_flag(ctx->img, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(ctx->img, LV_OBJ_FLAG_HIDDEN);
} }
@@ -291,26 +348,26 @@ static void thumb_task_fn(void* arg) {
if (!ctx->thumb_buf) ctx->thumb_buf = malloc(THUMB_BUF_SIZE); if (!ctx->thumb_buf) ctx->thumb_buf = malloc(THUMB_BUF_SIZE);
} }
if (!ctx->thumb_buf) { if (!ctx->thumb_buf) {
snprintf(ctx->status_text, sizeof(ctx->status_text), "OOM thumb buf"); snprintf(ctx->status_text, sizeof(ctx->status_text), "OOM thumb buf %d", THUMB_BUF_SIZE);
ui_update_all(ctx); ui_update_all(ctx);
ctx->thumb_task = NULL; ctx->thumb_in_progress = false; vTaskDelete(NULL); return; ctx->thumb_task = NULL; ctx->thumb_in_progress = false; vTaskDelete(NULL); return;
} }
int idx = ctx->current_idx; int idx = ctx->current_idx;
if (idx < 0 || idx >= photo_count) idx = 0; if (idx < 0 || idx >= photo_count) idx = 0;
Photo* p = &photos[idx]; Photo* p = &photos[idx];
ESP_LOGI(TAG, "Downloading PNG idx %d id %s", idx, p->id); ESP_LOGI(TAG, "Downloading PNG idx %d id %s %dx%d", idx, p->id, ctx->img_w, ctx->img_h);
snprintf(ctx->status_text, sizeof(ctx->status_text), "Fetching PNG %d/%d via 8106", idx+1, photo_count); snprintf(ctx->status_text, sizeof(ctx->status_text), "Fetching PNG %d/%d %dx%d via 8106", idx+1, photo_count, ctx->img_w, ctx->img_h);
ui_update_all(ctx); ui_update_all(ctx);
size_t out_len = 0; size_t out_len = 0;
int r = fetch_png_from_proxy(p->id, ctx->thumb_buf, THUMB_BUF_SIZE, &out_len); int r = fetch_png_from_proxy(p->id, ctx->thumb_buf, THUMB_BUF_SIZE, &out_len, ctx->img_w, ctx->img_h);
if (r > 0) { if (r > 0) {
ctx->thumb_len = out_len; ctx->thumb_len = out_len;
const char* saved = save_buffer_to_file(ctx->thumb_buf, out_len); const char* saved = save_buffer_to_file(ctx->thumb_buf, out_len);
if (saved) { if (saved) {
strncpy(ctx->saved_img_path, saved, sizeof(ctx->saved_img_path)-1); strncpy(ctx->saved_img_path, saved, sizeof(ctx->saved_img_path)-1);
ctx->has_image = true; ctx->has_image = true;
snprintf(ctx->status_text, sizeof(ctx->status_text), "PNG %d bytes saved %s", (int)out_len, saved); snprintf(ctx->status_text, sizeof(ctx->status_text), "PNG %d bytes %dx%d saved %s", (int)out_len, ctx->img_w, ctx->img_h, saved);
} else if (ctx->app) { } else if (ctx->app) {
char tmp_path[256]; size_t tmp_sz = sizeof(tmp_path); char tmp_path[256]; size_t tmp_sz = sizeof(tmp_path);
tt_app_get_user_data_child_path(ctx->app, "immich_cur.png", tmp_path, &tmp_sz); tt_app_get_user_data_child_path(ctx->app, "immich_cur.png", tmp_path, &tmp_sz);
@@ -319,7 +376,7 @@ static void thumb_task_fn(void* arg) {
fwrite(ctx->thumb_buf, 1, out_len, f); fclose(f); fwrite(ctx->thumb_buf, 1, out_len, f); fclose(f);
strncpy(ctx->saved_img_path, tmp_path, sizeof(ctx->saved_img_path)-1); strncpy(ctx->saved_img_path, tmp_path, sizeof(ctx->saved_img_path)-1);
ctx->has_image = true; ctx->has_image = true;
snprintf(ctx->status_text, sizeof(ctx->status_text), "PNG %d via user_data %s", (int)out_len, tmp_path); snprintf(ctx->status_text, sizeof(ctx->status_text), "PNG %d %dx%d via user_data %s", (int)out_len, ctx->img_w, ctx->img_h, tmp_path);
} else { } else {
ctx->has_image = false; ctx->has_image = false;
snprintf(ctx->status_text, sizeof(ctx->status_text), "PNG %d bytes but save fail", (int)out_len); snprintf(ctx->status_text, sizeof(ctx->status_text), "PNG %d bytes but save fail", (int)out_len);
@@ -353,7 +410,7 @@ static void fetch_task_fn(void* arg) {
int n = fetch_person_assets(); int n = fetch_person_assets();
if (n>0) { if (n>0) {
current_index=0; ctx->current_idx=0; current_index=0; ctx->current_idx=0;
snprintf(ctx->status_text, sizeof(ctx->status_text), "Loaded %d photos, PNG via 8106...", n); snprintf(ctx->status_text, sizeof(ctx->status_text), "Loaded %d photos, %dx%d PNG via 8106...", n, ctx->img_w, ctx->img_h);
ui_update_all(ctx); ui_update_all(ctx);
if (!ctx->thumb_buf) { if (!ctx->thumb_buf) {
ctx->thumb_buf = heap_caps_malloc(THUMB_BUF_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); ctx->thumb_buf = heap_caps_malloc(THUMB_BUF_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
@@ -362,15 +419,15 @@ static void fetch_task_fn(void* arg) {
if (ctx->thumb_buf) { if (ctx->thumb_buf) {
size_t ol=0; size_t ol=0;
Photo* p=&photos[0]; Photo* p=&photos[0];
int r=fetch_png_from_proxy(p->id, ctx->thumb_buf, THUMB_BUF_SIZE, &ol); int r=fetch_png_from_proxy(p->id, ctx->thumb_buf, THUMB_BUF_SIZE, &ol, ctx->img_w, ctx->img_h);
if (r>0) { if (r>0) {
ctx->thumb_len=ol; ctx->thumb_len=ol;
const char* saved=save_buffer_to_file(ctx->thumb_buf, ol); const char* saved=save_buffer_to_file(ctx->thumb_buf, ol);
if (saved) { strncpy(ctx->saved_img_path, saved, sizeof(ctx->saved_img_path)-1); ctx->has_image=true; snprintf(ctx->status_text, sizeof(ctx->status_text), "PNG %d %s", (int)ol, saved); } if (saved) { strncpy(ctx->saved_img_path, saved, sizeof(ctx->saved_img_path)-1); ctx->has_image=true; snprintf(ctx->status_text, sizeof(ctx->status_text), "PNG %d %dx%d %s", (int)ol, ctx->img_w, ctx->img_h, saved); }
else if (ctx->app) { else if (ctx->app) {
char tmp_path[256]; size_t tmp_sz=sizeof(tmp_path); char tmp_path[256]; size_t tmp_sz=sizeof(tmp_path);
tt_app_get_user_data_child_path(ctx->app, "immich_cur.png", tmp_path, &tmp_sz); tt_app_get_user_data_child_path(ctx->app, "immich_cur.png", tmp_path, &tmp_sz);
FILE* f=fopen(tmp_path,"wb"); if(f){fwrite(ctx->thumb_buf,1,ol,f); fclose(f); strncpy(ctx->saved_img_path, tmp_path, sizeof(ctx->saved_img_path)-1); ctx->has_image=true; snprintf(ctx->status_text,sizeof(ctx->status_text),"PNG %d user_data %s",(int)ol,tmp_path);} FILE* f=fopen(tmp_path,"wb"); if(f){fwrite(ctx->thumb_buf,1,ol,f); fclose(f); strncpy(ctx->saved_img_path, tmp_path, sizeof(ctx->saved_img_path)-1); ctx->has_image=true; snprintf(ctx->status_text,sizeof(ctx->status_text),"PNG %d %dx%d user_data %s",(int)ol, ctx->img_w, ctx->img_h, tmp_path);}
} }
} }
ui_update_all(ctx); ui_update_all(ctx);
@@ -394,7 +451,7 @@ static void prev_event_cb(lv_event_t* e) {
if (ctx->thumb_in_progress || ctx->fetch_in_progress) return; if (ctx->thumb_in_progress || ctx->fetch_in_progress) return;
ctx->current_idx--; if (ctx->current_idx<0) ctx->current_idx=photo_count-1; ctx->current_idx--; if (ctx->current_idx<0) ctx->current_idx=photo_count-1;
current_index=ctx->current_idx; ctx->thumb_len=0; ctx->has_image=false; current_index=ctx->current_idx; ctx->thumb_len=0; ctx->has_image=false;
snprintf(ctx->status_text, sizeof(ctx->status_text), "Loading %d/%d 8106 PNG", ctx->current_idx+1, photo_count); snprintf(ctx->status_text, sizeof(ctx->status_text), "Loading %d/%d %dx%d 8106 PNG", ctx->current_idx+1, photo_count, ctx->img_w, ctx->img_h);
ui_update_all(ctx); start_thumb_task(ctx); ui_update_all(ctx); start_thumb_task(ctx);
} }
static void next_event_cb(lv_event_t* e) { static void next_event_cb(lv_event_t* e) {
@@ -403,7 +460,7 @@ static void next_event_cb(lv_event_t* e) {
if (ctx->thumb_in_progress || ctx->fetch_in_progress) return; if (ctx->thumb_in_progress || ctx->fetch_in_progress) return;
ctx->current_idx++; if (ctx->current_idx>=photo_count) ctx->current_idx=0; ctx->current_idx++; if (ctx->current_idx>=photo_count) ctx->current_idx=0;
current_index=ctx->current_idx; ctx->thumb_len=0; ctx->has_image=false; current_index=ctx->current_idx; ctx->thumb_len=0; ctx->has_image=false;
snprintf(ctx->status_text, sizeof(ctx->status_text), "Loading %d/%d 8106 PNG", ctx->current_idx+1, photo_count); snprintf(ctx->status_text, sizeof(ctx->status_text), "Loading %d/%d %dx%d 8106 PNG", ctx->current_idx+1, photo_count, ctx->img_w, ctx->img_h);
ui_update_all(ctx); start_thumb_task(ctx); ui_update_all(ctx); start_thumb_task(ctx);
} }
static void reload_event_cb(lv_event_t* e) { static void reload_event_cb(lv_event_t* e) {
@@ -411,13 +468,20 @@ static void reload_event_cb(lv_event_t* e) {
if (!ctx) return; if (!ctx) return;
if (ctx->fetch_in_progress || ctx->thumb_in_progress) return; if (ctx->fetch_in_progress || ctx->thumb_in_progress) return;
photo_count=0; ctx->current_idx=0; current_index=0; ctx->thumb_len=0; ctx->has_image=false; photo_count=0; ctx->current_idx=0; current_index=0; ctx->thumb_len=0; ctx->has_image=false;
snprintf(ctx->status_text, sizeof(ctx->status_text), "Reloading..."); snprintf(ctx->status_text, sizeof(ctx->status_text), "Reloading %dx%d...", ctx->img_w, ctx->img_h);
ui_update_all(ctx); start_fetch_task(ctx); ui_update_all(ctx); start_fetch_task(ctx);
} }
static void* create_data(void) { static void* create_data(void) {
AppCtx* ctx = calloc(1, sizeof(AppCtx)); AppCtx* ctx = calloc(1, sizeof(AppCtx));
if (ctx) { ctx->current_idx=0; snprintf(ctx->status_text, sizeof(ctx->status_text), "Init %s proxy %s", IMMICH_BASE_URL, RESIZE_PROXY_URL); } if (ctx) {
ctx->current_idx=0;
ctx->disp_w = FALLBACK_W;
ctx->disp_h = FALLBACK_H;
ctx->img_w = FALLBACK_W;
ctx->img_h = FALLBACK_H;
snprintf(ctx->status_text, sizeof(ctx->status_text), "Init %s proxy %s", IMMICH_BASE_URL, RESIZE_PROXY_URL);
}
return ctx; return ctx;
} }
static void destroy_data(void* data) { static void destroy_data(void* data) {
@@ -431,6 +495,8 @@ static void on_destroy(AppHandle app, void* data) { (void)app;(void)data; }
static void on_show(AppHandle app, void* data, lv_obj_t* parent) { static void on_show(AppHandle app, void* data, lv_obj_t* parent) {
AppCtx* ctx=(AppCtx*)data; if(!ctx) return; AppCtx* ctx=(AppCtx*)data; if(!ctx) return;
ctx->visible=true; ctx->app=app; ctx->visible=true; ctx->app=app;
detect_display_size(ctx, parent);
lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE); lv_obj_remove_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(parent, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); lv_obj_set_flex_align(parent, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
@@ -450,7 +516,7 @@ static void on_show(AppHandle app, void* data, lv_obj_t* parent) {
lv_obj_set_style_pad_all(title_cont, 2, LV_PART_MAIN); lv_obj_set_style_pad_all(title_cont, 2, LV_PART_MAIN);
ctx->lbl_title=lv_label_create(title_cont); ctx->lbl_title=lv_label_create(title_cont);
lv_label_set_text_fmt(ctx->lbl_title, "%s - %s photos 8106 PNG", PERSON_NAME, PERSON_COUNT_STR); lv_label_set_text_fmt(ctx->lbl_title, "%s - %s photos %dx%d 8106 PNG", PERSON_NAME, PERSON_COUNT_STR, ctx->img_w, ctx->img_h);
lv_obj_set_style_text_font(ctx->lbl_title, lvgl_get_text_font(FONT_SIZE_LARGE), LV_PART_MAIN); lv_obj_set_style_text_font(ctx->lbl_title, lvgl_get_text_font(FONT_SIZE_LARGE), LV_PART_MAIN);
lv_obj_set_style_text_color(ctx->lbl_title, lv_color_white(), LV_PART_MAIN); lv_obj_set_style_text_color(ctx->lbl_title, lv_color_white(), LV_PART_MAIN);
lv_obj_set_width(ctx->lbl_title, lv_pct(100)); lv_obj_set_width(ctx->lbl_title, lv_pct(100));
@@ -476,7 +542,7 @@ static void on_show(AppHandle app, void* data, lv_obj_t* parent) {
ctx->img=lv_image_create(main_cont); ctx->img=lv_image_create(main_cont);
lv_obj_add_flag(ctx->img, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(ctx->img, LV_OBJ_FLAG_HIDDEN);
lv_obj_set_size(ctx->img, 320, 240); lv_obj_set_size(ctx->img, ctx->img_w, ctx->img_h);
ctx->lbl_status=lv_label_create(main_cont); ctx->lbl_status=lv_label_create(main_cont);
lv_label_set_text(ctx->lbl_status, ctx->status_text); lv_label_set_text(ctx->lbl_status, ctx->status_text);
@@ -518,8 +584,8 @@ static void on_show(AppHandle app, void* data, lv_obj_t* parent) {
lv_obj_t* lr=lv_label_create(ctx->btn_reload); lv_label_set_text(lr, LV_SYMBOL_REFRESH); lv_obj_center(lr); lv_obj_t* lr=lv_label_create(ctx->btn_reload); lv_label_set_text(lr, LV_SYMBOL_REFRESH); lv_obj_center(lr);
lv_obj_add_event_cb(ctx->btn_reload, reload_event_cb, LV_EVENT_CLICKED, ctx); lv_obj_add_event_cb(ctx->btn_reload, reload_event_cb, LV_EVENT_CLICKED, ctx);
if (photo_count>0) { ctx->current_idx=current_index; if(ctx->current_idx>=photo_count) ctx->current_idx=0; snprintf(ctx->status_text,sizeof(ctx->status_text),"Cached %d photos via 8106",photo_count); ui_update_all(ctx); start_thumb_task(ctx); } if (photo_count>0) { ctx->current_idx=current_index; if(ctx->current_idx>=photo_count) ctx->current_idx=0; snprintf(ctx->status_text,sizeof(ctx->status_text),"Cached %d photos %dx%d via 8106 disp %dx%d",photo_count, ctx->img_w, ctx->img_h, ctx->disp_w, ctx->disp_h); ui_update_all(ctx); start_thumb_task(ctx); }
else { snprintf(ctx->status_text,sizeof(ctx->status_text),"Fetching %s via %s...",PERSON_NAME, RESIZE_PROXY_URL); ui_update_all(ctx); start_fetch_task(ctx); } else { snprintf(ctx->status_text,sizeof(ctx->status_text),"Fetching %s %dx%d via %s disp %dx%d",PERSON_NAME, ctx->img_w, ctx->img_h, RESIZE_PROXY_URL, ctx->disp_w, ctx->disp_h); ui_update_all(ctx); start_fetch_task(ctx); }
} }
static void on_hide(AppHandle app, void* data) { static void on_hide(AppHandle app, void* data) {