From e4d1d35da459c2c9a902ad9a605bbc9bfeea97c8 Mon Sep 17 00:00:00 2001 From: Adolfo Date: Mon, 20 Jul 2026 00:21:01 -0400 Subject: [PATCH] feat(GameBoy): restore integer scaling using full canvas API - use lv_display_get_*_resolution to compute available area - apply lv_image_set_scale 2x/3x + pivot center when display large enough - removes previous comment hack 'avoid non-exported LVGL transform symbols' - now requires firmware feature/gameboy-canvas-full-api (symbols exported) SDK: 0.8.0-dev built with IDF 5.5.2, 0 missing symbols --- Apps/GameBoy/main/Source/main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Apps/GameBoy/main/Source/main.c b/Apps/GameBoy/main/Source/main.c index b0c5183..20c5714 100644 --- a/Apps/GameBoy/main/Source/main.c +++ b/Apps/GameBoy/main/Source/main.c @@ -433,10 +433,29 @@ static void build_emu_ui(AppCtx* ctx, lv_obj_t* parent){ } if (ctx->fb_native){ + // Integer scaling: use canvas as image source (LVGL canvas inherits lv_image) + // then scale via lv_image_set_scale (256 = 1x, 512 = 2x, etc) + lv_coord_t disp_w = lv_display_get_horizontal_resolution(NULL); + lv_coord_t disp_h = lv_display_get_vertical_resolution(NULL); + // available height for canvas = disp_h - toolbar - info_bar - controls (~110) + // Estimate usable: disp_h - 160 conservative + int avail_h = disp_h - 160; + int avail_w = disp_w - 8; + int scale = 1; + if (avail_w >= FRAME_W * 3 && avail_h >= FRAME_H * 3) scale = 3; + else if (avail_w >= FRAME_W * 2 && avail_h >= FRAME_H * 2) scale = 2; + ctx->canvas = lv_canvas_create(canvas_cont); lv_canvas_set_buffer(ctx->canvas, ctx->fb_native, FRAME_W, FRAME_H, LV_COLOR_FORMAT_RGB565); + if (scale > 1) { + // LVGL image scale is 256 = 1x + lv_image_set_scale(ctx->canvas, (uint32_t)(256 * scale)); + // Center pivot for clean scaling + lv_image_set_pivot(ctx->canvas, FRAME_W / 2, FRAME_H / 2); + } lv_obj_set_style_border_width(ctx->canvas, 1, 0); lv_obj_set_style_border_color(ctx->canvas, lv_color_hex(0x444444), 0); + lv_obj_center(ctx->canvas); } else { lv_obj_t* err=lv_label_create(canvas_cont); lv_label_set_text(err,"FB alloc failed"); lv_obj_set_style_text_color(err, lv_color_white(),0); }