Time Manager
Relevant source files
The following files were used as context for generating this wiki page:
The Time Manager is a core system component within FlxOS responsible for handling system time, uptime tracking, and time-related synchronization. It provides a centralized interface for retrieving current timestamps and formatted time strings, which are utilized by various applications and system services such as the System Info App and the Command Line Interface (CLI).
The manager is integrated into the core system source set and is initialized during the system startup sequence to ensure time services are available to both GUI-based and headless environments.
Sources: main/CMakeLists.txt:14, main/core/system/time/TimeManager.cpp
Architecture and Integration
The Time Manager acts as a wrapper around low-level ESP-IDF and FreeRTOS time functions, providing a high-level API for the rest of the OS. It interacts with the hardware abstraction layer to track system ticks and wall-clock time.
Component Relationship
The following diagram illustrates how the Time Manager interacts with various FlxOS modules:
The Time Manager provides data to system-level monitors and user-facing applications.
Sources: main/core/services/cli/CliService.cpp:111-125, main/core/apps/system_info/SystemInfoApp.cpp:241-249
Core Functionality
Uptime Tracking
A primary responsibility of the Time Manager (and related services) is tracking the total time elapsed since the device was powered on. This is typically retrieved in seconds or microseconds and then formatted for human-readable output.
| Feature | Method / Logic | Description |
|---|---|---|
| Microsecond Uptime | esp_timer_get_time() | Retrieves the time since boot in microseconds. |
| Seconds Uptime | uptime_us / 1000000 | Converts raw microsecond data into standard seconds. |
| Formatted Uptime | HH:MM:SS | Formats uptime for display in the System Info App. |
Sources: main/core/services/cli/CliService.cpp:112-113, main/core/apps/system_info/SystemInfoApp.cpp:241-249
System Time Management
The manager facilitates access to the real-time clock (RTC) data. While manual time setting via CLI is noted as "not yet implemented" in current builds (requiring SNTP or manual settimeofday), the system supports retrieving and formatting the current local time.
The sequence shows the transition from raw hardware timestamps to formatted strings used in the UI.
Sources: main/core/services/cli/CliService.cpp:484-500, reports/naming.txt:12-13
Module Integrations
CLI Integration
The CliService provides several commands that leverage the Time Manager's logic to expose time data to the developer via the serial console.
uptime: Calculates days, hours, minutes, and seconds from the system timer.time: Useslocaltime_randstrftimeto print the current calendar time.
Sources: main/core/services/cli/CliService.cpp:111-125, main/core/services/cli/CliService.cpp:484-500
System Info Integration
The SystemInfoApp utilizes the uptime data to provide real-time status updates in the "System" tab of the GUI. It updates the m_uptime_label every interval (default 1000ms).
void SystemInfoApp::updateUptime(const Services::SystemStats& sysStats) {
if (m_uptime_label) {
int const uptime_s = sysStats.uptimeSeconds;
int const h = uptime_s / 3600;
int const m = (uptime_s % 3600) / 60;
int const s = uptime_s % 60;
lv_label_set_text_fmt(m_uptime_label, "Uptime: %02d:%02d:%02d", h, m, s);
}
}
Sources: main/core/apps/system_info/SystemInfoApp.cpp:241-249, main/core/apps/system_info/SystemInfoApp.cpp:27-28
Roadmap and Future Enhancements
According to the development roadmap, time-related features are categorized under standard applications and core enhancements.
| Task ID | Feature | Status | Priority | Notes |
|---|---|---|---|---|
| 4.8 | Clock/Alarm App | ⏳ Planned | P2 | Future app for alarms and timers. |
| 2.7 | mDNS/Bonjour | ⏳ Planned | P2 | Indirectly supports network discovery for time servers. |
Sources: ROADMAP.md:88, ROADMAP.md:52
Summary
The Time Manager is a vital utility in FlxOS that bridges the gap between hardware timers and the user interface. It ensures that both background services and foreground applications have access to accurate uptime and system time data, supporting features ranging from simple console logs to the dynamic uptime display in the system dashboard.