# Plan a touchscreen UI for an ESP32 or other microcontroller

A memory-aware screen design, library choice, and code structure for a display-based embedded project.

- Topic: Software Development
- Framework: Few-Shot
- Level: Standard
- Tags: Design, Plan, Fill-in Template
- Source: https://www.thinkwithprompt.com/prompts/plan-a-touchscreen-ui-for-an-esp32-or-other-microcontroller

## Prompt

```text
Help me plan the user interface for my microcontroller project with a display.

**Board and chip:** [e.g. "ESP32-S3 with 8MB PSRAM", "ESP32-WROOM, no PSRAM"]
**Display:** [size, resolution, driver chip, interface — e.g. "3.5in 480x320 ILI9488 over SPI"]
**Input:** [capacitive touch / resistive touch / buttons / rotary encoder]
**Framework:** [Arduino / ESP-IDF / PlatformIO]
**Screens and features I need:** [e.g. "home dashboard with sensor readings, settings menu, Wi-Fi setup"]
**Constraints:** [battery-powered, refresh rate, other tasks sharing the CPU]

Give me:
1. **Library recommendation:** compare options such as LVGL, TFT_eSPI/LovyanGFX with a custom layer, or a minimal hand-rolled approach, against my RAM, flash, and feature needs.
2. **Memory budget:** frame buffer strategy (full vs. partial buffers, double buffering, PSRAM use) with the math for my resolution and color depth.
3. **Screen map:** each screen, its widgets, and navigation between them.
4. **Code structure:** modules for display driver, input handling, UI state, and app logic; how UI updates run alongside other tasks (FreeRTOS tasks, timers, avoiding blocking calls).
5. **Performance tips:** dirty-region redraws, DMA transfers, SPI clock, font and image storage.
6. **Input handling:** touch calibration, debouncing, and long-press behavior.
7. **Starter code:** a minimal example that initializes the display and input and shows one screen.

If any of my hardware details are missing or incompatible, tell me before recommending. Mark pin numbers and driver settings I must confirm as [CONFIRM].
```

## What to fill in

- e.g. "ESP32-S3 with 8MB PSRAM", "ESP32-WROOM, no PSRAM"
- capacitive touch / resistive touch / buttons / rotary encoder
- Arduino / ESP-IDF / PlatformIO
- battery-powered, refresh rate, other tasks sharing the CPU
- CONFIRM

Free to copy and use. From ThinkWithPrompt (https://www.thinkwithprompt.com/), a library of 2,663 curated AI prompts.
