Skip to content

`common_screens` Module Overview

Path: main/display/screens

The common_screens module provides the complete library of reusable, firmware-agnostic LVGL screens for the Pibot CNC Pendant. It is partitioned into six sub-modules that together cover every screen the application needs outside of CNC-firmware-specific flows (FluidNC, grbl, grblHAL). Each sub-module builds on the base infrastructure defined in this same module, following a shared lifecycle pattern enforced through macros (ESP3D_TRANSITION_START, ESP3D_CLEANUP_TIMER_BODY, ESP3D_PREPARE_DESTRUCTION_GUARD).

All screens run exclusively on Core 1 (the LVGL task) and use timer-based two-phase destruction to avoid deleting LVGL objects from within event callbacks.


Sub-modulePathKey Screens
screen_base_infrastructuregeneric_screen.h, circular_menu_screen.h, list_menu_screen.hBase classes for all screens
modal_dialog_screensinput_screen.h/cpp, message_box_screen.h/cppKeyboard input, confirmation/info dialogs
network_scan_screenswifi_scan_screen.cpp, scan_bt_screen.cpp, server_scan_screen.cppAsync scan-and-select for WiFi APs, BT devices, mDNS servers
settings_selection_screensbaudrate_screen.cpp, polling_screen.cpp, screen_timeout_screen.cpp, output_selection_screen.cpp, languages_screen.cppPredefined-list pickers that persist to NVS
connection_status_screenconnection_status_screen.h/cppInteractive transport/CNC connection diagnostic hub
system_lifecycle_screenssplash_screen.cpp, update_screen.cppBoot splash and SD-card firmware/resource update

LVGL - Core 1

ui_core

UIManager · ThemeStyles · esp3d_resources

ui_components

VirtualButtonsComponent

CircularMenuComponent · ListMenuComponent

common_screens ← this module

cnc_shared

fluidnc · grbl · grblhal

used by

used by

used by

screen_base_infrastructure

GenericScreen · CircularMenuScreen · ListMenuScreen

modal_dialog_screens

inputScreen · messageBoxScreen

network_scan_screens

wifi · bt · server

settings_selection_screens

baudrate · polling · timeout · output · language

connection_status_screen

system_lifecycle_screens

splash · update

instantiates

instantiates

instantiates

raw lv_obj (no GenericScreen)

instantiates

instantiates

instantiates

instantiates

instantiates

instantiates

instantiates (cnc_shared)

GenericScreen

+lv_obj_t* screen_

+lv_obj_t* container_

+VirtualButtonsComponent* virtual_buttons_

+bool is_prepared_for_destruction_

+static bool transition_in_progress_

+prepareForDestruction()

+rotateContainer(angle)

+isValid() : bool

CircularMenuScreen

+CircularMenuComponent* circular_menu_

+showMenu()

+prepareForDestruction()

ListMenuScreen

+ListMenuComponent* list_menu_

+prepareForDestruction()

inputScreen

messageBoxScreen

connectionStatusScreen

splashScreen

updateScreen

baudrateScreen

wifiScanScreen

scanBTScreen

serverScanScreen

languagesScreen

mainScreen


Every screen in this module follows the same two-phase timer-based destruction pattern to comply with LVGL’s single-thread constraint.

LVGLtransition_timer_cbcleanup_timer_cbAnyScreenEvent Callback (Core 1)LVGLtransition_timer_cbcleanup_timer_cbAnyScreenEvent Callback (Core 1)Guards set - events blockedprepareForDestruction()lv_timer_create(0 ms)lv_screen_load_anim(next, FADE, 300ms)lv_timer_create(300 ms)delete old screen instancetransition_in_progress_ = false

Key guard variables shared across all screens:

VariableRole
is_prepared_for_destruction_Blocks re-entry after teardown begins
cleanup_executed_Makes prepareForDestruction() idempotent
transition_in_progress_ (static)Prevents re-entrant screen transitions

