From be40a08c7d0f144ad5cb404a4e4b4c61e2cf39cd Mon Sep 17 00:00:00 2001 From: gitee-bot Date: Mon, 30 Jun 2025 12:42:39 +0000 Subject: [PATCH] Update README.md --- .../ports/linux/lv_drivers/wayland/README.md | 176 ++++-------------- 1 file changed, 38 insertions(+), 138 deletions(-) diff --git a/f411/guider/ports/linux/lv_drivers/wayland/README.md b/f411/guider/ports/linux/lv_drivers/wayland/README.md index ba7fe6b..6ab21ce 100644 --- a/f411/guider/ports/linux/lv_drivers/wayland/README.md +++ b/f411/guider/ports/linux/lv_drivers/wayland/README.md @@ -1,157 +1,57 @@ -# Wayland display and input driver -Wayland display and input driver, with support for keyboard, pointer (i.e. mouse) and touchscreen. -Keyboard support is based on libxkbcommon. -Following shell are supported: +# lvgl_cube -* wl_shell (deprecated) -* xdg_shell +## 介绍 -> xdg_shell requires an extra build step; see section _Generate protocols_ below. +本项目是一个基于 LVGL 图形库的立方体图形展示程序,适用于 STM32F411 系列微控制器。它结合了 LVGL 的图形渲染能力与 STM32 的硬件驱动能力,实现了 3D 立方体在显示屏上的动态旋转效果。 +项目主要功能: +- 使用 FreeRTOS 多任务机制 +- 实现 LVGL 图形显示 +- 立方体 3D 渲染与旋转 +- SPI 接口驱动显示屏 +- GPIO 初始化与控制 +- 定时器中断用于刷新显示 -Basic client-side window decorations (simple title bar, minimize and close buttons) -are supported, while integration with desktop environments is not. +## 主要特性 +- **3D 图形渲染**:通过矩阵乘法和旋转算法实现立方体的三维变换 +- **LVGL 图形库集成**:使用轻量级图形库进行图形渲染 +- **硬件驱动**:包含 STM32F411 的 SPI、GPIO、定时器等硬件驱动代码 +- **多任务处理**:基于 FreeRTOS 实现多个任务并行运行 -## Install headers and libraries +## 使用示例 -### Ubuntu +项目包含以下关键功能函数: +- `create_simple_graphics()` - 创建简单的图形元素 +- `matconv()` - 矩阵乘法计算 +- `rotate()` - 旋转向量计算 +- `fill_display2()` - 屏幕填充函数 +- `drm_flush()` - 显示缓冲区刷新函数 -``` -sudo apt-get install libwayland-dev libxkbcommon-dev libwayland-bin wayland-protocols -``` +## 硬件要求 -### Fedora +- STM32F411 系列微控制器 +- 支持 SPI 接口的显示屏 +- 相关外围电路(如复位电路、时钟电路等) -``` -sudo dnf install wayland-devel libxkbcommon-devel wayland-utils wayland-protocols-devel -``` +## 软件架构 +项目采用以下主要模块: +- **LVGL**:负责图形界面和 3D 效果的渲染 +- **FreeRTOS**:管理多个并发任务 +- **STM32 HAL**:提供底层硬件驱动 +- **CMSIS**:包含 ARM Cortex-M 系列内核的系统头文件 -## Generate protocols +## 编译与运行 -Support for non-basic shells (i.e. other than _wl_shell_) requires additional -source files to be generated before the first build of the project. To do so, -navigate to the _wayland_ folder (the one which includes this file) and issue -the following commands: +本项目适用于 STM32CubeIDE 开发环境,编译后可烧录到 STM32F411 开发板运行。运行时,显示屏上将展示一个持续旋转的立方体图形。 -``` -cmake . -make -``` +## 贡献者 +本项目由 skyline 开发并维护。 -## Build configuration under Eclipse +## 许可证 -In "Project properties > C/C++ Build > Settings" set the followings: - -- "Cross GCC Compiler > Command line pattern" - - Add ` ${wayland-cflags}` and ` ${xkbcommon-cflags}` to the end (add a space between the last command and this) - - -- "Cross GCC Linker > Command line pattern" - - Add ` ${wayland-libs}` and ` ${xkbcommon-libs}` to the end (add a space between the last command and this) - - -- In "C/C++ Build > Build variables" - - Configuration: [All Configuration] - - - Add - - Variable name: `wayland-cflags` - - Type: `String` - - Value: `pkg-config --cflags wayland-client` - - Variable name: `wayland-libs` - - Type: `String` - - Value: `pkg-config --libs wayland-client` - - Variable name: `xkbcommon-cflags` - - Type: `String` - - Value: `pkg-config --cflags xkbcommon` - - Variable name: `xkbcommon-libs` - - Type: `String` - - Value: `pkg-config --libs xkbcommon` - - -## Init Wayland in LVGL - -1. In `main.c` `#incude "lv_drivers/wayland/wayland.h"` -2. Enable the Wayland driver in `lv_drv_conf.h` with `USE_WAYLAND 1` and - configure its features below, enabling at least support for one shell. -3. `LV_COLOR_DEPTH` should be set either to `32` or `16` in `lv_conf.h`; - support for `8` and `1` depends on target platform. -4. After `lv_init()` call `lv_wayland_init()`. -5. Add a display (or more than one) using `lv_wayland_create_window()`, - possibly with a close callback to track the status of each display: -```c - #define H_RES (800) - #define V_RES (480) - - /* Create a display */ - lv_disp_t * disp = lv_wayland_create_window(H_RES, V_RES, "Window Title", close_cb); -``` - As part of the above call, the Wayland driver will register four input devices - for each display: - - a KEYPAD connected to Wayland keyboard events - - a POINTER connected to Wayland touch events - - a POINTER connected to Wayland pointer events - - a ENCODER connected to Wayland pointer axis events - Handles for input devices of each display can be get using respectively - `lv_wayland_get_indev_keyboard()`, `lv_wayland_get_indev_touchscreen()`, - `lv_wayland_get_indev_pointer()` and `lv_wayland_get_indev_pointeraxis()`, using - `disp` as argument. -5. After `lv_deinit()` (if used), or in any case during de-initialization, call - `lv_wayland_deinit()`. - -### Fullscreen mode - -In order to set one window as fullscreen or restore it as a normal one, -call the `lv_wayland_window_set_fullscreen()` function respectively with `true` -or `false` as `fullscreen` argument. - -### Disable window client-side decoration at runtime - -Even when client-side decorations are enabled at compile time, they can be -disabled at runtime setting the `LV_WAYLAND_DISABLE_WINDOWDECORATION` -environment variable to `1`. - -### Event-driven timer handler - -Set `LV_WAYLAND_TIMER_HANDLER` in `lv_drv_conf.h` and call `lv_wayland_timer_handler()` -in your timer loop (in place of `lv_timer_handler()`). - -You can now sleep/wait until the next timer/event is ready, e.g.: -``` -/* [After initialization and display creation] */ -#include -#include -#include - -struct pollfd pfd; -uint32_t time_till_next; -int sleep; - -pfd.fd = lv_wayland_get_fd(); -pfd.events = POLLIN; - -while (1) { - /* Handle any Wayland/LVGL timers/events */ - time_till_next = lv_wayland_timer_handler(); - - /* Run until the last window closes */ - if (!lv_wayland_window_is_open(NULL)) { - break; - } - - /* Wait for something interesting to happen */ - if (time_till_next == LV_NO_TIMER_READY) { - sleep = -1; - } else if (time_till_next > INT_MAX) { - sleep = INT_MAX; - } else { - sleep = time_till_next; - } - - while ((poll(&pfd, 1, sleep) < 0) && (errno == EINTR)); -} -``` +本项目使用 MIT 许可证,详情请参考根目录下的 LICENSE 文件。 \ No newline at end of file -- Gitee