Fix 3.5C backlight (GPIO27) and GT911 INT handling per CYD guide.

Wrong BL=21 caused black screen; INT is separate from backlight and stays INPUT after reset.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-25 18:57:41 +08:00
parent f870f5cebb
commit d19341339b
19 changed files with 465 additions and 56 deletions

View File

@@ -12,14 +12,15 @@
#include <freertos/task.h>
// Half-res canvas (fits ESP32 DRAM). UI shows it at 2x -> 320x240.
static constexpr uint16_t CANVAS_W = UI_HOR_RES / 2;
static constexpr uint16_t CANVAS_H = UI_VER_RES / 2;
/* Cap decode canvas on all boards to fit 3.5" DRAM. */
static constexpr uint16_t CANVAS_W = 128;
static constexpr uint16_t CANVAS_H = 96;
static constexpr size_t CANVAS_PIXELS = (size_t)CANVAS_W * (size_t)CANVAS_H;
static uint16_t g_pixels[CANVAS_PIXELS]; // buffer A
static uint16_t *g_pixels = nullptr; // buffer A (heap)
static uint16_t *g_buf_b = nullptr; // buffer B (heap, GIF double-buffer)
static uint16_t *g_show = g_pixels; // LVGL reads this
static uint16_t *g_draw = g_pixels; // GIF decoder writes this
static uint16_t *g_show = nullptr; // LVGL reads this
static uint16_t *g_draw = nullptr; // GIF decoder writes this
static bool g_ready = false;
static lv_image_dsc_t g_dsc;
static uint16_t g_img_w = 0;
@@ -39,7 +40,7 @@ static int g_dst_h = 0;
// GIF worker (core 0): decode must not block LVGL/touch on core 1.
static TaskHandle_t g_gif_task = nullptr;
static uint16_t *g_draw_dst = g_pixels; // alias used by gif_draw
static uint16_t *g_draw_dst = nullptr; // alias used by gif_draw
static char g_gif_path[PHOTO_PATH_MAX];
static volatile bool g_gif_active = false;
static volatile bool g_gif_busy = false;
@@ -596,6 +597,14 @@ bool photo_view_init() {
if (g_ready) {
return true;
}
if (!g_pixels) {
g_pixels = (uint16_t *)malloc(CANVAS_PIXELS * sizeof(uint16_t));
if (!g_pixels) {
Serial.println("photo_view: canvas alloc failed");
return false;
}
g_show = g_draw = g_draw_dst = g_pixels;
}
canvas_clear(0x0000);
canvas_sync_dsc();
g_ready = true;
@@ -614,9 +623,11 @@ void photo_view_deinit() {
free(g_buf_b);
g_buf_b = nullptr;
}
g_show = g_pixels;
g_draw = g_pixels;
g_draw_dst = g_pixels;
if (g_pixels) {
free(g_pixels);
g_pixels = nullptr;
}
g_show = g_draw = g_draw_dst = nullptr;
g_ready = false;
g_dsc.data = nullptr;
}