mirror of
https://github.com/apache/nuttx.git
synced 2026-08-15 09:23:20 +00:00
Summary: - Added two new Rust example applications to the documentation: - `hello` example showcasing JSON serialization/deserialization, async runtime usage, and C interoperability in a NuttX environment - `slint` example demonstrating the integration of the Slint UI framework with NuttX's framebuffer and touchscreen devices for creating GUI applications in Rust - Each example includes detailed explanations of key features and how they are implemented using Rust's modern language capabilities Impact: - Enhances the documentation for Rust development within NuttX, providing clear and practical examples for developers - Facilitates easier adoption of Rust for new projects by demonstrating how to leverage its features while maintaining compatibility with existing NuttX infrastructure - No changes to the core NuttX system; the additions are entirely within the documentation and examples directory Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
42 lines
1.6 KiB
ReStructuredText
42 lines
1.6 KiB
ReStructuredText
==================================
|
|
`slint` UI Framework Example
|
|
==================================
|
|
|
|
.. image:: slint.jpg
|
|
:alt: Slint UI Example Screenshot
|
|
:align: center
|
|
|
|
This example demonstrates how to use the Slint UI framework in a NuttX environment with Rust. It shows how to create a simple GUI application that:
|
|
|
|
- Displays a counter that increments every second
|
|
- Uses NuttX's framebuffer device for rendering
|
|
- Handles touchscreen input
|
|
- Implements a software renderer for the Slint UI
|
|
|
|
Key Features
|
|
------------
|
|
|
|
1. **Framebuffer Integration**
|
|
- Opens and configures the NuttX framebuffer device (/dev/fb0)
|
|
- Supports RGB565 pixel format
|
|
- Implements a custom line buffer provider for efficient rendering
|
|
|
|
2. **Touchscreen Input**
|
|
- Opens and reads from the touchscreen device (/dev/input0)
|
|
- Handles touch press, move, and release events
|
|
- Maps touch coordinates to UI elements
|
|
|
|
3. **Slint UI Framework**
|
|
- Creates a simple window with a text element showing a counter
|
|
- Uses Slint's software renderer backend
|
|
- Implements a custom NuttX platform adapter
|
|
- Handles window events and animations
|
|
|
|
4. **Rust Integration**
|
|
- Uses nuttx crate to interface with NuttX devices
|
|
- Implements safe Rust abstractions for framebuffer and touchscreen
|
|
- Demonstrates Rust's memory safety features with unsafe blocks
|
|
|
|
The example shows how modern Rust UI frameworks can be used in embedded systems while maintaining compatibility with NuttX's device model.
|
|
|
|
This serves as a foundation for building more complex Rust GUI applications in NuttX that need to handle graphical output and touch input.
|