mirror of
https://github.com/vicliu624/trail-mate.git
synced 2026-09-09 13:35:32 +00:00
5.7 KiB
5.7 KiB
UI Shared / IDF Migration Plan
This document is used to explain: how to extract UI logic from each apps/* and deposit it into a reusable shared layer that is compatible with both PlatformIO and ESP-IDF entrances.
1. Goal
1.1 Overall goal
- Concentrate common UI pages, shells, controllers, and runtime interfaces into
modules/ui_shared - Let
apps/esp_pioandapps/esp_idfOnly keep the respective platform entrance, startup process and adapter - Avoid shared UI directly relying on Arduino or ESP-IDF specific implementation details
1.2 Migration principles
- Page structure, interaction and state logic are first deposited into the shared layer
- Platform differences converge to
platform/*and app runtime adapter - Do not maintain an implementation of the same page in PIO / IDF respectively
- For capabilities that cannot be shared temporarily, use capability-gated fallback to occupy the space
2. Layered boundary
2.1 modules/ui_shared
Host:
- page shell
- Page component
- controller / presenter
- Runtime abstract interface
- Universal fallback page
Should not directly depend on:
<Arduino.h><Preferences.h>nvs.h- Specific board-level API
2.2 apps/esp_pio / apps/esp_idf
Host:
- startup / boot
- menu / app catalog entry
- loop driver
- life cycle management
- facade / runtime adapter assembly
2.3 platform/*
Host:
- Device capability implementation
- Screen/sleep/audio/GPS/storage and other platform APIs
- Arduino and IDF respective contract implementation
3. Current status (as of 2026-03-11)
3.1 Shared page skeleton
Has been moved to shared shell + runtime/components/controller page:
SettingsChatGPS / MapGNSS Sky PlotContactsTeamTrackerPC LinkUSBSSTVProtocol Probe(internal route:energy_sweep)Walkie Talkie
3.2 apps side status
apps/esp_pio/src and apps/esp_idf/src have gradually converged to the following responsibilities:
startup_runtime.cpploop_runtime.cppapp_runtime_access.cppapp_registry.cpp
Among them esp_idf Also included:
runtime_config.cppapp_facade_runtime.cppidf_entry.cppidf_component_anchor.cpp
3.3 Completed Cleanup
- A batch of old IDF retired stubs have been removed
ui_common_stub.cpp/ui_status_stub.cppinmodules/ui_sharedhas been significantly shrunk- Most of the
ui_*.cppretained underapps/esp_pio/srconly have wrapper responsibilities
4. Phased plan
Phase 0: Inventory and hemostasis
Goal
- First clarify which pages have been shared and which ones still have app private implementation
- Stop adding duplicate page implementation
Delivery
- Page ownership list
- App private wrapper list
- Shared shell gap list
Phase 1: apps entry convergence
Goal
Converge apps/esp_pio and apps/esp_idf into "start + loop + runtime wiring".
Tasks
- Align
app_catalog/menu/startup/loopto shared mode - Clean up the historical page wrapper / registry special case in
apps/esp_pio - Convergence Life cycle and runtime access of
app_runtime_access - Unify the startup / loop / event driver mode of
esp_pio/esp_idf
Complete the standard
- The app directories at both ends no longer carry specific UI logic
- The app entry can stably drive the shared app catalog / shared shell
Stage 2: Page sharing completed
Goal
Really unify the page layer to shared:
- shell
- host
- fallback
- components / controller / runtime
Tasks
- Complete shared
shell + components/runtime - Remove residual page logic on the app side
- Unify the wiring between app catalog and shared page shell
- Use capability-gated fallback for missing capabilities
Complete the standard
- The page structure is only maintained in
modules/ui_shared - The fallback behavior is consistent
- The app side no longer copies the page implementation
Phase 3: Platform capability abstraction completed
Goal
Converge all the device capabilities that shared UI depends on into the adapter contract.
Requires the ability to abstract
- restart
- kv / config persistence
- screen sleep
- tone / audio preview
- GPS runtime control
- tracker recording hook
- hostlink / USB capability hook
- walkie / sstv / lora support
Placement
- Arduino is implemented in
platform/esp/arduino_common - IDF is implemented in
platform/esp/idf_commonandapps/esp_idf/*runtime
Complete the standard
modules/ui_sharedno longer directly contains ESP proprietary header files- shared only relies on platform contract
Phase 4: Configuration and profile convergence
Goal
Unify device profile, visual size, and capability differences into runtime config / page profile.
Key points
tab5tdeckpager
Requirements
- Topbar, height, spacing, icon cards, etc. are driven by shared profile
- Board-level differences are not scattered in the page code
5. Risk points
- The shared page has completed structural migration, but the runtime hook may still have platform coupling
- PIO / IDF The life cycle rhythms of the two sets of entrances are not completely consistent, and it is easy to have differences in the order of events
- fallback If the design is too weak, it will cover up the real gaps in the short term
- Before the profile is completely unified, layout bifurcation may continue to occur on different devices
6. Acceptance criteria
modules/ui_sharedbecomes the only source of truth for the page UIapps/esp_pioandapps/esp_idfare mainly responsible for startup and assembly- Platform differences only appear in
platform/*and runtime adapter