From 4b833aaa5719d01af7bd354002f86f8aec5d9362 Mon Sep 17 00:00:00 2001 From: Shinku <17696928+Shinku-Chen@users.noreply.github.com> Date: Thu, 27 Aug 2026 18:48:15 +0800 Subject: [PATCH] docs(development): add display refresh and deep-sleep notes Add a reusable, upstream-benefiting post-release experience entry from the 'What to Eat Today' firmware release: - Display refresh: direct esp_lcd_panel_draw_bitmap refresh of a single image rect, big-endian RGB565, this project's LVGL I8 palette layout, and an optional interlaced two-pass mode. - Deep-sleep wakeup: ESP32-C3 has no EXT0/EXT1; use esp_deep_sleep_enable_gpio_wakeup on an RTC GPIO, noting ESP-IDF 5.5.3's default internal-resistor behavior. - LVGL object-type misuse crash signature (lv_tlsf_block_size). Link the bilingual entry from both the English and zh_CN experience indexes. Hardware facts are marked Unverified pending source commit/tag, board revision, and reproduced measurements. --- docs/development/experience-notes.md | 1 + docs/development/experience-notes.zh_CN.md | 1 + docs/experiences/INDEX.md | 1 + docs/experiences/INDEX.zh_CN.md | 1 + .../display-refresh-and-deep-sleep.md | 62 +++++++++++++++++++ .../display-refresh-and-deep-sleep.zh_CN.md | 50 +++++++++++++++ 6 files changed, 116 insertions(+) create mode 100644 docs/experiences/shinku-chen/display-refresh-and-deep-sleep.md create mode 100644 docs/experiences/shinku-chen/display-refresh-and-deep-sleep.zh_CN.md diff --git a/docs/development/experience-notes.md b/docs/development/experience-notes.md index 352542c..f4a1866 100644 --- a/docs/development/experience-notes.md +++ b/docs/development/experience-notes.md @@ -49,3 +49,4 @@ stored entries. The index below lists each entry once it is added. - **Audio Compression Trade-offs on ESP32-C3** (Shinku-Chen) — how a voice-playback codec was chosen on limited flash (IMA-ADPCM vs Opus vs MP3), with measured capacity and decoder cost. See [`../experiences/shinku-chen/audio-compression-trade-offs.md`](../experiences/shinku-chen/audio-compression-trade-offs.md). - **Post-Release Follow-up for the AI Passport Publishing Flow** (Shinku-Chen) — confirm the publish destination, include the data partition in a release, and the consent gates for the post-release tracks. See [`../experiences/shinku-chen/post-release-follow-up.md`](../experiences/shinku-chen/post-release-follow-up.md). +- **Display Refresh and Deep-sleep on ESP32-C3 (No PSRAM)** (Shinku-Chen) — direct panel refresh of a single image rect, RTC-GPIO deep-sleep wakeup, and the LVGL object-type misuse crash signature. See [`../experiences/shinku-chen/display-refresh-and-deep-sleep.md`](../experiences/shinku-chen/display-refresh-and-deep-sleep.md). diff --git a/docs/development/experience-notes.zh_CN.md b/docs/development/experience-notes.zh_CN.md index 412b3d1..4b3f913 100644 --- a/docs/development/experience-notes.zh_CN.md +++ b/docs/development/experience-notes.zh_CN.md @@ -37,3 +37,4 @@ fork 上自行创建或变更的 `docs/` 文档。每条经验一个 `.md` 及 - **ESP32-C3 上音频压缩方式的权衡**(Shinku-Chen)— 在有限 Flash 上如何为语音播放应用选编解码(IMA-ADPCM vs Opus vs MP3),含实测容量与解码器成本。见 [`../experiences/shinku-chen/audio-compression-trade-offs.zh_CN.md`](../experiences/shinku-chen/audio-compression-trade-offs.zh_CN.md)。 - **发布后收尾:AI Passport 发布流程的衔接**(Shinku-Chen)— 确认发布目的地、发布时包含数据分区、以及发布后收尾各轨道的同意门槛。见 [`../experiences/shinku-chen/post-release-follow-up.zh_CN.md`](../experiences/shinku-chen/post-release-follow-up.zh_CN.md)。 +- **ESP32-C3(无 PSRAM)上的显示刷新与深睡**(Shinku-Chen)— 直接刷新单个图片矩形、RTC GPIO 深睡唤醒,以及 LVGL 对象类型误用的崩溃特征。见 [`../experiences/shinku-chen/display-refresh-and-deep-sleep.zh_CN.md`](../experiences/shinku-chen/display-refresh-and-deep-sleep.zh_CN.md)。 diff --git a/docs/experiences/INDEX.md b/docs/experiences/INDEX.md index 99cc4b7..dcb8d73 100644 --- a/docs/experiences/INDEX.md +++ b/docs/experiences/INDEX.md @@ -24,3 +24,4 @@ rather than merged into an existing one. - [Audio Compression Trade-offs on ESP32-C3](shinku-chen/audio-compression-trade-offs.md) — how a voice-playback codec was chosen on limited flash (IMA-ADPCM vs Opus vs MP3), with measured capacity and decoder cost. - [Post-Release Follow-up for the AI Passport Publishing Flow](shinku-chen/post-release-follow-up.md) — confirm the publish destination, include the data partition in a release, and the consent gates for the post-release tracks. +- [Display Refresh and Deep-sleep on ESP32-C3 (No PSRAM)](shinku-chen/display-refresh-and-deep-sleep.md) — direct panel refresh of a single image rect, RTC-GPIO deep-sleep wakeup, and the LVGL object-type misuse crash signature. diff --git a/docs/experiences/INDEX.zh_CN.md b/docs/experiences/INDEX.zh_CN.md index 86da2ef..27930ed 100644 --- a/docs/experiences/INDEX.zh_CN.md +++ b/docs/experiences/INDEX.zh_CN.md @@ -18,3 +18,4 @@ - [ESP32-C3 上音频压缩方式的权衡](shinku-chen/audio-compression-trade-offs.zh_CN.md) — 在有限 Flash 上如何为语音播放应用选编解码(IMA-ADPCM vs Opus vs MP3),含实测容量与解码器成本。 - [发布后收尾:AI Passport 发布流程的衔接](shinku-chen/post-release-follow-up.zh_CN.md) — 确认发布目的地、发布时包含数据分区、以及发布后收尾各轨道的同意门槛。 +- [ESP32-C3(无 PSRAM)上的显示刷新与深睡](shinku-chen/display-refresh-and-deep-sleep.zh_CN.md) — 直接刷新单个图片矩形、RTC GPIO 深睡唤醒,以及 LVGL 对象类型误用的崩溃特征。 diff --git a/docs/experiences/shinku-chen/display-refresh-and-deep-sleep.md b/docs/experiences/shinku-chen/display-refresh-and-deep-sleep.md new file mode 100644 index 0000000..b7deaa3 --- /dev/null +++ b/docs/experiences/shinku-chen/display-refresh-and-deep-sleep.md @@ -0,0 +1,62 @@ +

