System Architecture
Overall Architecture
ElenixOS adopts a layered architecture design, from bottom to top: hardware layer, portable interface layer, kernel layer, and application layer. This architecture design gives the system good portability and scalability.
Module Dependencies
Core Module Dependency Graph
Architecture Layer Description
1. Hardware Layer
The hardware layer includes various hardware components such as MCU/SoC, Bluetooth, sensors, storage, display, and power management ICs. These hardware components are the foundation for ElenixOS to run.
2. Portable Interface Layer
The portable interface layer provides hardware abstraction, including:
- OS Abstraction Layer: Memory management, synchronization primitives, file system, etc.
- Sensor Interface: Unified sensor access interface
- Power Management Interface: Power state management and control
- Other Peripheral Interfaces: Access interfaces for other hardware peripherals
This layer's design allows ElenixOS to run on different hardware platforms by simply implementing the corresponding interfaces.
3. Kernel Layer
The kernel layer is the core of ElenixOS, containing the following subsystems:
- System Services Subsystem: Event dispatching, animation system, event system, scene system, user services, multi-language support, package manager, etc.
- Script Runtime Subsystem: Script engine, JS API layer, etc.
- Built-in UI Controls: Various UI components built based on LVGL
This layer implements the core functions of ElenixOS and provides services and interfaces for the application layer.
4. Application Layer
The application layer includes watchface system, third-party applications, and system applications. These applications run based on the script engine and use JS API to access system services and UI components.
Data Flow
The data flow of ElenixOS is as follows:
- User Input: Obtain user input through hardware layer input devices (such as touch screen)
- Event Processing: Input events are passed through the portable interface layer to the kernel layer's event system
- Event Dispatching: The event system distributes events to corresponding handlers
- Application Response: Applications execute corresponding logic based on events
- UI Update: Applications update the interface through the UI module
- Display Output: The UI module renders the interface to the display
Script Execution Process
- Script Loading: Load application or watchface script files from the file system
- Script Parsing: The script engine parses JavaScript code
- Script Execution: Execute scripts in Realm, call JS API
- Native Call: JS API calls native code to access system services and hardware
- Result Return: Return execution results to the script
Architecture Advantages
- Layered Design: Clear layered structure makes the system easy to understand and maintain
- Portability: The portable interface layer allows the system to run on different hardware platforms
- Scalability: Modular design makes the system easy to extend and customize
- Script-driven: Scripted development makes application development more flexible and efficient
- Unified Interface: Unified API design makes application development simpler