The foundation layer. Provides three base classes consumed by every other screen in the project:

  • GenericScreen (generic_screen.h) — owns the LVGL screen object, a rotatable content container, and a VirtualButtonsComponent button strip. Registers with UIManager.
  • CircularMenuScreen (circular_menu_screen.h) — extends GenericScreen with a radial section-picker (CircularMenuComponent). Used by main_screen and settings_screen.
  • ListMenuScreen (list_menu_screen.h) — extends GenericScreen with a virtual-scrolling list (ListMenuComponent). Used by all list-based screens.

Two full-screen overlay dialogs invoked from any screen across the application:

  • inputScreen — configurable keyboard input (numeric, alphanumeric, PIN, semicolon-separated list). Validates range, decimal places, length, and optional leading zeros.
  • messageBoxScreen — typed dialogs (Information, Confirmation, Error, InformationWithAction) with up to three action buttons.

Both use a creation timer chain (to allow caller teardown before the dialog appears) and a dismissal timer chain (to safely destroy and navigate away).

Three async scan-and-select screens sharing an identical pattern: a ListMenuScreen base, a FreeRTOS scan task (off the LVGL thread), a 250 ms poll timer, and a loading spinner.

  • wifiScanScreen — scans 802.11 APs, handles three WiFi driver states, prompts for passwords via inputScreen, navigates to connectionStatusScreen.
  • scanBTScreen — scans BT Classic / BLE devices, supports PIN entry, countdown timer showing remaining scan duration.
  • serverScanScreen — discovers CNC servers via mDNS (_telnet._tcp or _ws._tcp), guards against a known TLSF/lwIP race on re-connect.

Five single-purpose list-pickers that write immediately to NVS and apply the change live:

ScreenNVS key writtenLive effect
baudrateScreenesp3d_baud_rateserialClient.change_baud_rate()
pollingScreenesp3d_polling_intervalgcodeHandler.updateReportingInterval()
screenTimeoutScreenesp3d_screen_timeoutActivitySubscriber::setTimeout()
outputSelectionScreenesp3d_output_client, esp3d_radio_modeLive switch or restart
languagesScreenactive language codeui_manager.setLanguage() — no restart

A full-screen diagnostic hub showing transport and CNC server status side by side, with adaptive action buttons that change based on the current connection state character (C, T, A, ?, .). Subscribes to connection_status and server_status values from ESP3DValues. Provides PIN/password re-entry flows for authentication failures.

Two screens that bracket the device’s operational life:

  • splashScreen — shown at boot; loads macros, displays the logo, auto-transitions after 1 500 ms. Uses raw LVGL (no GenericScreen) to minimize heap pressure at startup.
  • updateScreen — shown when the SD-card update service detects pending firmware, resources, or config files. Uses firmware-embedded fonts (not XIP) because the ui_resources partition may be erased while the screen is live. Progress is routed through ESP3DValues to stay thread-safe (update runs on Core 0, LVGL on Core 1).

core_platform

ui_core

ui_components

common_screens

VirtualButtonsComponent

CircularMenuComponent

ListMenuComponent

RotaryBaseComponent

UIManager

ThemeStyles · ThemeColors

esp3d_resources

ESP3DValues

ESP3DSettings

ESP3DTranslationService

LVGL

esp3d_log


DocumentContent
docs/architecture/screens_architecture.mdFull screen system: UIManager, ESP3DScreenType, registration, orientation, full lifecycle
docs/architecture/screen_transitions_flow.mdTimer-based safe transition pattern; ESP3D_TRANSITION_START / ESP3D_CLEANUP_TIMER_BODY macros
docs/architecture/Input_system.mdPhysical encoder, buttons, switch, potentiometer routing into virtual buttons
docs/ui_resources/ui_style_guide.mdThemeStyles architecture, apply* functions, per-screen style inventory
docs/ui_resources/theme_palette.md26 semantic color tokens (ESP3D_* constants), RGBA format, per-theme values
docs/guides/esp32_memory_constraints.mdHeap fragmentation playbook; allocation rules for constrained builds
docs/features/feature_resource_matrix.mdWiFi/BT/socket-client mutual exclusion; RAM budgets
docs/features/mdns.mdmDNS registered services (relevant for serverScanScreen)
docs/ui_resources/development.mdui_resources partition binary format; SD-card update mechanisms (relevant for updateScreen and languagesScreen)
docs/architecture/connection_management.mdTransport lifecycle and connection state character protocol