+ 简体中文 · English +

+ +# Display Refresh and Deep-sleep on ESP32-C3 (No PSRAM) + +Captured after the **"What to Eat Today"** single-app firmware release. These are +general, upstream-benefiting learnings that apply to any AI Passport app, not +fork-specific customization. + +> **Verification status — Unverified.** The hardware and runtime facts below +> (GPIO wakeup level, LCD byte order, and the crash signature) are captured from +> this project's own observations but are not yet backed by a pinned source +> commit/tag, the exact test-board revision, or reproduced measurements. Treat +> them as unverified field notes rather than confirmed upstream behavior. + +## Direct panel refresh of a single image rect + +For a UI that redraws only a fixed image area each frame, bypassing LVGL's +partial-redraw path and driving the LCD panel directly is more controllable: + +- `bsp_display_panel()` exposes an `esp_lcd_panel_handle_t`; use + `esp_lcd_panel_draw_bitmap(panel, x1, y1, x2, y2, color_data)` to push **only + the image rectangle**. +- The panel layer does **not** byte-swap (swap is a `esp_lvgl_port` flag), so push + **big-endian RGB565** for the ST7789 SPI path. +- The LVGL I8 indexed bitmaps **generated by this project** embed a 256×4 + (B,G,R,A) palette before the pixel index bytes; decode each row to RGB565 on + the fly with a small line buffer — no full-frame RAM on a no-PSRAM part. This + palette layout is this project's LVGL I8 convention, not a universal rule for + all I8 data. +- An optional interlaced two-pass (even rows, then odd rows) halves the pixels per + SPI pass at the cost of a visible tear — useful for A/B comparing speed vs. + tearing. +- Keep the image rectangle's origin (x, y) shared between the LVGL layout and the + direct draw so the two paths agree. + +## Deep-sleep GPIO wakeup on ESP32-C3 + +ESP32-C3 has **no EXT0/EXT1** wakeup. Use `esp_deep_sleep_enable_gpio_wakeup()` +on an RTC GPIO. On this board the key ADC node is GPIO0 with an external 10 kΩ +pull-up (high at idle), so a **low-level** wake (`ESP_GPIO_WAKEUP_GPIO_LOW`) fires +on any key press. + +- Configure the GPIO as a digital input before `esp_deep_sleep_start()`. Note + that ESP-IDF 5.5.3 by default enables the RTC GPIO internal resistors + (`CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS=y`), which stacks an internal + pull on top of the external 10 kΩ pull-up. If the intent is to rely on the + external pull-up **only**, that config must be explicitly disabled — a behavior + not yet verified on hardware. +- `esp_deep_sleep_start()` does not return; on wake the app boots fresh, so + re-initialize peripherals and the ADC button handle that sleep replaced. +- A timer-only wakeup causes a periodic reboot cycle, not a true "power off"; use + GPIO wakeup when the intent is to sleep until a user action. + +## LVGL object-type misuse and the resulting crash signature + +Passing a non-label `lv_obj_t*` (e.g. a panel) to `lv_label_set_text()` corrupts +the heap: LVGL reads the object as a label, frees a garbage text pointer, and +faults in `lv_tlsf_block_size` — a `Load access fault` with `MTVAL` near a small +offset (e.g. `0x68`), looping on reboot. Keep the actual `lv_obj_t*` created by +`lv_label_create()` in a dedicated variable and use that, not the container. diff --git a/docs/experiences/shinku-chen/display-refresh-and-deep-sleep.zh_CN.md b/docs/experiences/shinku-chen/display-refresh-and-deep-sleep.zh_CN.md new file mode 100644 index 0000000..ea7b2c6 --- /dev/null +++ b/docs/experiences/shinku-chen/display-refresh-and-deep-sleep.zh_CN.md @@ -0,0 +1,50 @@ +

