next iteration on display, still some artifacting issues, and ux with buttons states and updating

This commit is contained in:
matt committed 2026-08-04 19:38:58 -07:00
1 parent 45998b6176
commit ae5d12b3a2
14 files changed
+860 -398

No files matched your search

+40 -7
View File
@@ -108,14 +108,24 @@ static void rgb_flush_cb(lv_display_t *display, const lv_area_t *area, uint8_t *
lv_display_flush_ready(display);
}
esp_err_t display_init(void)
/*
* Phase 1: allocate everything, scan nothing.
*
* Called BEFORE wifi_init_sta(), on a heap nothing else has touched. The
* bounce buffers need two contiguous 25.6KB DMA-capable internal blocks, and
* WiFi's dynamic RX buffers churn that same pool hard enough to fragment it:
* observed on hardware (2026-08-04) as "no mem for bounce buffer" with 84KB
* of total free heap -- plenty of bytes, no block big enough, and retries
* useless because the fragmentation is not transient.
*
* Allocating first is deterministic where retrying was a dice roll. The
* panel is NOT scanning after this returns -- scan-out (and with it the
* PSRAM-reading refill ISR that flash writes would fault) starts only in
* display_start().
*/
esp_err_t display_alloc(void)
{
ESP_LOGI(TAG, "Initializing 800x480 RGB panel (CrowPanel Advance)");
/* lv_display_create() below allocates from LVGL's heap. Without lv_init()
* that heap is a null pool and the call faults with LoadProhibited. */
ESP_RETURN_ON_FALSE(lv_is_initialized(), ESP_ERR_INVALID_STATE, TAG,
"lv_init() must run before display_init()");
ESP_LOGI(TAG, "Allocating 800x480 RGB panel (CrowPanel Advance)");
const esp_lcd_rgb_panel_config_t panel_config = {
.clk_src = LCD_CLK_SRC_DEFAULT,
@@ -175,6 +185,29 @@ esp_err_t display_init(void)
ESP_RETURN_ON_ERROR(esp_lcd_new_rgb_panel(&panel_config, &panel), TAG,
"esp_lcd_new_rgb_panel failed");
ESP_LOGI(TAG, "Panel buffers allocated; free internal heap: %u KB",
(unsigned)(heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024));
return ESP_OK;
}
/*
* Phase 2: start scan-out and hand the framebuffers to LVGL.
*
* From esp_lcd_panel_init() onward the bounce-refill ISR is reading PSRAM
* continuously, so every flash write (NVS, WiFi PHY calibration) must already
* be done -- see the init-order comment in main.c.
*/
esp_err_t display_start(void)
{
ESP_RETURN_ON_FALSE(panel != NULL, ESP_ERR_INVALID_STATE, TAG,
"display_alloc() must run before display_start()");
/* lv_display_create() below allocates from LVGL's heap. Without lv_init()
* that heap is a null pool and the call faults with LoadProhibited. */
ESP_RETURN_ON_FALSE(lv_is_initialized(), ESP_ERR_INVALID_STATE, TAG,
"lv_init() must run before display_start()");
ESP_RETURN_ON_ERROR(esp_lcd_panel_reset(panel), TAG, "panel reset failed");
ESP_RETURN_ON_ERROR(esp_lcd_panel_init(panel), TAG, "panel init failed");
+16 -3
View File
@@ -9,9 +9,22 @@
#define DISPLAY_H_RES 800
#define DISPLAY_V_RES 480
/* Requires lv_init() to have already run -- call lvgl_port_init() first.
* Backlight is NOT owned here on the Advance; see drivers/backlight. */
esp_err_t display_init(void);
/*
* Two-phase bring-up, and the order is load-bearing:
*
* display_alloc() -- BEFORE wifi_init_sta(). Grabs the framebuffers and
* the two contiguous bounce buffers while the internal
* heap is still unfragmented; WiFi's RX buffer churn
* destroys the needed contiguity within seconds.
* The panel is not scanning after this.
* display_start() -- AFTER WiFi (all flash writes done) and after
* lvgl_port_init(). Starts scan-out and registers the
* display with LVGL.
*
* Backlight is NOT owned here on the Advance; see drivers/backlight.
*/
esp_err_t display_alloc(void);
esp_err_t display_start(void);
lv_display_t *display_get_default(void);