Skip to main content
Prompts ESP32 UI Library Developer with C++ DSL

model coding user risk: low

ESP32 UI Library Developer with C++ DSL

Act as an expert Embedded Systems Developer to create a UI library for ESP32 using PlatformIO, Arduino-ESP32 framework, ESPAsyncWebServer, LittleFS, and ArduinoJson v7, featuring a…

PROMPT

Act as an Embedded Systems Developer. You are an expert in developing libraries for microcontrollers with a focus on the ESP32 platform.

Your task is to develop a UI library for the ESP32 with the following specifications:

- **MCU**: ESP32
- **Build System**: PlatformIO
- **Framework**: Arduino-ESP32
- **Language Standard**: C++14 (modern, RAII-style) Compiler flag "-fno-rtti"
- **Web Server**: ESPAsyncWebServer
- **Filesystem**: LittleFS
- **JSON**: ArduinoJson v7
- **Frontend Schema Engine**: UI-Schema

You will:
- Implement a Task-Based Runtime environment within the library.
- Ensure the initialization flow is handled strictly within the library.
- Conform to a mandatory REST API contract.
- Integrate a C++ UI DSL as a key feature.
- Develop a compile-time debug system.

Rules:
- The library should be completely generic, allowing users to define items and their names in their main code.

This task requires a detailed understanding of both hardware interface and software architecture principles.

Your responsibilities:
- Develop backend logic for device control and state management.
- Serve static frontend files and provide UI-Schema and runtime state via JSON.
- Ensure frontend/backend separation: Frontend handles rendering, ESP32 handles logic.

Constraints:
- No HTML, CSS, or JS logic in ESP32 firmware.
- Frontend is schema-driven, controlled via JSON updates.

ROLES & RULES

Role assignments

  • Act as an Embedded Systems Developer.
  • You are an expert in developing libraries for microcontrollers with a focus on the ESP32 platform.
  1. The library should be completely generic, allowing users to define items and their names in their main code.
  2. No HTML, CSS, or JS logic in ESP32 firmware.
  3. Frontend is schema-driven, controlled via JSON updates.

EXPECTED OUTPUT

Format
code
Constraints
  • C++14 RAII-style
  • PlatformIO library structure
  • no HTML/CSS/JS in firmware

SUCCESS CRITERIA

  • Implement a Task-Based Runtime environment within the library.
  • Ensure the initialization flow is handled strictly within the library.
  • Conform to a mandatory REST API contract.
  • Integrate a C++ UI DSL as a key feature.
  • Develop a compile-time debug system.
  • Develop backend logic for device control and state management.
  • Serve static frontend files and provide UI-Schema and runtime state via JSON.
  • Ensure frontend/backend separation: Frontend handles rendering, ESP32 handles logic.

FAILURE MODES

  • May include HTML, CSS, or JS logic in ESP32 firmware despite constraints.
  • May fail to make the library completely generic.
  • May not handle initialization strictly within the library.

CAVEATS

Missing context
  • Exact REST API endpoints, methods, and JSON schemas.
  • Examples of user-defined items and main.cpp integration.
  • Details on static frontend files (source, structure).
  • Success criteria for library completion (e.g., tests, demos).
  • Hardware assumptions (e.g., display? It's web UI, but confirm).
Ambiguities
  • Does not define 'UI-Schema'.
  • Does not specify the 'mandatory REST API contract'.
  • Does not detail the C++ UI DSL syntax or features.
  • Unclear specifics of 'Task-Based Runtime environment'.
  • Unclear what 'compile-time debug system' entails.

QUALITY

OVERALL
0.65
CLARITY
0.85
SPECIFICITY
0.75
REUSABILITY
0.10
COMPLETENESS
0.65

IMPROVEMENT SUGGESTIONS

  • Specify the mandatory REST API contract with endpoints, payloads, and responses.
  • Provide a syntax example or grammar for the C++ UI DSL.
  • Define UI-Schema with links or examples, and integration steps.
  • Add a usage example in main.cpp showing library initialization and item definition.
  • Clarify Task-Based Runtime (e.g., FreeRTOS tasks?) and debug system.
  • Include library file structure (e.g., src/, include/, library.json).

USAGE

Copy the prompt above and paste it into your AI of choice — Claude, ChatGPT, Gemini, or anywhere else you're working. Replace any placeholder sections with your own context, then ask for the output.

MORE FOR MODEL