+ 简体中文 · English +

+ +# ESP32-C3(无 PSRAM)上的显示刷新与深睡 + +在「今天吃啥」单应用固件发布后沉淀。这些是通用、上游受益的经验,适用于任何 +AI Passport 应用,而非 fork 专属定制。 + +> **验证状态 — Unverified。** 下面的硬件与运行时事实(GPIO 唤醒电平、LCD 字节序、 +> 崩溃特征)来自本项目自身的观察,但尚未附上固定来源 commit/tag、确切测试板版本或 +> 复现实测。请将其视为未经验证的现场笔记,而非已确认的上游行为。 + +## 直接刷新单个图片矩形 + +对于只需每帧重绘固定图片区域的 UI,绕过 LVGL 的局部重绘路径、直接驱动 LCD +面板更可控: + +- `bsp_display_panel()` 暴露 `esp_lcd_panel_handle_t`;用 + `esp_lcd_panel_draw_bitmap(panel, x1, y1, x2, y2, color_data)` **只推图片矩形**。 +- panel 层**不做**字节交换(swap 是 `esp_lvgl_port` 的 flag),故 ST7789 SPI 路径 + 要推**大端 RGB565**。 +- **本项目生成的** LVGL I8 索引位图在像素索引字节前内嵌 256×4 (B,G,R,A) 调色板; + 用小的行缓冲逐行解码为 RGB565,避免在无 PSRAM 部件上占整帧 RAM。该调色板布局是 + 本项目 LVGL I8 的约定,并非所有 I8 数据的通用规则。 +- 可选隔行两趟(先偶行后奇行)让每趟 SPI 像素减半,代价是可见撕裂——适合 A/B + 对比速度与撕裂。 +- 让图片矩形的原点 (x, y) 在 LVGL 布局与直画之间共享,保证两条路径一致。 + +## ESP32-C3 的深睡 GPIO 唤醒 + +ESP32-C3 **没有 EXT0/EXT1** 唤醒。用 `esp_deep_sleep_enable_gpio_wakeup()` 在 +RTC GPIO 上唤醒。本板按键 ADC 节点是 GPIO0,带外部 10k 上拉(常态高),故**低电平** +唤醒(`ESP_GPIO_WAKEUP_GPIO_LOW`)在任意按键按下时触发。 + +- 在 `esp_deep_sleep_start()` 前把该 GPIO 配成数字输入。注意 ESP-IDF 5.5.3 默认会 + 启用 RTC GPIO 内部电阻(`CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS=y`), + 会在外部 10 kΩ 上拉之上叠加内部上拉。若意图是**只**依靠外部上拉,需显式关闭该 + 配置——此行为尚未在真机验证。 +- `esp_deep_sleep_start()` 不返回;唤醒后应用冷启动,需重新初始化休眠所替换的 + 外设与 ADC 按键句柄。 +- 仅定时器唤醒会造成周期性重启,而非真正的“关机”;意图是睡到用户操作时应使用 + GPIO 唤醒。 + +## LVGL 对象类型误用及其崩溃特征 + +把非 label 的 `lv_obj_t*`(如 panel)传给 `lv_label_set_text()` 会破坏堆: +LVGL 把该对象当作 label,释放一个垃圾文本指针,在 `lv_tlsf_block_size` 中出错—— +`Load access fault`,`MTVAL` 接近一个小偏移(如 `0x68`),并循环重启。应在专用变量里 +保存 `lv_label_create()` 真正创建的 `lv_obj_t*` 并使用它,而不是容器。