diff --git a/Documentation/applications/examples/rust/hello/index.rst b/Documentation/applications/examples/rust/hello/index.rst new file mode 100644 index 00000000000..82f5c5d2806 --- /dev/null +++ b/Documentation/applications/examples/rust/hello/index.rst @@ -0,0 +1,30 @@ +================================== +`hello` Example in Rust +================================== + +This example demonstrates how to use Rust's powerful features in a NuttX environment, including: + +- **JSON Serialization/Deserialization**: Using the popular `serde` and `serde_json` crates to work with JSON data +- **Async Runtime**: Demonstrates basic usage of the `tokio` async runtime +- **C Interoperability**: Shows how to expose Rust functions to be called from C code + +Key Features +------------ + +1. JSON Handling + - Defines a `Person` struct with `Serialize` and `Deserialize` traits + - Serializes Rust structs to JSON strings + - Deserializes JSON strings into Rust structs + - Demonstrates pretty-printing JSON + +2. Async Runtime + - Initializes a single-threaded `tokio` runtime + - Runs a simple async task that prints a message + +3. C Interop + - Exports `hello_rust_cargo_main` function with `#[no_mangle]` for C calling + - Uses `extern "C"` to define the C ABI + +The example shows how Rust's modern features can be used in embedded systems while maintaining compatibility with C-based systems. + +This example serves as a foundation for building more complex Rust applications in NuttX that need to handle JSON data and async operations. diff --git a/Documentation/applications/examples/rust/slint/index.rst b/Documentation/applications/examples/rust/slint/index.rst new file mode 100644 index 00000000000..27ad3837ebb --- /dev/null +++ b/Documentation/applications/examples/rust/slint/index.rst @@ -0,0 +1,42 @@ +================================== +`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. diff --git a/Documentation/applications/examples/rust/slint/slint.jpg b/Documentation/applications/examples/rust/slint/slint.jpg new file mode 100644 index 00000000000..24904b3254b Binary files /dev/null and b/Documentation/applications/examples/rust/slint/slint.jpg differ