diff --git a/README.md b/README.md index d05642c..b3e7968 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,26 @@ -# Demo +# Demo \[ English | [简体中文](README_zh-cn.md) \] -## Overview +## Overview -This repository implements examples of openvela native application code. Developers can quickly get started with development based on our documentation and examples. +This repository implements examples of openvela native application code. Developers can quickly get started with development based on our documentation and examples. -## Usage Instructions +## Demo List -- [Bicycle Computer](../../../docs/blob/dev/en/demo/X_Track.md) -- [Breakout Game](breakout/Readme.md) -- [Calculator](calculator/Readme.md) -- [Hourglass](hourglass/Readme.md) -- [Music Player](../../../docs/blob/dev/en/demo/Music_Player_Example.md) -- [Music Player 2](music_player2/README-en.md) -- [Relation Calculator](relation_calculator/Readme.md) -- [Smart Band](../../../docs/blob/dev/en/demo/Smart_Band_Example.md) -- [Snake Game](snake_game/Readme.md) -- [Virtual Pet](pet/README.md) -- [Whackmole](Whackmole/README.md) -- [Wooden Fish](wooden_fish/README.md) +| Demo | Description | +|------|-------------| +| [BandX](bandx/README.md) | Smart band UI demo | +| [Breakout](breakout/README.md) | Brick breaker game | +| [Calculator](calculator/README.md) | Calculator with expression evaluation | +| [Hourglass](hourglass/README.md) | Digital hourglass timer | +| [MiMo](mimo/README.md) | Xiaomi MiMo AI model provider | +| [Music Player](music_player/README.md) | Music player application | +| [Music Player 2](music_player2/README.md) | Enhanced music player with splash screen | +| [Virtual Pet](pet/README.md) | Interactive virtual pet | +| [Relation Calculator](relation_calculator/README.md) | Chinese family relation calculator | +| [Snake Game](snake_game/README.md) | Classic snake game | +| [Utils](utils/README.md) | Shared demo utility library | +| [Whack-a-Mole](Whackmole/README.md) | Whack-a-mole game | +| [Wooden Fish](wooden_fish/README.md) | Digital wooden fish | +| [X-TRACK](x_track/README.md) | Bicycle computer / GPS tracker | diff --git a/README_zh-cn.md b/README_zh-cn.md index 15bfac5..33e90af 100644 --- a/README_zh-cn.md +++ b/README_zh-cn.md @@ -4,19 +4,23 @@ ## 简介 -该仓库实现了 openvela native应用代码示例,开发者可以根据我们的文档和示例,快速上手开发。 +该仓库实现了 openvela native 应用代码示例,开发者可以根据文档和示例快速上手开发。 -## 使用说明 +## 演示列表 -- [音乐播放器](../../../docs/blob/dev/zh-cn/demo/Music_Player_Example_zh-cn.md) -- [智能手环](../../../docs/blob/dev/zh-cn/demo/Smart_Band_Example_zh-cn.md) -- [自行车码表](../../../docs/blob/dev/zh-cn/demo/X_Track_zh-cn.md) -- [计算器](calculator/Readme.md) -- [亲戚计算器](relation_calculator/Readme.md) -- [打地鼠](Whackmole/README_zh-cn.md) -- [音乐播放器2](music_player2/README.md) -- [打砖块](breakout/Readme.md) -- [电子沙漏](hourglass/Readme.md) -- [贪吃蛇](snake_game/Readme.md) -- [虚拟宠物](pet/README.md) -- [电子木鱼](wooden_fish/README_zh-cn.md) +| 演示 | 说明 | +|------|------| +| [智能手环 BandX](bandx/README_zh-cn.md) | 智能手环 UI 演示 | +| [打砖块 Breakout](breakout/README_zh-cn.md) | 经典打砖块游戏 | +| [计算器 Calculator](calculator/README_zh-cn.md) | 支持表达式求值的计算器 | +| [电子沙漏 Hourglass](hourglass/README_zh-cn.md) | 电子沙漏计时器 | +| [MiMo AI](mimo/README_zh-cn.md) | 小米 MiMo AI 大模型接入组件 | +| [音乐播放器](music_player/README_zh-cn.md) | 音乐播放器应用 | +| [音乐播放器 2](music_player2/README_zh-cn.md) | 增强版音乐播放器(含启动页) | +| [虚拟宠物](pet/README_zh-cn.md) | 交互式虚拟宠物 | +| [亲戚计算器](relation_calculator/README_zh-cn.md) | 中国亲戚关系计算器 | +| [贪吃蛇](snake_game/README_zh-cn.md) | 经典贪吃蛇游戏 | +| [工具库 Utils](utils/README_zh-cn.md) | 共享演示工具库 | +| [打地鼠](Whackmole/README_zh-cn.md) | 打地鼠游戏 | +| [电子木鱼](wooden_fish/README_zh-cn.md) | 电子木鱼 | +| [自行车码表 X-TRACK](x_track/README_zh-cn.md) | 自行车码表 / GPS 追踪器 | diff --git a/bandx/README.md b/bandx/README.md new file mode 100644 index 0000000..647beb8 --- /dev/null +++ b/bandx/README.md @@ -0,0 +1,130 @@ +# Smart Band + +English | [中文](README_zh-cn.md) + +## Introduction + +Bandx is a smart band demo that incorporates watch dial, launcher, music, heart rate, stopwatch, sleep, sports, settings and flashlight, with a resolution of 194 x 368 pixels. + +This article describes how to run this example on Emulator. + +## Prerequisites + +To download the source code, see [Quick Start](https://github.com/open-vela/docs/blob/dev/en/quickstart/openvela_ubuntu_quick_start.md). + +## Step 1: Configure the project + +1. Switch to the root directory of openvela repository and execute the following command to configure Bandx. + + **Note**: The emulator configuration file (defconfig) is in the "vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap/" directory, and the emulator code is configured and compiled using "build.sh". + + ```Bash + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap menuconfig + ``` + + - build.sh: A script for compilation used to configure and compile openvela code. + - vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap: configuration path + - menuconfig: Open the menuconfig page to modify the configuration of the project code. + +2. Press the "/" key to search and modify the following configurations: + + ```Bash + LV_USE_FRAGMENT = y + LVX_USE_DEMO_BANDX = y + BANDX_BASE_PATH = "/data" + ``` + + Take **LV_USE_FRAGMENT** as an example for illustration. The other configurations are modified is the same way. + + 1. Enter the configuration to be searched. + 2. Press "Enter" to go to the configuration page. + 3. Press "Enter" to open the configuration, and a \* that appears in [ ] indicates that the configuration is opened. + 4. Press the "/" key to continue searching for the remaining configurations, and modify them as described above. + 5. Press the letter Q to bring up the exit Save screen. + 6. Press the letter Y to save the configuration and exit the Modify Configuration page. + +## Step 2: Compile the project + +1. Switch to the root directory of openvela repository and execute the following commands one by one in a terminal: + + ```Bash + # Clean up build artifacts + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j8 + + #Start to build + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j8 + ``` + +2. After successful execution, you will get the following files: + + ```plaintext + ./nuttx + ├── vela_ap.elf + ├── vela_ap.bin + ``` + +## Step 3: Launch the emulator and push resources + +The font and image resources used in Bandx are located in 'apps/packages/demos/bandx/resources/'. To push these resources to the corresponding file paths mounted by the emulator, follow the steps below. + +1. Switch to the root directory of openvela repository and start the emulator: + + ```bash + ./emulator.sh vela + ``` + +2. Push resources to the device by using emulator-supported ADB. Open a new terminal in the root directory of openvela repository, type "adb push" followed by the file path to transfer the resources to the appropriate location. + + ```bash + # Install adb + sudo apt install android-tools-adb + + # Push resources + adb push apps/packages/demos/bandx/resource/font/assets/* /data/font/ + adb push apps/packages/demos/bandx/resource/image/assets /data/image/ + ``` + + **Note**: If "BANDX_BASE_PATH" is changed to a non-default value like "/tmp", the resource files must also be moved to the "/tmp/font/" and "/tmp/image/" directories. Otherwise, a "resource not found" error will occur. + +## Step 4: Start Bandx + +1. Enter the following command in the emulator's terminal environment "openvela-ap": + + ```Bash + bandx & + ``` + +2. To access the Launcher screen, swipe quickly from right to left. Single-click different icons to navigate to subpages, such as the Heart Rate page. To exit the page, swipe quickly from left to right. + + **Note**: The music page is just a UI display, with no access to audio. + +3. Turn on "Auto-show" in settings to auto-play the entire application. Turn off "Auto-show" to end playing it. + +## Step 5: Exit Demo + +Shut down the emulator to exit Demo. + +## FAQ + +### 1. adb command not found + +#### Reason + +The "adb" tool is not installed. + +#### Solution + +Install "adb" and execute the following command: + +``` Bash +sudo apt install android-tools-adb +``` + +### 2. Garbled text is shown + +#### Reason +Font resources are not loaded correctly. + +#### Solution + +Follow [Step 3](#step-3-launch-the-emulator-and-push-resources) to push resources. \ No newline at end of file diff --git a/bandx/README_zh-cn.md b/bandx/README_zh-cn.md new file mode 100644 index 0000000..cfdc9a2 --- /dev/null +++ b/bandx/README_zh-cn.md @@ -0,0 +1,131 @@ +# 智能手环 + +[English](README.md) | 中文 + +## 简介 + +该应用是一款智能手环演示,包括手表表盘、启动器、音乐、心率、秒表、睡眠、运动、设置、手电筒,分辨率为 194*368。 + +本文介绍如何在模拟器上运行该示例。 + +## 前提条件 + +下载源码,请参见[快速入门](https://github.com/open-vela/docs/blob/dev/zh-cn/quickstart/openvela_ubuntu_quick_start.md)。 + +## 步骤一 配置项目 + +1. 切换到 openvela 仓库的根目录,执行如下命令来配置手环 Bandx。 + + **说明**:模拟器配置文件(defconfig)在 `vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap/` 目录下,使用 `build.sh` 配置和编译模拟器的代码。 + + ```cpp + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap menuconfig + ``` + + - build.sh:编译脚本,用来配置和编译 openvela 代码 + - vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap:配置路径 + - menuconfig:打开 menuconfig 页面,修改项目代码的配置。 + +2. 按下 `/` 键逐个搜索修改如下配置项: + + ```Bash + LV_USE_FRAGMENT = y + LVX_USE_DEMO_BANDX = y + BANDX_BASE_PATH = "/data" + ``` + + 以 LV_USE_FRAGMENT 为例进行操作,其余配置方式相同。 + + 1. 输入待搜索的配置。 + 2. 按下`Enter`进入到配置页面。 + 3. 按下`Enter`键打开该配置,`[ ]` 中出现 `*` 表示该配置被打开。 + 4. 按下 `/` 键可以继续搜索剩下的配置,并按上述步骤修改其余配置。 + 5. 按下字母`Q`键,弹出退出保存界面。 + 6. 按下字母`Y`键保存配置,并退出修改配置页面。 + +## 步骤二 编译项目 + +1. 切换到 openvela 仓库的根目录,在终端内依次执行如下命令: + + ```Bash + # 清理构建产物 + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j8 + + # 开始构建 + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j8 + ``` + +2. 成功执行后,将得到以下文件: + + ```plaintext + ./nuttx + ├── vela_ap.elf + ├── vela_ap.bin + ``` + +## 步骤三 启动模拟器并推送资源 + +Bandx 中使用的字体和图像资源位于 `apps/packages/demos/bandx/resources/` 中,要将这些资源推送到模拟器挂载的相应文件路径,可以按照以下步骤操作。 + +1. 切换到 openvela 仓库的根目录,启动模拟器: + + ```bash + ./emulator.sh vela + ``` + +2. 使用模拟器支持的 `ADB` 将资源推送到设备,在 openvela 仓库的根目录下打开一个新的终端,输入 `adb push` 后跟文件路径,即可将资源传输到相应位置。 + + ```bash + # 安装adb + sudo apt install android-tools-adb + + # 推送资源 + adb push apps/packages/demos/bandx/resource/font/assets/* /data/font/ + adb push apps/packages/demos/bandx/resource/image/assets /data/image/ + ``` + + 如果将 `BANDX_BASE_PATH` 更改为非默认值,如 `/tmp`,则资源文件也必须传输到 `/tmp/font/` 和 `/tmp/image/` 目录。否则将出现找不到资源的错误。 + +## 步骤四 启动 Bandx + +1. 在模拟器的终端环境 `openvela-ap>` 中输入如下命令: + + ```Bash + bandx & + ``` + +2. 要访问 Launcher 界面,`从右向左`快速滑动。单击不同的图标导航到子页面,如 Heart Rate 页面。要退出页面,`从左向右`快速滑动。 + + **说明**:music页面只是UI展示,没有接入音频。 + +3. 打开 settings 中的 `Auto-show`,将会自动播放整个应用;关闭 `Auto-show`,自动播放就结束。 + +## 步骤五 退出 Demo + +关闭模拟器退出 Demo。 + +## 常见问题 + +### 1. adb 命令找不到 + +#### 原因 + +未安装 `adb` 工具。 + +#### 解决方案 + +安装 `adb`,执行以下命令: + +``` Bash +sudo apt install android-tools-adb +``` + +### 2. 字体显示为乱码 + +#### 原因 + +未正确加载字体资源。 + +#### 解决方案 + +请按[步骤三](#步骤三-启动模拟器并推送资源)进行资源推送。 \ No newline at end of file diff --git a/breakout/README.md b/breakout/README.md new file mode 100644 index 0000000..57a2bfc --- /dev/null +++ b/breakout/README.md @@ -0,0 +1,46 @@ +# Breakout - Brick Breaker Game + +English | [中文](README_zh-cn.md) + +A classic breakout (brick breaker) game demo built with LVGL on OpenVela/NuttX. Control a paddle to bounce a ball and destroy bricks. + +## Features + +- Classic breakout gameplay +- Touch/input-based paddle control +- LVGL-based graphics rendering +- libuv event loop integration + +## Configuration + +Enable in menuconfig: + +``` +LVX_USE_DEMO_BREAKOUT=y +LVX_BREAKOUT_DATA_ROOT="/data" +LVX_BREAKOUT_STACKSIZE=65536 +``` + +## Project Structure + +``` +breakout/ +├── src/ +│ └── breakout.h # Game logic declarations +├── breakout_main.cpp # Application entry point (C++) +├── Kconfig # NuttX configuration +├── CMakeLists.txt # CMake build script +└── Makefile # Make build script +``` + +## Usage + +```bash +nsh> breakout +``` + +## Build + +```bash +./build.sh -j8 +``` diff --git a/breakout/Readme.md b/breakout/README_zh-cn.md similarity index 91% rename from breakout/Readme.md rename to breakout/README_zh-cn.md index 18cb7a1..10ae70e 100644 --- a/breakout/Readme.md +++ b/breakout/README_zh-cn.md @@ -1,5 +1,7 @@ +[English](README.md) | 中文 + # 🎮 Breakout Game 《打砖块游戏v3.2》 -`“KUN生是旷野,不是轨道!”` 拥有对篮球无限热爱的KUN,在家族中独树一帜,正挥洒着汗水,勤奋努力的击打篮球撞碎砖块,缔造属于自己的篮球哲学。 +`"KUN生是旷野,不是轨道!"` 拥有对篮球无限热爱的KUN,在家族中独树一帜,正挥洒着汗水,勤奋努力的击打篮球撞碎砖块,缔造属于自己的篮球哲学。 🧱 开发时长不足`两年半`的作品,是基于OpenVela和LVGL开发的触屏打砖块游戏,将篮球和鸡融合到一起,已实现了基本游戏逻辑,增加了图片素材并实现了打击音效。 @@ -33,24 +35,22 @@ - **游戏状态管理**:管理游戏状态(例如:PLAYING、GAME_OVER、PAUSED)以控制游戏流程。 - -# 🖼️ Image Handling(图片处理) -## 1. libpng decoder(libpng 解码器) +# 🖼️ 图片处理 +## 1. libpng 解码器 好消息,OpenVela系统已经内置了该PNG解码器,仅需将`LIB_PNG`和`LV_USE_LIBPNG`配置为`yes`,即可轻松使用`lv_image_set_src`等函数读取使用`PNG`图片。使用方法可以参考:`https://lvgl.100ask.net/master/details/libs/libpng.html` 此外,这是libpng的github仓库链接:`https://github.com/pnggroup/libpng`,自己手动引入还是有难度。 -## 2.Image Caching(图片缓存) +## 2. 图片缓存 LVGL 支持将图像缓存到内存中,以提升图像组件在运行时的加载速度,特别适用于反复绘制的图像场景,如游戏背景、按钮图标等。 在从外部读入图片过多,会有明显卡顿,可以使用图片缓存的方法,将图片读入内存。具体可以参考:`https://lvgl.100ask.net/master/details/main-components/image.html#overview-image-caching` -# 🔊 Audio Handling(音频处理) +# 🔊 音频处理 引用了`packages_demos`仓库下的`music_player`的音频控制文件`audio_ctl.c`和`audio_ctl.h`,通过`audio_ctl_init_nxaudio`加载音频文件,`audio_ctl_start`播放音频,`audio_ctl_stop`暂停音频,`audio_ctl_uninit_nxaudio`释放资源,实现了碰撞砖块发出音效。 - -# 🚀 Getting Started 快速开始 +# 🚀 快速开始 首先进入模拟器配置 -## 1.配置模拟器(menuconfig) +## 1. 配置模拟器(menuconfig) ```bash ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap menuconfig ``` @@ -63,7 +63,8 @@ LVGL 支持将图像缓存到内存中,以提升图像组件在运行时的加 - `AUDIO`和`AUDIOUTILS_NXAUDIO_LIB`配置为`yes` (读取wav音频文件) - `Default image header cache count`配置为`18` (缓存图片数) - `Default image cache size`配置为`8388608` ,这一步设定图片内存8MB,实测只用了大概3648003,不到4MB,设为8MB这样保险一些。**在配置后,一定要先`清理构建产物`,再`重新构建`,否则`image cache max size`不会更新。** -## 2.构建和清除构建文件 + +## 2. 构建和清除构建文件 ### 开始构建 ```bash ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j$(nproc) @@ -72,37 +73,37 @@ LVGL 支持将图像缓存到内存中,以提升图像组件在运行时的加 ```bash ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j$(nproc) ``` -## 3.ADB推送更新关卡等资源(在模拟器运行状况下) + +## 3. ADB推送更新关卡等资源(在模拟器运行状况下) ```bash adb push apps/packages/demos/breakout/res /data/ ``` -## 4.启动模拟器 +## 4. 启动模拟器 ```bash ./emulator.sh vela ``` -## 5.启动游戏 +## 5. 启动游戏 ```bash breakout & ``` + --- -# ▶️ 启动游戏 + +# ▶️ 启动游戏 在 main文件函数中初始化 LVGL后,调用: ballgame_start(); // 启动游戏 - -# 🎮 Controls +# 🎮 操作说明 - 移动挡板:按住并拖动屏幕,挡板随手指水平移动。 - - 发射小球:游戏开始时,轻触屏幕即可发射小球。 - - 重新开始:掉球后点击 "Restart" 按钮重开一局。 -# 📄 Level File Format (.dat) +# 📄 关卡文件格式 (.dat) 放置关卡文件: 将 .dat 文件放到资源路径下,例如: @@ -130,6 +131,7 @@ ballgame_start(); // 启动游戏 # C # ####### ``` + **V3.0增加了三个充满激情的buff道具** - 可以呼朋引伴的友情魔法 - 让篮球无丝分裂的奇妙技艺 @@ -137,6 +139,7 @@ ballgame_start(); // 启动游戏 **好好运用,相信你一定能战胜砖块!(๑•̀ㅂ•́)و✧** **V3.1 球绘制方法更新概述** + **旧版(每球独立对象)** - 每个球都是一个独立的 LVGL 对象。 - 每帧通过 lv_obj_set_pos 移动对象。 @@ -148,7 +151,6 @@ ballgame_start(); // 启动游戏 - 每帧只需刷新一次 canvas(先填充背景去除拖影,再绘制球的新位置)。 - 显著降低对象管理开销,提升多球场景下的刷新性能。 - # 素材使用说明 - 素材来源于`https://icon.sucai999.com/`以及`https://craftpix.net` - 道具图标来源于`game-icons.net` @@ -160,5 +162,4 @@ ballgame_start(); // 启动游戏 - **Google 图片**:可在个人及商业项目中使用,需遵守 **Apache 2.0** 许可协议,并附带版权声明、许可证文本及修改声明。 - **CraftPix.net 图片**:可用于个人及商业项目,但需遵守 **CraftPix 自定义许可协议**,保留版权信息并不得单独转售源文件。 - **game-icons.net图标**:可用于个人及商业项目,但必须 署名原作者,并标明许可协议;允许修改、分发和再使用,但不得去除作者署名。 -- **freesound音频**:本作品使用的音频文件皆为 **CC0(Creative Commons 0)** 授权的资源,表示该资源已被作者明确放弃所有版权及相关权利,可自由复制、修改、分发,亦可用于个人或商业用途,无需署名、无需许可、无任何限制。 - +- **freesound音频**:本作品使用的音频文件皆为 **CC0(Creative Commons 0)** 授权的资源,表示该资源已被作者明确放弃所有版权及相关权利,可自由复制、修改、分发,亦可用于个人或商业用途,无需署名、无需许可、无任何限制。 \ No newline at end of file diff --git a/calculator/README.md b/calculator/README.md new file mode 100644 index 0000000..eec46b5 --- /dev/null +++ b/calculator/README.md @@ -0,0 +1,191 @@ +English | [中文](README_zh-cn.md) + +# Advanced Calculator - Based on open-vela + +## 📚 Table of Contents + +- [1. Introduction](#1-introduction) +- [2. Implementation](#2-implementation) +- [3. Usage Guide](#3-usage-guide) +- [📁 Project Path](#project-path) +- [🛠️ Common Commands](#common-commands) + +--- + +## 1. Introduction + +- An **advanced calculator** built on open-vela. +- The expression calculation engine is based on the repository https://github.com/W-Mai/ExpressionCalc +- `calculate` computes the result, `Clear` clears the screen, `Del` deletes the last character. +- Functions like sqrt and cos require parentheses; constants PI and E can be used directly. + For example: PI / 2, E + 4, sqrt(4), cos(-2) + +![Calculator UI](./screen_history/screenshot_commit7.png) + +The calculator supports the following features: + +### 1.1 Basic Arithmetic + +- Addition, subtraction, multiplication, and division +- Double precision arithmetic, displaying only significant digits (no trailing zeros) +- Example: displays `1.5` instead of `1.50000000` + +### 1.2 Advanced Functions +Usage example: cos(2) + +- sqrt — Square root +- log — Natural logarithm (ln) +- sin — Sine function +- cos — Cosine function +- PI — Pi constant (3.1415926...) +- E — Euler's number (2.7182818...) +- . — Decimal point +- ( — Left parenthesis +- ) — Right parenthesis + +### 1.3 Smart Input After Result + +- After a result is displayed, entering a new number automatically clears the screen +- If an operator is entered, the result is retained and computation continues + +--- + +## 2. Implementation + +### 2.1 Token Levels and Operator Precedence + +- Operator priority is defined via TokenLevel. For example, + and - have priority 1, while *, /, % have priority 2. +- This enables correct operator precedence when processing reverse Polish notation. + +### 2.2 Expression Parsing +- The `reversePolishNotation` method converts infix expressions (e.g., `a + b * c`) to reverse Polish notation (e.g., `a b c * +`) using a stack to handle operators and parentheses. +- Numbers are added directly to the result queue. +- Operators are pushed/popped based on their precedence. +- Left parentheses are pushed onto the stack; right parentheses pop operators until a left parenthesis is found. + +### 2.3 Reverse Polish Notation Evaluation + +- The `evalNotation` method evaluates reverse Polish notation using a stack. +- Numbers are pushed onto the stack. +- When an operator is encountered, operands are popped, computed, and the result is pushed back. +- Supports both custom and built-in operators: +, -, *, sin, log, etc. + +### 2.4 Dynamic Button Creation with LVGL `create_button()` + +- Buttons are dynamically created via the `create_button()` function. +- A 2D `btn_map` configures button layout for easy maintenance and extension. +- LVGL component functions set button and input field sizes, positions, and colors. + +### 2.5 Input Protection + +- Invalid input (e.g., multiple `.`, square root of negative numbers, division by zero) displays `ERROR`. +- Delete, clear, and error reset operations are fully handled to ensure stable operation. + +--- + +## 3. Usage Guide + +### 3.1 Configure the Emulator (menuconfig) +```bash +./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap menuconfig +``` + +#### (1) Build Settings +- Set `LVX_USE_DEMO_CALCULATOR` to `yes` +- Set `LVX_CALCULATOR_DATA_ROOT` to `/data` (default in Kconfig) + +#### (2) C++ Header Configuration +To support C++ headers (e.g., iostream.h, cmath.h): +- Set C++ library to `Toolchain C++ support` +- Set C++ low level library select to `GNU low level libsupc++` +- Set Language standard to `(gnu++20)` + +For try-catch exception handling (not recommended for embedded, not used in current version): +- Enable `exception support` + +### 3.2 Makefile Build Issues + +#### (1) Main Function Not Found +``` +arm-none-eabi-ld: ... undefined reference to calculator_main' +``` +- Because the Makefile sets `PROGNAME = calculator`, the linker expects a function named `int calculator_main(int argc, char *argv[])`. +- You must also add `extern "C"`, so the main function should be `extern "C" int calculator_main` to compile successfully. + +#### (2) Makefile Configuration +- Since C++ files are used, add `CXXEXT` to specify .cpp files: +``` +CXXEXT := .cpp +``` +- C++ source files must be listed under `CXXSRCS`: +``` +CXXSRCS = calculator_cre.cpp expression_calc.cpp +``` + +### 3.3 Resource Management + +#### (1) Built-in Resource Mode (Recommended, enabled by default) +Enable `use the builtin resources` in menuconfig (default `y`): +- Fonts and images are compiled into the firmware, no additional push needed +- ELF size increases +- Pros: Simple deployment, no adb push required +- Use case: Production, quick testing + +#### (2) File System Resource Mode +Disable `use the builtin resources` in menuconfig (set to `n`): +- Resources must be pushed via ADB while the emulator is running: + +Start the emulator: +```bash +./emulator.sh vela +``` + +Push resources via ADB: +```bash +adb push apps/packages/demos/calculator/res /data/ +``` + +Launch the calculator: +```bash +calculator & +``` + +- Pros: Dynamically replaceable resources, smaller ROM footprint +- Use case: Development, frequent UI resource changes + +## 📁 Project Path +vela-opensource/apps/packages/demos/calculator/ + +--- + +## 🛠️ Common Commands + +### Build +```bash +./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j$(nproc) +``` + +### Configure Emulator (menuconfig) +```bash +./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap menuconfig +``` + +### Push Resources via ADB (file system resource mode, emulator running) +```bash +adb push apps/packages/demos/calculator/res /data/ +``` + +### Clean Build Artifacts +```bash +./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j$(nproc) +``` + +### Start Emulator +```bash +./emulator.sh vela +``` + +### Launch Calculator +```bash +calculator & +``` \ No newline at end of file diff --git a/calculator/Readme.md b/calculator/README_zh-cn.md similarity index 85% rename from calculator/Readme.md rename to calculator/README_zh-cn.md index e9a3f11..a8f760b 100644 --- a/calculator/Readme.md +++ b/calculator/README_zh-cn.md @@ -1,25 +1,13 @@ +[English](README.md) | 中文 + # 高级计算器 - 基于 open-vela ## 📚 目录 -- [一、基本介绍](#一基本介绍) - - [1.1 基本四则运算](#1-基本四则运算) - - [1.2 高级计算支持](#2-高级计算支持) - - [1.3 结果后输入智能处理](#3-结果后输入智能处理) - -- [二、实现思路](#二实现思路) - - [2.1 Token 级别与运算符优先级](#1-token-级别与运算符优先级) - - [2.2 表达式解析](#2-表达式解析) - - [2.3 逆波兰表示法计算](#3-逆波兰表示法计算) - - [2.4 基于 LVGL 使用 create_button() 动态创建按键](#4-基于-lvgl-使用-create_button-动态创建按键) - - [2.5 输入保护机制](#5-输入保护机制) - -- [三、使用说明](#三使用说明) - - [3.1 配置模拟器(menuconfig)](#1配置模拟器menuconfig) - - [3.2 makefile 编译问题](#2makefile编译问题) - - [3.3 资源推送更新 /res](#3资源推送更新-res) - -- [📁 原工程路径](#原工程路径) +- [一、基本介绍](#一基本介绍) +- [二、实现思路](#二实现思路) +- [三、使用说明](#三使用说明) +- [📁 原工程路径](#原工程路径) - [🛠️ 常用指令](#常用指令) --- @@ -38,7 +26,7 @@ ### 1. 基本四则运算 - 支持加、减、乘、除运算 -- 运算支持 double 精度,仅显示有效数字,不显示多余的 `0` +- 运算支持 double 精度,仅显示有效数字,不显示多余的 `0` - 例如:显示 `1.5`,而不是 `1.50000000` ### 2. 高级计算支持 @@ -58,6 +46,7 @@ - 运算结果显示后,再次输入新数字会自动清屏 - 如果输入的是运算符,则保留结果并继续运算 + --- ## 二、实现思路 @@ -65,48 +54,34 @@ ### 1. Token 级别与运算符优先级 - 通过 TokenLevel 来定义每个操作符的优先级。例如,+ 和 - 的优先级是 1,而 *, /, % 等是 2。 - - 这样就能在处理逆波兰表示法时判断操作符的优先级,确保正确的运算顺序。 - ### 2. 表达式解析 - reversePolishNotation 方法负责将输入的中缀表达式(例如 a + b * c)转换为逆波兰表示法(如 a b c * +)。这个过程使用了栈来处理操作符和括号。 - - 当遇到数字时,直接将其添加到结果队列。 - - 当遇到操作符时,根据其优先级判断是否需要弹出栈中的操作符。 - - 遇到左括号 ( 时,压入栈中,右括号 ) 时,弹出栈中的操作符直到遇到左括号。 - ### 3. 逆波兰表示法计算 - evalNotation 方法通过栈来计算逆波兰表示法的结果。 - - 如果遇到数字,将其压入栈中。 - - 如果遇到运算符,从栈中弹出参数并进行计算,然后将结果压回栈中。 - - 支持的运算符可以是自定义的,也可以是内置的,如 +, -, *, sin, log 等。 - ### 4. 基于 LVGL 使用 `create_button()` 动态创建按键 - 通过 `create_button()` 函数动态创建按键 - - 使用二维 `btn_map` 配置按钮排布,便于维护和扩展 - - 使用 LVGL 的组件函数设置按钮及输入框,设定合理设置尺寸和位置,颜色 ### 5. 输入保护机制 - 输入非法或不符合规则(如多个 `.`、负数开根号、除以零等)时,运算显示 `ERROR` - - 删除、清除、错误重置等操作处理完善,确保系统稳定运行 --- - ## 三、使用说明 首先进入模拟器配置 ### 1.配置模拟器(menuconfig) @@ -126,7 +101,6 @@ 如果使用异常处理机制try-catch,需要开启以下设置(嵌入式中不推荐,当前版本已不使用该机制) - enable exception support - ### 2.makefile编译问题 #### (1)编译找不到Main函数 @@ -144,7 +118,7 @@ CXXEXT := .cpp ``` - 并且C++文件需要使用CXXSRCS标出,如 ``` -CXXSRCS = calculator_cre.cpp expression_calc.cpp +CXXSRCS = calculator_cre.cpp expression_calc.cpp ``` ### 3.资源管理方式 @@ -178,7 +152,6 @@ calculator & - 优点:可动态更换资源,ROM 占用小 - 适用场景:开发调试、频繁更换 UI 资源 - ## 📁原工程路径 vela-opensource/apps/packages/demos/calculator/ @@ -187,7 +160,6 @@ vela-opensource/apps/packages/demos/calculator/ ## 🛠️常用指令 ### 开始构建 - ```bash ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j$(nproc) ``` @@ -213,14 +185,4 @@ adb push apps/packages/demos/calculator/res /data/ ### 启动计算器应用 ```bash calculator & -``` ---- - - - - - - - - - +``` \ No newline at end of file diff --git a/hourglass/README.md b/hourglass/README.md new file mode 100644 index 0000000..a0eee61 --- /dev/null +++ b/hourglass/README.md @@ -0,0 +1,79 @@ +English | [中文](README_zh-cn.md) + +# Hourglass Demo + +## Overview +A digital hourglass demo application running on the OpenVela system emulator. It uses the LVGL graphics library to create a visual hourglass effect, where users can control the hourglass start and timer duration via touchscreen. + +## Features +- Realistic hourglass animation: simulates sand particles flowing from top to bottom. +- Interactive controls: + - Start/Reset: start or reset the hourglass timer. + - Time adjustment: increase or decrease the total timer duration. +- Modular design: UI and control logic are separated for easy maintenance and extension. + +## Prerequisites +- OpenVela development environment set up (Reference: [Environment Setup](https://gitee.com/open-vela/docs/blob/dev/zh-cn/quickstart/Set_up_the_development_environment_zh-cn.md)) +- OpenVela source code obtained (Reference: [Download OpenVela Source](https://gitee.com/open-vela/docs/blob/dev/zh-cn/quickstart/Download_Vela_sources_zh-cn.md)) + +## Getting Started + +### 1. Configure the Project +```bash +./build.sh vendor/openvela/boards/vela/configs/qemu-armeabi-v7a-ap/ distclean -j$(nproc) menuconfig +``` +In the configuration interface: +- Press `/` to search for `LVX_USE_DEMO_HOURGLASS`. +- Press Enter to navigate to the option. +- Press Space to mark it as `[*]` (i.e., `=y`) to enable the demo. +- Press `Q` multiple times to exit, and press `Y` when prompted to save. + +Note: Other related configurations (device path, task priority, etc.) are pre-configured and do not need modification unless you have special requirements. + +### 2. Build +```bash +./build.sh vendor/openvela/boards/vela/configs/qemu-armeabi-v7a-ap/ -j$(nproc) +``` + +Clean build artifacts: +```bash +./build.sh vendor/openvela/boards/vela/configs/qemu-armeabi-v7a-ap/ distclean -j$(nproc) +``` + +### 3. Run the Demo +Start the emulator: +```bash +./emulator.sh vela +``` + +Launch the hourglass application: +```bash +hourglass & +``` + +## Project Structure +``` +vela/packages/demos/hourglass/ +├── hourglass_page.c/h # UI rendering, button event handling +├── hourglass_control.c/h # Core hourglass animation control logic and state machine +├── hourglass_main.c # Program entry point, task initialization +├── Kconfig # Configuration options (enable, priority, device path, etc.) +├── Make.defs # Build system dependency definitions +└── Makefile # Build rules +``` + +## Core Implementation + +### UI +- Hourglass body: Composed of two 45-degree rotated square containers, each dynamically creating an 8x8 matrix of red squares to simulate sand particles. +- Control panel: Contains Start button and +/- buttons for controlling the hourglass and adjusting time. + +### Control Logic +- State machine: Manages three states — initial, running, and finished. +- Timer-driven: Core animation is periodically triggered by an LVGL timer. +- Sand movement algorithm: Uses diagonal scanning with random direction strategy, moving one "sand particle" (changing a square's color) at a time to simulate natural falling. + +## Troubleshooting +- Demo not starting: Verify that `LVX_USE_DEMO_HOURGLASS` is correctly set to `y` in the configuration step. +- Touch not responding: Check that the device path configured in `LVX_USE_DEMO_HOURGLASS_DEVPATH` matches the actual system device node. +- Build errors: Ensure the development environment is properly set up and a thorough `distclean` has been performed. \ No newline at end of file diff --git a/hourglass/README_zh-cn.md b/hourglass/README_zh-cn.md new file mode 100644 index 0000000..ac5dd93 --- /dev/null +++ b/hourglass/README_zh-cn.md @@ -0,0 +1,79 @@ +[English](README.md) | 中文 + +# 电子沙漏 Demo (Hourglass Demo) + +## 项目简介 +这是一个基于openvela系统,在模拟器上运行的电子沙漏演示程序。它使用LVGL图形库创建了一个可视化的沙漏效果,用户可以通过触摸屏控制沙漏的启动和计时时间。 + +## 功能特性 +- 逼真的沙漏动画:模拟沙粒从上至下的流动效果。 +- 交互控制: + - 开始/重置:启动或重置沙漏计时。 + - 时间调整:增加或减少沙漏的总计时时间。 +- 模块化设计:UI界面与控制逻辑分离,便于维护和扩展。 + +## 前提条件 +- 已搭建OpenVela开发环境(参考:[环境搭建](https://gitee.com/open-vela/docs/blob/dev/zh-cn/quickstart/Set_up_the_development_environment_zh-cn.md)) +- 已获取OpenVela源码(参考:[下载openvela源码](https://gitee.com/open-vela/docs/blob/dev/zh-cn/quickstart/Download_Vela_sources_zh-cn.md)) + +## 快速开始 + +### 1. 配置项目 +```bash +./build.sh vendor/openvela/boards/vela/configs/qemu-armeabi-v7a-ap/ distclean -j$(nproc) menuconfig +``` +在打开的配置界面中,进行如下操作: +- 按下 / 键,搜索 LVX_USE_DEMO_HOURGLASS。 +- 按回车键进入该配置项。 +- 按下空格键,将选项标记为 [*] (即 =y) 以启用该Demo。 +- 多次按 Q 键退出,并在提示是否保存时按 Y 键。 + +注意:其他相关配置(如设备路径、任务优先级等)已预设好,无需修改,除非有特殊需求。 + +### 2. 编译与构建 +```bash +./build.sh vendor/openvela/boards/vela/configs/qemu-armeabi-v7a-ap/ -j$(nproc) +``` + +清理构建产物: +```bash +./build.sh vendor/openvela/boards/vela/configs/qemu-armeabi-v7a-ap/ distclean -j$(nproc) +``` + +### 3. 运行Demo +启动模拟器: +```bash +./emulator.sh vela +``` + +启动沙漏应用: +```bash +hourglass & +``` + +## 项目结构 +``` +vela/packages/demos/hourglass/ +├── hourglass_page.c/h # UI界面绘制、按钮事件处理 +├── hourglass_control.c/h # 沙漏动画的核心控制逻辑与状态机 +├── hourglass_main.c # 程序入口,任务初始化 +├── Kconfig # 项目配置选项(使能、优先级、设备路径等) +├── Make.defs # 编译系统依赖项定义 +└── Makefile # 编译规则 +``` + +## 核心实现说明 + +### UI界面 +- 沙漏主体:由两个旋转45度的正方形容器构成,每个容器内动态创建8x8的红色小方块矩阵来模拟沙粒。 +- 控制面板:包含Start按钮和+/-按钮,用于控制沙漏运行和调整时间。 + +### 控制逻辑 +- 状态机:管理沙漏的初始、运行、结束三种状态。 +- 定时器驱动:核心动画由LVGL定时器周期性触发。 +- 沙粒移动算法:使用对角线扫描与随机方向策略,每次移动一粒"沙粒"(即改变一个小方块的颜色),模拟自然下落。 + +## 故障排除 +- Demo未启动:请确认配置步骤中 LVX_USE_DEMO_HOURGLASS 已正确设置为 y。 +- 触摸无响应:检查 LVX_USE_DEMO_HOURGLASS_DEVPATH 配置的设备路径是否与系统实际设备节点匹配。 +- 编译错误:确保开发环境已正确搭建,并执行过彻底的 distclean。 \ No newline at end of file diff --git a/hourglass/Readme.md b/hourglass/Readme.md deleted file mode 100644 index 7f7da3b..0000000 --- a/hourglass/Readme.md +++ /dev/null @@ -1,79 +0,0 @@ -电子沙漏 Demo (Hourglass Demo) -项目简介 -这是一个基于openvela系统,在模拟器上运行的电子沙漏演示程序。它使用LVGL图形库创建了一个可视化的沙漏效果,用户可以通过触摸屏控制沙漏的启动和计时时间。 -功能特性 -逼真的沙漏动画:模拟沙粒从上至下的流动效果。 -交互控制: -开始/重置:启动或重置沙漏计时。 -时间调整:增加或减少沙漏的总计时时间。 -模块化设计:UI界面与控制逻辑分离,便于维护和扩展。 -前提条件: -已搭建OpenVela开发环境(参考:[环境搭建](https://gitee.com/open-vela/docs/blob/dev/zh-cn/quickstart/Set_up_the_development_environment_zh-cn.md)) -已获取OpenVela源码(参考:[下载openvela源码](https://gitee.com/open-vela/docs/blob/dev/zh-cn/quickstart/Download_Vela_sources_zh-cn.md)) -快速开始 -1. 配置项目 -### 打开功能选项 -```bash -./build.sh vendor/openvela/boards/vela/configs/qemu-armeabi-v7a-ap/ distclean -j$(nproc) menuconfig -``` -在打开的配置界面中,进行如下操作: -按下 / 键,搜索 LVX_USE_DEMO_HOURGLASS。 -按回车键进入该配置项。 -按下空格键,将选项标记为 [*] (即 =y) 以启用该Demo。 -多次按 Q 键退出,并在提示是否保存时按 Y 键。 -注意:其他相关配置(如设备路径、任务优先级等)已预设好,无需修改,除非有特殊需求。 -2. 编译与构建 -在源码根目录下,依次执行以下命令: -### 构建 -```bash -./build.sh vendor/openvela/boards/vela/configs/qemu-armeabi-v7a-ap/ -j$(nproc) -``` - -### 清理构建产物 -```bash -./build.sh vendor/openvela/boards/vela/configs/qemu-armeabi-v7a-ap/ distclean -j$(nproc) -``` - -3. 运行Demo -### 启动模拟器 -```bash -./emulator.sh vela -``` - -### 启动计算器应用 -```bash -hourglass & -``` - -项目结构 -text -vela/packages/demos/hourglass/ -├── hourglass_page.c/h # UI界面绘制、按钮事件处理 -├── hourglass_control.c/h # 沙漏动画的核心控制逻辑与状态机 -├── hourglass_main.c # 程序入口,任务初始化 -├── Kconfig # 项目配置选项(使能、优先级、设备路径等) -├── Make.defs # 编译系统依赖项定义 -└── Makefile # 编译规则 -核心实现说明 -UI界面 -沙漏主体:由两个旋转45度的正方形容器构成,每个容器内动态创建8x8的红色小方块矩阵来模拟沙粒。 -控制面板:包含Start按钮和+/-按钮,用于控制沙漏运行和调整时间。 -控制逻辑 -状态机:管理沙漏的初始、运行、结束三种状态。 -定时器驱动:核心动画由LVGL定时器周期性触发。 -沙粒移动算法:使用对角线扫描与随机方向策略,每次移动一粒“沙粒”(即改变一个小方块的颜色),模拟自然下落。 -故障排除 -Demo未启动:请确认配置步骤中 LVX_USE_DEMO_HOURGLASS 已正确设置为 y。 -触摸无响应:检查 LVX_USE_DEMO_HOURGLASS_DEVPATH 配置的设备路径是否与系统实际设备节点匹配。 -编译错误:确保开发环境已正确搭建,并执行过彻底的 distclean。 - ---- - - - - - - - - - diff --git a/music_player/README.md b/music_player/README.md new file mode 100644 index 0000000..e33d277 --- /dev/null +++ b/music_player/README.md @@ -0,0 +1,160 @@ +# Music Player + +English | [中文](README_zh-cn.md) + +## Introduction + +This article describes how to run the music player demo on Emulator. + +## Prerequisites + +To download the source code, see [Quick Start](https://github.com/open-vela/docs/blob/dev/en/quickstart/openvela_ubuntu_quick_start.md). + +## Step 1: Configure the project + +1. Switch to the root directory of openvela repository and execute the following command to configure the music player. + + **Note**: The emulator configuration file (defconfig) is in the "vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap/" directory, and the development board code is configured and compiled using "build.sh". + + ```Bash + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap menuconfig + ``` + + - build.sh: A script for compilation used to configure and compile openvela code. + - vendor/openvela/boards/vela/configs/\*: configuration path + - menuconfig: Open the menuconfig page to modify the configuration of the project code. + +2. Press the "/" key to search and modify the following configurations: + + ```Bash + LVX_USE_DEMO_MUSIC_PLAYER=y + LVX_MUSIC_PLAYER_DATA_ROOT="/data" + ``` + + **Note**: Take LVX_USE_DEMO_MUSIC_PLAYER as an example for illustration. The other configurations are modified is the same way. + + 1. Enter the configuration "LVX_USE_DEMO_MUSIC_PLAYER" to be searched. Fuzzy search is supported; for example, "music_player" will get the corresponding configuration. Press the Enter key to enter that configuration. + 2. Press the spacebar, and a \* that appears in [ ] indicates that the configuration is turned on. + 3. Set "LVX_MUSIC_PLAYER_DATA_ROOT" to "/data", and press Enter to save the current configuration. + 4. Press the letter Q to bring up the exit Save screen. + 5. Press the letter Y to save the configuration and exit the Modify Configuration page. + +## Step 2: Compile the project + +1. Switch to the root directory of openvela repository and execute the following commands one by one in a terminal: + + ```Bash + # Clean up build artifacts + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j8 + + # Start to build + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j8 + ``` + +2. After successful execution, you will get the following files: + + ```plaintext + ./nuttx + ├── vela_ap.elf + ├── vela_ap.bin + ``` + +## Step 3: Launch the emulator and push resources + +The font and image resources used by the music player are located in "apps/packages/demos/music_player/res". To push these resources to the corresponding file paths mounted by the emulator, follow the steps below. + +1. Switch to the root directory of openvela repository and start the emulator: + + ```Bash + ./emulator.sh vela + ``` + +2. Push resources to the device by using emulator-supported ADB. Open a new terminal in the root directory of openvela repository, type "adb push" followed by the file path to transfer the resources to the appropriate location. + + ```Bash + #Install adb + sudo apt install android-tools-adb + + #Push resources + adb push apps/packages/demos/music_player/res /data/ + ``` + +## Step 4: Start the music player + +Enter the following command in the emulator's terminal environment "openvela-ap": + +```Bash +music_player & +``` + +## Step 5: Exit Demo + +Shut down the emulator to exit Demo. + +## FAQ + +### How to customize the music player? + +1. Modify the configuration under "apps/packages/demos/music_player/res" to add new music media files in the "res/musics" directory. Only the "\*.wav" format is currently supported. You can convert file formats "\*.mp3/aac/m4a" to "\*.wav". Then, modify the "res/musics/manifest.json" file in that directory: + + ```JSON + { + "musics": [ + { + "path": "UnamedRhythm.wav", + "name": "UnamedRhythm", + "artist": "Benign X", + "cover": "UnamedRhythm.png", + "total_time": 12000, + "color": "#114514" + } + ] + } + ``` + +2. Add the media item you want to play to that configuration file. Refer to the format: + + | Parameters | Description of parameters | + | :--------- | :---------------------------------------------------------------- | + | path | File path of the media item to be played | + | name | Name of the media item | + | artist | Name of the artist | + | cover | Cover path. If no cover is provided, the cover will be displayed. | + | total_time | The total playing duration of the media item in "milliseconds". | + | color | Theme color, not currently used. | + + For example, to add music "Happiness.wav" with a playing time of 186,507 ms, you can modify it as follows. + + ```JSON + { + "musics": [ + { + "path": "UnamedRhythm.wav", + "name": "UnamedRhythm", + "artist": "Benign X", + "cover": "UnamedRhythm.png", + "total_time": 12000, + "color": "#114514" + }, + { + "path": "Happiness.wav", + "name": "Xin", + "artist": "Tang", + "cover": "Good.png", + "total_time": 186507, + "color": "#252525" + } + ] + } + ``` + +3. After modifying the configuration, you need to push resources again by executing the following command: + + ```Bash + # Push resources + adb push apps/packages/demos/music_player/res /data/ + ``` + +4. Exit the emulator. + +5. Execute [Step 3](#step-3-launch-the-emulator-and-push-resources) and [Step 4](#step-4-start-the-music-player) again. \ No newline at end of file diff --git a/music_player/README_zh-cn.md b/music_player/README_zh-cn.md new file mode 100644 index 0000000..db57388 --- /dev/null +++ b/music_player/README_zh-cn.md @@ -0,0 +1,160 @@ +# 音乐播放器 + +[English](README.md) | 中文 + +## 简介 + +本文介绍如何在模拟器中运行音乐播放器 Demo。 + +## 前提条件 + +下载源码,请参见[快速入门](https://github.com/open-vela/docs/blob/dev/zh-cn/quickstart/openvela_ubuntu_quick_start.md)。 + +## 步骤一 配置项目 + +1. 切换到 openvela 仓库的根目录,执行如下命令来配置音乐播放器。 + + **说明**:模拟器配置文件(defconfig)在 `vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap/` 目录下,使用 `build.sh` 配置和编译开发板的代码。 + + ```Bash + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap menuconfig + ``` + + - build.sh:编译脚本,用来配置和编译 openvela 代码 + - vendor/openvela/boards/vela/configs/*:配置路径 + - menuconfig:打开 menuconfig 页面,修改项目代码的配置。 + +2. 按下 `/` 键逐个搜索修改如下配置: + + ```Bash + LVX_USE_DEMO_MUSIC_PLAYER=y + LVX_MUSIC_PLAYER_DATA_ROOT="/data" + ``` + + **说明**:以 LVX_USE_DEMO_MUSIC_PLAYER为例进行操作,其余配置方式相同。 + + 1. 输入待搜索的配置 `LVX_USE_DEMO_MUSIC_PLAYER`,支持模糊搜索,例如 `music_player`,找到对应的配置,按回车键进入该配置。 + 2. 按下空格键,`[ ]` 中出现 `*` 表示打开该配置。 + 3. 将 `LVX_MUSIC_PLAYER_DATA_ROOT` 设置为 `/data`,修改后按下回车键保存当前配置项。 + 4. 按下 `Q` 键,弹出退出保存界面。 + 5. 按下字母`Y` 键保存配置,退出修改配置页面。 + +## 步骤二 编译项目 + +1. 切换到 openvela 仓库的根目录,在终端内依次执行如下命令: + + ```Bash + # 清理构建产物 + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j8 + + # 开始构建 + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j8 + ``` + +2. 成功执行后,将得到以下文件: + + ```Bash + ./nuttx + ├── vela_ap.elf + ├── vela_ap.bin + ``` + +## 步骤三 启动模拟器并推送资源 + +音乐播放器运行中会使用到的字体和图片资源位于 `apps/packages/demos/music_player/res` 中。要将这些资源推送到模拟器挂载的相应文件路径,可以按照以下步骤操作。 + +1. 切换到 openvela 仓库的根目录,启动模拟器: + + ```Bash + ./emulator.sh vela + ``` + +2. 使用模拟器支持的 ADB 将资源推送到设备,在 openvela 仓库的根目录下打开一个新的终端,输入 adb push 后跟文件路径,即可将资源传输到相应位置。 + + ```Bash + # 安装adb + sudo apt install android-tools-adb + + # 推送资源 + adb push apps/packages/demos/music_player/res /data/ + ``` + +## 步骤四 启动音乐播放器 + +在模拟器的终端环境 `openvela-ap>` 中输入如下命令: + +```Bash +music_player & +``` + +## 步骤五 退出 Demo + +关闭模拟器退出 Demo。 + +## 常见问题 + +### 如何自定义音乐播放器 + +1. 修改 `apps/packages/demos/music_player/res` 下面的相关配置,在 `res/musics` 目录下增加新的音乐媒体文件,格式目前只支持 `*.wav`,可以自行将 `*.mp3/aac/m4a` 等格式的媒体文件转换为 `*.wav` 格式。然后修改该目录下的 `res/musics/manifest.json` 文件: + + ```JSON + { + "musics": [ + { + "path": "UnamedRhythm.wav", + "name": "UnamedRhythm", + "artist": "Benign X", + "cover": "UnamedRhythm.png", + "total_time": 12000, + "color": "#114514" + } + ] + } + ``` + +2. 将想要播放的媒体添加到该配置文件中,参考该格式: + + | 参数 | 参数说明 | + | :--------- | :--------------------------------------- | + | path | 待播放媒体的文件路径 | + | name | 媒体名 | + | artist | 艺术家名 | + | cover | 封面路径,如果没有提供封面,会展示封面。 | + | total_time | 该媒体的总播放时长,单位为 `毫秒`。 | + | color | 主题色,目前还没有使用。 | + + 例如:添加一个,`Happiness.wav` 播放时长为 `186,507 ms` 的音乐,可以按如下方式修改。 + + ```JSON + { + "musics": [ + { + "path": "UnamedRhythm.wav", + "name": "UnamedRhythm", + "artist": "Benign X", + "cover": "UnamedRhythm.png", + "total_time": 12000, + "color": "#114514" + }, + { + "path": "Happiness.wav", + "name": "Xin", + "artist": "Tang", + "cover": "Good.png", + "total_time": 186507, + "color": "#252525" + } + ] + } + ``` + +3. 修改完配置后,需要重新推送资源,执行如下命令: + + ```Bash + # 推送资源 + adb push apps/packages/demos/music_player/res /data/ + ``` + +4. 退出模拟器。 + +5. 重新执行[步骤三](#步骤三-启动模拟器并推送资源)和[步骤四](#步骤四-启动音乐播放器)。 \ No newline at end of file diff --git a/music_player2/README-en.md b/music_player2/README-en.md deleted file mode 100644 index 13e9d4e..0000000 --- a/music_player2/README-en.md +++ /dev/null @@ -1,258 +0,0 @@ -# music_player2 - -music_player2 is an embedded music player designed based on the openvela system. It provides a UI interface with support for audio playback, playlist management, splash screen, volume control, and other features. Built with a modular architecture design for easy extension and maintenance. - -## Table of Contents - -- [Features](#features) -- [System Requirements](#system-requirements) -- [Project Structure](#project-structure) -- [Getting Started](#getting-started) -- [User Guide](#user-guide) -- [Customization Guide](#customization-guide) -- [Contributing](#contributing) - -## Detailed Documentation - -- [Troubleshooting Guide](docs/en/TROUBLESHOOTING.md) -- [Technical Documentation](docs/en/TECHNICAL.md) -- [Changelog](docs/en/CHANGELOG.md) - -## Features - -### Core Features -- Audio playback control -- Previous/next track switching -- Volume adjustment control -- Playlist management -- Real-time playback progress display -- Top status bar (time, date, Wi-Fi, battery) - -### Interface Features -- Splash screen: Logo animation and loading effects -- Rectangle adaptation: Optimized for simulator rectangular screen -- Volume bar: Visual volume control -- Scrolling song information: Long titles automatically scroll - -### System Features -- Wi-Fi network connection management -- Complete file system integration -- JSON configuration file management -- Real-time system resource monitoring -- Modular architecture design - -## System Requirements - -### Hardware Requirements -ARM architecture embedded devices with audio output and display capabilities. - -### Software Requirements -- **Operating System**: openvela -- **Graphics Library**: LVGL -- **Audio Library**: NuttX Audio Framework / Simulator Audio Controller -- **Network**: Wi-Fi driver support - -### Development Environment -- **Compiler**: arm-none-eabi-gcc -- **Build System**: Make / NuttX Build System -- **Debug Tools**: ADB -- **Host System**: Linux -- **Emulator**: QEMU - -## Project Structure - -``` -music_player2/ -├── music_player2.c -├── music_player2.h -├── music_player2_main.c -├── splash_screen.c -├── playlist_manager.c -├── playlist_manager.h -├── audio_ctl.c -├── audio_ctl.h -├── font_config.c -├── font_config.h -├── wifi.c -├── wifi.h -├── Kconfig -├── Makefile -├── Make.defs -├── README.md -├── README-en.md -├── docs/ -│ ├── ch/ -│ └── en/ -└── res/ - ├── fonts/ - ├── icons/ - ├── musics/ - └── config.json -``` - -## Getting Started - -### Environment Setup -```bash -# Install necessary tools -sudo apt update && sudo apt install -y android-tools-adb build-essential git - -# Clone openvela repository -git clone && cd vela_code -``` - -### Configuration and Build -```bash -# Configure music player -echo "CONFIG_LVX_USE_DEMO_VELA_AUDIO=y" >> vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap/defconfig -echo 'CONFIG_LVX_MUSIC_PLAYER_DATA_ROOT="/data"' >> vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap/defconfig - -# Build project -./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j8 -./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j8 -``` - -### Startup and Deployment -```bash -cd nuttx && ln -sf vela_ap.elf nuttx && cd .. -./emulator.sh vela -sleep 15 && adb connect 127.0.0.1:5555 -adb -s emulator-5554 push apps/packages/demos/music_player2/res /data/ -adb -s emulator-5554 shell "music_player2 &" -``` - -### Configuration File Description - -#### config.json - Wi-Fi Configuration -```json -{ - "wifi": { - "ssid": "vela_network", - "pswd": "vela123456" - } -} -``` - -#### manifest.json - Music Configuration -```json -{ - "musics": [ - { - "path": "test.mp3", - "name": "Test Song", - "artist": "Demo Artist", - "cover": "test.png", - "total_time": 180000, - "color": "#4A90E2" - } - ] -} -``` - -## User Guide - -### Basic Operations -1. **Play/Pause**: Click the central play button -2. **Previous/Next**: Click the left/right arrow buttons -3. **Volume Control**: Click the volume button to show volume bar -4. **Open Playlist**: Click the playlist button -5. **Select Song**: Click the desired song in the list - -### Debug Mode -Enable debug mode by adding the `-DDEBUG` flag during compilation: -```bash -make CFLAGS="-DDEBUG" -``` - -## Customization Guide - -### Adding New Music - -#### 1. Prepare Audio Files -```bash -convert cover.jpg -resize 300x300 cover.png -``` - -#### 2. Update Configuration File -```json -{ - "musics": [ - { - "path": "new_song.mp3", - "name": "New Song Title", - "artist": "Artist Name", - "cover": "new_cover.png", - "total_time": 240000, - "color": "#FF5722" - } - ] -} -``` - -#### 3. Deploy Files -```bash -# Copy files to resource directory -cp new_song.mp3 res/musics/ -cp new_cover.png res/musics/ - -# Push to device -adb push res/musics/ /data/res/musics/ -``` - -### Interface Customization - -#### Modify Theme Colors -```c -// Modify in music_player2.c -#define MODERN_PRIMARY_COLOR lv_color_hex(0x00BFFF) -#define MODERN_SECONDARY_COLOR lv_color_hex(0xFF6B6B) -#define MODERN_BACKGROUND_COLOR lv_color_hex(0x121212) -``` - -#### Adjust Interface Layout -```c -// Modify resolution adaptation -#define SCREEN_WIDTH 1280 -#define SCREEN_HEIGHT 800 - -// Adjust component sizes -#define COVER_SIZE 200 -#define BUTTON_SIZE 60 -``` - -## Contributing - -### Development Process -1. Fork the project -2. Create feature branch -3. Develop and test -4. Submit changes -5. Create Pull Request - -### Code Standards -- Function naming: snake_case -- Variable naming: snake_case -- Constant naming: UPPER_CASE -- Structure naming: snake_case_t - -### Commit Message Standards -- feat: New feature -- fix: Bug fix -- docs: Documentation update -- style: Code formatting adjustment -- refactor: Refactoring -- test: Test related - -## License - -This project is licensed under the Apache License 2.0 open source license. - -## Acknowledgments - -- **openvela**: Providing embedded operating system platform -- **LVGL Community**: Providing graphics library and UI component support - ---- - -*Last updated: 2025-10-29* -*Current version: v2.3.3* diff --git a/music_player2/README.md b/music_player2/README.md index ccdd88a..678147a 100644 --- a/music_player2/README.md +++ b/music_player2/README.md @@ -1,65 +1,67 @@ # music_player2 -music_player2是一个嵌入式音乐播放器,基于 openvela 系统设计。提供 UI 界面,支持音频播放、播放列表管理、启动页面、音量控制等功能。采用模块化架构设计,易于扩展和维护。 - -## 目录 - -- [功能特性](#功能特性) -- [系统要求](#系统要求) -- [项目结构](#项目结构) -- [启动指南](#启动指南) -- [使用指南](#使用指南) -- [自定义指南](#自定义指南) -- [贡献指南](#贡献指南) - -## 详细文档 - -- [故障排除指南](docs/ch/TROUBLESHOOTING.md) -- [技术文档](docs/ch/TECHNICAL.md) -- [更新日志](docs/ch/CHANGELOG.md) - -## 功能特性 - -### 核心功能 -- 音频播放控制 -- 上一首/下一首切换 -- 音量调节控制 -- 播放列表管理 -- 实时播放进度显示 -- 顶部状态栏(时间、日期、Wi-Fi、电池) - -### 界面功能 -- 启动页面:Logo 动画和加载效果 -- 长方形适配:为模拟器长方形屏幕优化 -- 音量条:可视化音量控制 -- 滚动歌曲信息:长标题自动滚动显示 - -### 系统功能 -- Wi-Fi 网络连接管理 -- 完整文件系统集成 -- JSON 配置文件管理 -- 系统资源实时监控 -- 模块化架构设计 - -## 系统要求 - -### 硬件要求 -支持 ARM 架构的嵌入式设备,具备音频输出和显示功能。 - -### 软件要求 -- **操作系统**:openvela -- **图形库**:LVGL -- **音频库**:NuttX Audio 框架 / 模拟器音频控制器 -- **网络**:Wi-Fi 驱动支持 - -### 开发环境 -- **编译器**:arm-none-eabi-gcc -- **构建系统**:Make / NuttX 构建系统 -- **调试工具**:ADB -- **主机系统**:Linux -- **模拟器**:QEMU - -## 项目结构 +English | [中文](README_zh-cn.md) + +music_player2 is an embedded music player designed based on the openvela system. It provides a UI interface with support for audio playback, playlist management, splash screen, volume control, and other features. Built with a modular architecture design for easy extension and maintenance. + +## Table of Contents + +- [Features](#features) +- [System Requirements](#system-requirements) +- [Project Structure](#project-structure) +- [Getting Started](#getting-started) +- [User Guide](#user-guide) +- [Customization Guide](#customization-guide) +- [Contributing](#contributing) + +## Detailed Documentation + +- [Troubleshooting Guide](docs/en/TROUBLESHOOTING.md) +- [Technical Documentation](docs/en/TECHNICAL.md) +- [Changelog](docs/en/CHANGELOG.md) + +## Features + +### Core Features +- Audio playback control +- Previous/next track switching +- Volume adjustment control +- Playlist management +- Real-time playback progress display +- Top status bar (time, date, Wi-Fi, battery) + +### Interface Features +- Splash screen: Logo animation and loading effects +- Rectangle adaptation: Optimized for simulator rectangular screen +- Volume bar: Visual volume control +- Scrolling song information: Long titles automatically scroll + +### System Features +- Wi-Fi network connection management +- Complete file system integration +- JSON configuration file management +- Real-time system resource monitoring +- Modular architecture design + +## System Requirements + +### Hardware Requirements +ARM architecture embedded devices with audio output and display capabilities. + +### Software Requirements +- **Operating System**: openvela +- **Graphics Library**: LVGL +- **Audio Library**: NuttX Audio Framework / Simulator Audio Controller +- **Network**: Wi-Fi driver support + +### Development Environment +- **Compiler**: arm-none-eabi-gcc +- **Build System**: Make / NuttX Build System +- **Debug Tools**: ADB +- **Host System**: Linux +- **Emulator**: QEMU + +## Project Structure ``` music_player2/ @@ -90,37 +92,40 @@ music_player2/ └── config.json ``` -## 启动指南 +## Getting Started -### 环境准备 +### Environment Setup ```bash -# 安装必要的工具 +# Install necessary tools sudo apt update && sudo apt install -y android-tools-adb build-essential git -# 克隆 openvela 仓库 +# Clone openvela repository git clone && cd vela_code ``` -### 配置和构建 +### Configuration and Build ```bash -# 配置音乐播放器 +# Configure music player echo "CONFIG_LVX_USE_DEMO_VELA_AUDIO=y" >> vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap/defconfig echo 'CONFIG_LVX_MUSIC_PLAYER_DATA_ROOT="/data"' >> vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap/defconfig -# 构建项目 +# Build project ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j8 ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j8 ``` -### 启动和部署 +### Startup and Deployment ```bash +cd nuttx && ln -sf vela_ap.elf nuttx && cd .. ./emulator.sh vela +sleep 15 && adb connect 127.0.0.1:5555 adb -s emulator-5554 push apps/packages/demos/music_player2/res /data/ +adb -s emulator-5554 shell "music_player2 &" ``` -### 配置文件说明 +### Configuration File Description -#### config.json - Wi-Fi配置 +#### config.json - Wi-Fi Configuration ```json { "wifi": { @@ -130,7 +135,7 @@ adb -s emulator-5554 push apps/packages/demos/music_player2/res /data/ } ``` -#### manifest.json - 音乐配置 +#### manifest.json - Music Configuration ```json { "musics": [ @@ -146,33 +151,31 @@ adb -s emulator-5554 push apps/packages/demos/music_player2/res /data/ } ``` -## 使用指南 +## User Guide -### 基本操作 -1. **播放/暂停**: 点击中央播放按钮 -2. **上一首/下一首**: 点击左右箭头按钮 -3. **音量控制**: 点击音量按钮显示音量条 -4. **打开播放列表**: 点击播放列表按钮 -5. **选择歌曲**: 在列表中点击想要播放的歌曲 +### Basic Operations +1. **Play/Pause**: Click the central play button +2. **Previous/Next**: Click the left/right arrow buttons +3. **Volume Control**: Click the volume button to show volume bar +4. **Open Playlist**: Click the playlist button +5. **Select Song**: Click the desired song in the list -### 调试模式 -在编译时添加 `-DDEBUG` 标志启用调试模式: +### Debug Mode +Enable debug mode by adding the `-DDEBUG` flag during compilation: ```bash make CFLAGS="-DDEBUG" ``` -## 自定义指南 +## Customization Guide -### 添加新音乐 +### Adding New Music -#### 1. 准备音频文件 +#### 1. Prepare Audio Files ```bash -# 确保音频文件为支持的格式(MP3/WAV) -# 准备专辑封面(推荐 300x300,支持 JPG/PNG 格式) convert cover.jpg -resize 300x300 cover.png ``` -#### 2. 更新配置文件 +#### 2. Update Configuration File ```json { "musics": [ @@ -188,70 +191,70 @@ convert cover.jpg -resize 300x300 cover.png } ``` -#### 3. 部署文件 +#### 3. Deploy Files ```bash -# 复制文件到资源目录 +# Copy files to resource directory cp new_song.mp3 res/musics/ cp new_cover.png res/musics/ -# 推送到设备 +# Push to device adb push res/musics/ /data/res/musics/ ``` -### 自定义界面 +### Interface Customization -#### 修改主题颜色 +#### Modify Theme Colors ```c -// 在 music_player2.c 中修改 +// Modify in music_player2.c #define MODERN_PRIMARY_COLOR lv_color_hex(0x00BFFF) #define MODERN_SECONDARY_COLOR lv_color_hex(0xFF6B6B) #define MODERN_BACKGROUND_COLOR lv_color_hex(0x121212) ``` -#### 调整界面布局 +#### Adjust Interface Layout ```c -// 修改分辨率适配 +// Modify resolution adaptation #define SCREEN_WIDTH 1280 #define SCREEN_HEIGHT 800 -// 调整控件大小 +// Adjust component sizes #define COVER_SIZE 200 #define BUTTON_SIZE 60 ``` -## 贡献指南 +## Contributing -### 开发流程 -1. Fork 项目 -2. 创建功能分支 -3. 开发和测试 -4. 提交更改 -5. 创建 Pull Request +### Development Process +1. Fork the project +2. Create feature branch +3. Develop and test +4. Submit changes +5. Create Pull Request -### 代码规范 -- 函数命名:snake_case -- 变量命名:snake_case -- 常量命名:UPPER_CASE -- 结构体命名:snake_case_t +### Code Standards +- Function naming: snake_case +- Variable naming: snake_case +- Constant naming: UPPER_CASE +- Structure naming: snake_case_t -### 提交信息规范 -- feat: 新功能 -- fix: 修复bug -- docs: 文档更新 -- style: 代码格式调整 -- refactor: 重构 -- test: 测试相关 +### Commit Message Standards +- feat: New feature +- fix: Bug fix +- docs: Documentation update +- style: Code formatting adjustment +- refactor: Refactoring +- test: Test related -## 许可证 +## License -本项目采用 Apache License 2.0 开源许可证。 +This project is licensed under the Apache License 2.0 open source license. -## 致谢 +## Acknowledgments -- **openvela**:提供嵌入式操作系统平台 -- **LVGL 社区**:提供图形库和UI组件支持 +- **openvela**: Providing embedded operating system platform +- **LVGL Community**: Providing graphics library and UI component support --- -*最后更新时间:2025-10-29* -*当前版本:v2.3.3* \ No newline at end of file +*Last updated: 2025-10-29* +*Current version: v2.3.3* diff --git a/music_player2/README_zh-cn.md b/music_player2/README_zh-cn.md new file mode 100644 index 0000000..7fb8008 --- /dev/null +++ b/music_player2/README_zh-cn.md @@ -0,0 +1,259 @@ +# music_player2 + +[English](README.md) | 中文 + +music_player2是一个嵌入式音乐播放器,基于 openvela 系统设计。提供 UI 界面,支持音频播放、播放列表管理、启动页面、音量控制等功能。采用模块化架构设计,易于扩展和维护。 + +## 目录 + +- [功能特性](#功能特性) +- [系统要求](#系统要求) +- [项目结构](#项目结构) +- [启动指南](#启动指南) +- [使用指南](#使用指南) +- [自定义指南](#自定义指南) +- [贡献指南](#贡献指南) + +## 详细文档 + +- [故障排除指南](docs/ch/TROUBLESHOOTING.md) +- [技术文档](docs/ch/TECHNICAL.md) +- [更新日志](docs/ch/CHANGELOG.md) + +## 功能特性 + +### 核心功能 +- 音频播放控制 +- 上一首/下一首切换 +- 音量调节控制 +- 播放列表管理 +- 实时播放进度显示 +- 顶部状态栏(时间、日期、Wi-Fi、电池) + +### 界面功能 +- 启动页面:Logo 动画和加载效果 +- 长方形适配:为模拟器长方形屏幕优化 +- 音量条:可视化音量控制 +- 滚动歌曲信息:长标题自动滚动显示 + +### 系统功能 +- Wi-Fi 网络连接管理 +- 完整文件系统集成 +- JSON 配置文件管理 +- 系统资源实时监控 +- 模块化架构设计 + +## 系统要求 + +### 硬件要求 +支持 ARM 架构的嵌入式设备,具备音频输出和显示功能。 + +### 软件要求 +- **操作系统**:openvela +- **图形库**:LVGL +- **音频库**:NuttX Audio 框架 / 模拟器音频控制器 +- **网络**:Wi-Fi 驱动支持 + +### 开发环境 +- **编译器**:arm-none-eabi-gcc +- **构建系统**:Make / NuttX 构建系统 +- **调试工具**:ADB +- **主机系统**:Linux +- **模拟器**:QEMU + +## 项目结构 + +``` +music_player2/ +├── music_player2.c +├── music_player2.h +├── music_player2_main.c +├── splash_screen.c +├── playlist_manager.c +├── playlist_manager.h +├── audio_ctl.c +├── audio_ctl.h +├── font_config.c +├── font_config.h +├── wifi.c +├── wifi.h +├── Kconfig +├── Makefile +├── Make.defs +├── README.md +├── README-en.md +├── docs/ +│ ├── ch/ +│ └── en/ +└── res/ + ├── fonts/ + ├── icons/ + ├── musics/ + └── config.json +``` + +## 启动指南 + +### 环境准备 +```bash +# 安装必要的工具 +sudo apt update && sudo apt install -y android-tools-adb build-essential git + +# 克隆 openvela 仓库 +git clone && cd vela_code +``` + +### 配置和构建 +```bash +# 配置音乐播放器 +echo "CONFIG_LVX_USE_DEMO_VELA_AUDIO=y" >> vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap/defconfig +echo 'CONFIG_LVX_MUSIC_PLAYER_DATA_ROOT="/data"' >> vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap/defconfig + +# 构建项目 +./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j8 +./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j8 +``` + +### 启动和部署 +```bash +./emulator.sh vela +adb -s emulator-5554 push apps/packages/demos/music_player2/res /data/ +``` + +### 配置文件说明 + +#### config.json - Wi-Fi配置 +```json +{ + "wifi": { + "ssid": "vela_network", + "pswd": "vela123456" + } +} +``` + +#### manifest.json - 音乐配置 +```json +{ + "musics": [ + { + "path": "test.mp3", + "name": "Test Song", + "artist": "Demo Artist", + "cover": "test.png", + "total_time": 180000, + "color": "#4A90E2" + } + ] +} +``` + +## 使用指南 + +### 基本操作 +1. **播放/暂停**: 点击中央播放按钮 +2. **上一首/下一首**: 点击左右箭头按钮 +3. **音量控制**: 点击音量按钮显示音量条 +4. **打开播放列表**: 点击播放列表按钮 +5. **选择歌曲**: 在列表中点击想要播放的歌曲 + +### 调试模式 +在编译时添加 `-DDEBUG` 标志启用调试模式: +```bash +make CFLAGS="-DDEBUG" +``` + +## 自定义指南 + +### 添加新音乐 + +#### 1. 准备音频文件 +```bash +# 确保音频文件为支持的格式(MP3/WAV) +# 准备专辑封面(推荐 300x300,支持 JPG/PNG 格式) +convert cover.jpg -resize 300x300 cover.png +``` + +#### 2. 更新配置文件 +```json +{ + "musics": [ + { + "path": "new_song.mp3", + "name": "New Song Title", + "artist": "Artist Name", + "cover": "new_cover.png", + "total_time": 240000, + "color": "#FF5722" + } + ] +} +``` + +#### 3. 部署文件 +```bash +# 复制文件到资源目录 +cp new_song.mp3 res/musics/ +cp new_cover.png res/musics/ + +# 推送到设备 +adb push res/musics/ /data/res/musics/ +``` + +### 自定义界面 + +#### 修改主题颜色 +```c +// 在 music_player2.c 中修改 +#define MODERN_PRIMARY_COLOR lv_color_hex(0x00BFFF) +#define MODERN_SECONDARY_COLOR lv_color_hex(0xFF6B6B) +#define MODERN_BACKGROUND_COLOR lv_color_hex(0x121212) +``` + +#### 调整界面布局 +```c +// 修改分辨率适配 +#define SCREEN_WIDTH 1280 +#define SCREEN_HEIGHT 800 + +// 调整控件大小 +#define COVER_SIZE 200 +#define BUTTON_SIZE 60 +``` + +## 贡献指南 + +### 开发流程 +1. Fork 项目 +2. 创建功能分支 +3. 开发和测试 +4. 提交更改 +5. 创建 Pull Request + +### 代码规范 +- 函数命名:snake_case +- 变量命名:snake_case +- 常量命名:UPPER_CASE +- 结构体命名:snake_case_t + +### 提交信息规范 +- feat: 新功能 +- fix: 修复bug +- docs: 文档更新 +- style: 代码格式调整 +- refactor: 重构 +- test: 测试相关 + +## 许可证 + +本项目采用 Apache License 2.0 开源许可证。 + +## 致谢 + +- **openvela**:提供嵌入式操作系统平台 +- **LVGL 社区**:提供图形库和UI组件支持 + +--- + +*最后更新时间:2025-10-29* +*当前版本:v2.3.3* \ No newline at end of file diff --git a/pet/README.md b/pet/README.md index 639ff67..b8af57b 100644 --- a/pet/README.md +++ b/pet/README.md @@ -1,91 +1,62 @@ -# 虚拟宠物应用 (Virtual Pet Demo) +# Virtual Pet Demo -## 简介 +English | [中文](README_zh-cn.md) -虚拟宠物应用是一个基于LVGL图形库的交互式演示程序,模拟了一个数字宠物的饲养过程。用户可以通过喂食、饮水、运动和休息等操作来照顾虚拟宠物,提升其心情和等级。 +An interactive virtual pet demo application built with LVGL on OpenVela/NuttX. Simulate raising a digital pet by feeding, watering, exercising, and resting to improve its mood and level. -## 界面预览 +## Features -![虚拟宠物主界面](docs/images/jiemian.png) +- Pet status management: hunger, thirst, happiness, experience +- Three mood states: happy, calm, sad (auto-changes based on happiness value) +- Level system: accumulate experience to level up +- Sleep mode: manual toggle, slower status decay while sleeping +- Achievement system: consecutive feeding/watering/exercise streaks, survival days, level milestones +- Data persistence: auto-save and restore on restart +- Modern UI: left status panel, right action buttons, graphical interaction -*主界面:左侧显示宠物状态,右侧为操作按钮* +## Configuration -![宠物平静状态](docs/images/calm.png) -![宠物难过状态](docs/images/sad.png) +Enable in menuconfig: -*宠物的不同情绪状态:开心、平静、难过* - -## 功能特性 - -### 宠物状态管理 -- **饥饿度**:随时间缓慢下降,可通过喂食恢复 -- **口渴度**:随时间缓慢下降,可通过饮水恢复 -- **心情值**:受饥饿度和口渴度影响,可通过运动提升 -- **经验值**:随时间自动增长,运动可获得额外经验值 -- **等级系统**:积累足够经验值后升级 - -### 宠物状态表现 -- **三种情绪状态**:开心、平静、难过(根据心情值自动变化) -- **睡眠状态**:可手动切换,睡眠时状态下降更慢,心情缓慢恢复 - -### 成就系统 -- 连续7天喂食/饮水/运动 -- 存活30天 -- 达到5级/10级 - -### 数据持久化 -- 自动保存宠物数据 -- 应用重启后可恢复之前的状态 - -### 用户界面 -- 现代化UI设计,左侧状态面板,右侧操作按钮 -- 图形化按钮,带有点击反馈效果 -- 状态条直观显示宠物各项属性 - -## 使用方法 - -### 基本操作 -1. **喂食**:点击食物图标,增加饥饿度和少量心情值 -2. **饮水**:点击水杯图标,增加口渴度和少量心情值 -3. **运动**:点击运动图标,大幅提升心情值并获得额外经验,但会消耗饥饿度和口渴度 -4. **睡眠**:点击睡眠图标,切换宠物睡眠状态,睡眠时状态下降更慢 +``` +LVX_USE_DEMO_PET=y +LVX_PET_DATA_ROOT="/sdcard" +``` -### 状态指示 -- 左侧进度条显示宠物的饥饿度、口渴度、心情值和经验值 -- 宠物图像会根据心情状态变化 -- 顶部状态栏显示当前时间、电量和宠物等级 +## Project Structure -## 配置与编译 +``` +pet/ +├── pet.h # Data structures, constants, and API definitions +├── pet.c # Core functionality implementation +├── pet_main.c # Application entry point and LVGL initialization +├── Kconfig # NuttX configuration +├── CMakeLists.txt # CMake build script +└── Makefile # Make build script +``` -### 依赖项 -- LVGL图形库 -- NuttX操作系统 -- libuv事件循环库 +## Resource Structure -### 编译选项 -在NuttX配置中启用: ``` -CONFIG_LVX_USE_DEMO_PET=y -CONFIG_LVX_PET_DATA_ROOT="/data" # 设置资源文件路径 +/res/ +├── fonts/ # Font files +├── image/ # Pet and background images +└── icons/ # Action button icons ``` -## 资源文件结构 -``` -/data/res/ - ├── fonts/ # 字体文件 - ├── image/ # 宠物和背景图像 - └── icons/ # 操作按钮图标 +## Usage + +```bash +nsh> pet ``` -## 开发者信息 +- Feed: tap the food icon to increase hunger +- Water: tap the cup icon to increase thirst +- Exercise: tap the exercise icon to boost happiness and gain experience +- Sleep: tap the sleep icon to toggle sleep mode -### 主要文件 -- `pet.h`:定义结构体和常量 -- `pet.c`:实现主要功能 -- `pet_main.c`:应用入口和LVGL初始化 +## Build -### 扩展建议 -- 添加更多互动方式 -- 实现随机事件系统 -- 增加更多成就和奖励 -- 添加社交功能 \ No newline at end of file +```bash +./build.sh -j8 +``` diff --git a/pet/README_zh-cn.md b/pet/README_zh-cn.md new file mode 100644 index 0000000..02a11c8 --- /dev/null +++ b/pet/README_zh-cn.md @@ -0,0 +1,62 @@ +# 虚拟宠物应用 + +[English](README.md) | 中文 + +基于 LVGL 图形库的交互式虚拟宠物演示应用,运行于 OpenVela/NuttX 平台。模拟数字宠物的饲养过程,通过喂食、饮水、运动和休息等操作照顾虚拟宠物,提升心情和等级。 + +## 功能特性 + +- 宠物状态管理:饥饿度、口渴度、心情值、经验值 +- 三种情绪状态:开心、平静、难过(根据心情值自动变化) +- 等级系统:积累经验值升级 +- 睡眠状态:手动切换,睡眠时状态下降更慢 +- 成就系统:连续喂食/饮水/运动、存活天数、等级达成 +- 数据持久化:自动保存,重启后恢复状态 +- 现代化 UI:左侧状态面板,右侧操作按钮,图形化交互 + +## 配置 + +在 menuconfig 中启用: + +``` +LVX_USE_DEMO_PET=y +LVX_PET_DATA_ROOT="/sdcard" +``` + +## 项目结构 + +``` +pet/ +├── pet.h # 数据结构、常量与接口定义 +├── pet.c # 核心功能实现 +├── pet_main.c # 应用入口与 LVGL 初始化 +├── Kconfig # NuttX 配置 +├── CMakeLists.txt # CMake 构建脚本 +└── Makefile # Make 构建脚本 +``` + +## 资源目录结构 + +``` +/res/ +├── fonts/ # 字体文件 +├── image/ # 宠物和背景图片 +└── icons/ # 操作按钮图标 +``` + +## 使用方法 + +```bash +nsh> pet +``` + +- 喂食:点击食物图标,增加饥饿度 +- 饮水:点击水杯图标,增加口渴度 +- 运动:点击运动图标,提升心情值并获得经验 +- 睡眠:点击睡眠图标,切换睡眠状态 + +## 编译 + +```bash +./build.sh -j8 +``` diff --git a/relation_calculator/Readme.md b/relation_calculator/README.md similarity index 99% rename from relation_calculator/Readme.md rename to relation_calculator/README.md index fd58d57..e583baf 100644 --- a/relation_calculator/Readme.md +++ b/relation_calculator/README.md @@ -1,6 +1,6 @@ # Relatives Calculator Demo Quick Start -\[ English | [简体中文](Readme_zh-cn.md) \] +\[ English | [简体中文](README_zh-cn.md) \] This document provides a comprehensive guide to building, deploying, and running the **Relatives Calculator** demo application on the `openvela` system. It covers procedures for both the QEMU emulator and the ESP32-S3-BOX development board, as well as how to customize the application by adding new relationships. diff --git a/relation_calculator/Readme_zh-cn.md b/relation_calculator/README_zh-cn.md similarity index 99% rename from relation_calculator/Readme_zh-cn.md rename to relation_calculator/README_zh-cn.md index 60bda30..02a11d8 100644 --- a/relation_calculator/Readme_zh-cn.md +++ b/relation_calculator/README_zh-cn.md @@ -1,6 +1,6 @@ # 亲戚计算器 Demo 快速上手 -\[ [English](Readme.md) | 简体中文 \] +\[ [English](README.md) | 简体中文 \] 本文档为在 `openvela` 系统上构建、部署和运行**亲戚计算器**演示应用提供了全面的指导。内容涵盖 QEMU 模拟器和 ESP32-S3-BOX 开发板的操作流程,以及如何通过增加新关系来自定义此应用。 diff --git a/snake_game/Readme.md b/snake_game/README.md similarity index 98% rename from snake_game/Readme.md rename to snake_game/README.md index 7926371..9c4eab9 100644 --- a/snake_game/Readme.md +++ b/snake_game/README.md @@ -1,5 +1,7 @@ # Snake Game +English | [中文](README_zh-cn.md) + ## Introduction This is an automatic snake game implemented using the LVGL graphics library. The game area is a 60×35 grid, with each grid cell being 20×20 pixels. diff --git a/snake_game/README_zh-cn.md b/snake_game/README_zh-cn.md new file mode 100644 index 0000000..068493a --- /dev/null +++ b/snake_game/README_zh-cn.md @@ -0,0 +1,92 @@ +# 贪吃蛇游戏 + +[English](README.md) | 中文 + +## 简介 + +这是一个使用 LVGL 图形库实现的自动贪吃蛇游戏。游戏区域为 60×35 的网格,每个网格单元为 20×20 像素。 + +### 功能特性 + +- 点击 "START" 按钮开始游戏 +- 点击开始后,蛇会自动寻找并吃掉食物 +- 达到 1000 分即可获胜,显示 "Victory!" +- 撞到自身或墙壁时游戏结束,显示 "GAME OVER" +- 游戏结束时出现 "RESTART" 按钮 +- 实时分数显示 +- 随机食物生成 +- 蛇头为亮绿色,蛇身为深绿色 + +![模拟器界面](screen/1.png) +![游戏运行界面](screen/2.png) +![游戏开始界面](screen/3.png) +![游戏结束界面](screen/4.png) + +## 配置 + +1. 切换到 openvela 仓库根目录,执行以下命令配置贪吃蛇游戏: + + ```bash + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap menuconfig + ``` + +2. 按 `/` 搜索并修改以下配置: + + ```bash + LVX_USE_DEMO_SNAKE_GAME=y + LVX_SNAKE_GAME_DATA_ROOT="/data" + ``` + +## 编译 + +```bash +# 清理构建文件 +./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j$(nproc) + +# 开始编译 +./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j$(nproc) +``` + +## 运行 + +1. 启动模拟器: + + ```bash + ./emulator.sh vela + ``` + +2. 在模拟器终端环境 `openvela-ap>` 中输入: + + ```bash + snake_game & + ``` + +## 游戏规则 + +- 点击 "START" 按钮开始游戏 +- 蛇会自动寻找到食物的最短路径 +- 每吃一个食物得 10 分 +- 撞到自身或墙壁时游戏结束,显示 "GAME OVER" +- 游戏结束时点击 "RESTART" 按钮开始新游戏 +- 达到 1000 分即可获胜,显示 "Victory!" + +## 操作指南 + +1. **开始游戏**: + - 点击屏幕中央的 "START" 按钮 + - 游戏开始后按钮自动隐藏 + +2. **游戏进行中**: + - 蛇自动寻找食物并移动 + - 左上角显示分数 + - 右上角显示游戏状态 + +3. **游戏结束**: + - 蛇撞到自身或墙壁时游戏结束,显示 "GAME OVER" + - 达到 1000 分获胜,显示 "Victory!" + - 屏幕中央出现 "RESTART" 按钮 + - 点击 "RESTART" 开始新游戏 + +## 技术实现 + +游戏使用链表结构存储蛇身,通过定时器实现自动移动。蛇会计算到食物的最短路径(考虑掉头情况),自动选择最优移动方向。游戏使用 LVGL 的 canvas 组件进行渲染,每次移动后重绘整个屏幕。游戏界面设计简洁,控制按钮和状态显示醒目。 diff --git a/utils/README.md b/utils/README.md new file mode 100644 index 0000000..7f87d20 --- /dev/null +++ b/utils/README.md @@ -0,0 +1,21 @@ +# Demo Utils + +English | [中文](README_zh-cn.md) + +Shared utility library for OpenVela/NuttX demo applications. Provides common helper functions used across multiple demo projects. + +## Configuration + +Enable in menuconfig: + +``` +LVX_USE_DEMO_UTILS=y +``` + +This module is automatically selected when enabling demos that depend on it (e.g., Music Player, Music Player 2). + +## Build + +```bash +./build.sh -j8 +``` diff --git a/utils/README_zh-cn.md b/utils/README_zh-cn.md new file mode 100644 index 0000000..7c3e739 --- /dev/null +++ b/utils/README_zh-cn.md @@ -0,0 +1,21 @@ +# Demo Utils - 演示工具库 + +[English](README.md) | 中文 + +OpenVela/NuttX 演示应用的共享工具库,提供多个演示项目共用的辅助函数。 + +## 配置 + +在 menuconfig 中启用: + +``` +LVX_USE_DEMO_UTILS=y +``` + +当启用依赖此模块的演示应用(如音乐播放器、音乐播放器 2)时,会自动选中此模块。 + +## 编译 + +```bash +./build.sh -j8 +``` diff --git a/x_track/README.md b/x_track/README.md new file mode 100644 index 0000000..f9134c3 --- /dev/null +++ b/x_track/README.md @@ -0,0 +1,160 @@ +# Cycling Computer + +English | [中文](README_zh-cn.md) + +## Introduction + +"X-TRACK Demo" comes from the open source project [X-TRACK](https://github.com/FASTSHIFT/X-TRACK). Thanks to the original author of X-TRACK, FASTSHIFT, the migration is completed. + +It's a bike computer with features like speed display, distance statistics and real-time track display, with a display resolution of 240x320 pixels, using touch screen interaction. + +This article describes how to run the example on Emulator. + +## Prerequisites + +To download the source code, see [Quick Start](https://github.com/open-vela/docs/blob/dev/en/quickstart/openvela_ubuntu_quick_start.md). + +## Step 1: Configure the project + +1. Switch to the root directory of openvela repository and run the following command to start compiling and configuring the project: + + ```Bash + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap menuconfig + ``` + +2. Modify the following configurations in order. + + ```Bash + LIB_PNG = y + LV_USE_LIBPNG = y + NETUTILS_CJSON = y + UIKIT = y + UIKIT_FONT_MANAGER = y + LVX_USE_DEMO_X_TRACK = y + ``` + + **Note**: How to enable "LIB_PNG" configuration is shown as an example. Other configuration operations are the same. + + 1. Press the "/" button on the keyboard to enter the search mode, type "LIB_PNG" in the search field, use the arrow keys to move the cursor to "LIB_PNG", and press Enter to confirm. + 2. Press the "space bar" for the "Enable libpng" option to turn this option on, and a \* that appears in [ ] indicates that this configuration is turned on. + 3. The other configurations are turned on in the same way. + +## Step 2: Start to compile + +1. Run the following command to start compiling. + + ```Bash + # Clean up build artifacts + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j8 + + # Start to build + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j8 + ``` + +2. After successful compilation, the following files are generated in the "nuttx" directory. + + ```Bash + ./nuttx + ├── vela_ap.elf + ├── vela_ap.bin + ``` + +## Step 3: Launch the emulator and push resources + +1. Switch to the root directory of openvela repository and start the emulator: + + ```Bash + ./emulator.sh vela + ``` + +2. Push resources to the device by using emulator-supported ADB. Open a new terminal in the root directory of openvela repository, type "adb push" followed by the file path to transfer the resources to the appropriate location. + + ```Bash + # Install adb + sudo apt install android-tools-adb + + # Push resources + adb push apps/packages/demos/x_track/resource/font /data + adb push apps/packages/demos/x_track/resource/images /data + adb push apps/packages/demos/x_track/resource/track /data + ``` + +## Step 4: Start + +### 1. Startup page + +1. To enable the "X-TRACK" program, enter the following command in the emulator's terminal environment "openvela-ap": + + ```Bash + x_track & + ``` + +### 2. Main interface + +The three function buttons below are used for jumping to different function pages: + +1. Motion tracking page — The bottom left corner of this page shows the general information of the current movement. The middle part shows the current movement direction and the past trajectory. You can swipe right to return to the previous page. + +2. Shutdown page — This page mimics the shutdown page of a mobile phone. Hold and drag the yellow scroll bar up to the end and then release it to turn off the machine. Click somewhere or swipe right to return to the previous page. + +3. System information page — This page shows detailed system information. Swipe up or down or click the corresponding icons to see different information. Swipe right to return to the previous page. + +## Step 5: Exit + +Shut down the emulator to exit Demo. + +## FAQ + +### 1. adb command not found + +#### Reason + +The "adb" tool is not installed. + +#### Solution + +Install "adb" and execute the following command: + +```bash +sudo apt install android-tools-adb +``` + +### 2. Garbled text is shown + +#### Reason + +Font resources are not loaded correctly. + +#### Solution + +Follow [Step 3](#step-3-launch-the-emulator-and-push-resources) to push resources. + +### 3. Why is there no map display? + +#### Reason + +Due to the copyright issues for commercial maps, maps can't be provided. Only the track display function is available. + +### 4. Why is it different from the original UI? + +#### Reason + +With significant adjustments to the code of the original version, this demo is somewhat different in respect of function and display. + +### 5. Why does the battery level in the status bar at the top right corner keep jumping? + +#### Reason + +This is normal because the battery level on an emulator is just randomly simulated. + +### 6. Is this trajectory simulated? + +#### Reason + +Yes. It accesses a [GPX](https://en.wikipedia.org/wiki/GPS_Exchange_Format) file for track replay and simulates GNSS to generate data. + +### 7. How to replace the track file that shows my track? + +#### Solution + +Rename your track file (GPX format) as "TRK_EXAMPLE.gpx", and push it to the "/data/Track" directory with the "adb" tool. \ No newline at end of file diff --git a/x_track/README_zh-cn.md b/x_track/README_zh-cn.md new file mode 100644 index 0000000..e7cb9cb --- /dev/null +++ b/x_track/README_zh-cn.md @@ -0,0 +1,160 @@ +# 自行车码表 + +[English](README.md) | 中文 + +## 简介 + +`X-TRACK Demo` 移植自开源项目 [X-TRACK](https://github.com/FASTSHIFT/X-TRACK),感谢 X-TRACK 原作者 FASTSHIFT 本人完成该移植工作。 + +它是一个自行车码表,拥有时速显示、路程统计和实时轨迹显示等功能,显示分辨率为 `240x320`,使用触摸屏交互。 + +本文介绍如何在模拟器上运行该示例。 + +## 前提条件 + +下载源码,请参见[快速入门](https://github.com/open-vela/docs/blob/dev/zh-cn/quickstart/openvela_ubuntu_quick_start.md)。 + +## 步骤一 配置项目 + +1. 切换到 openvela 仓库的根目录,运行以下命令打开编译配置项目: + + ```Bash + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap menuconfig + ``` + +2. 依次修改如下配置。 + + ```Bash + LIB_PNG = y + LV_USE_LIBPNG = y + NETUTILS_CJSON = y + UIKIT = y + UIKIT_FONT_MANAGER = y + LVX_USE_DEMO_X_TRACK = y + ``` + + 以启用 `LIB_PNG` 配置为例进行说明,其他配置操作相同。 + + 1. 按键盘上的 `/` 按键进入搜索模式,在搜索栏输入`LIB_PNG`,使用方向键移动光标至`LIB_PNG`,按回车确认。 + 2. 在`Enable libpng`选项上按`空格键`将此选项开启,`[ ]` 中出现 `*` 表示该配置被打开。 + 3. 其余配置项的开启方法同上。 + +## 步骤二 开始编译 + +1. 运行以下命令开始编译: + + ```Bash + # 清理构建产物 + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j8 + + # 开始构建 + ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j8 + ``` + +2. 编译成功后,在`nuttx`目录下会生成以下文件。 + + ```Bash + ./nuttx + ├── vela_ap.elf + ├── vela_ap.bin + ``` + +## 步骤三 启动模拟器并推送资源 + +1. 切换到 openvela 仓库的根目录,启动模拟器: + + ```Bash + ./emulator.sh vela + ``` + +2. 使用模拟器支持的 `ADB` 将资源推送到设备,在 openvela 仓库的根目录下打开一个新的终端,输入 `adb push` 后跟文件路径,即可将资源传输到相应位置。 + + ```Bash + # 安装adb + sudo apt install android-tools-adb + + # 推送资源 + adb push apps/packages/demos/x_track/resource/font /data + adb push apps/packages/demos/x_track/resource/images /data + adb push apps/packages/demos/x_track/resource/track /data + ``` + +## 步骤四 启动 + +### 1 开机页面 + +1. 启用 `X-TRACK` 程序,在模拟器的终端环境 `openvela-ap>` 中输入如下命令: + + ```Bash + x_track & + ``` + +### 2 主界面 + +下方三个功能按钮,分别对应跳转不同的功能页面: + +1. 运动轨迹页面 — 此页面左下角显示了当前运动的基本信息,中间部分显示当前的运动方向和走过的轨迹,右划可返回上一页。 + +2. 关机页面 — 此页面模仿了手机的关机页面,按住黄色滚动条往上拖到底再松手即可关机,点击其他位置或右划可返回上一页。 + +3. 系统信息页面 — 此页面显示了更为详细的系统信息,上下划动或者点击对应的图标可切换不同的信息展示,右划可返回上一页。 + +## 步骤五 退出 Demo + +关闭模拟器退出 Demo。 + +## 常见问题 + +### 1. adb 命令找不到 + +#### 原因 + +未安装 `adb` 工具。 + +#### 解决方案 + +安装 `adb`,执行如下命令: + +```bash +sudo apt install android-tools-adb +``` + +### 2. 字体显示为乱码 + +#### 原因 + +未正确加载字体资源。 + +#### 解决方案 + +请按[步骤三](#步骤三-启动模拟器并推送资源)进行资源推送。 + +### 3. 为什么没有地图显示功能 + +#### 原因 + +商用地图资源存在版权问题,所以无法提供地图功能,只保留轨迹显示功能。 + +### 4. 为什么和原版的 UI 不一样 + +#### 原因 + +此 Demo 基于原版的代码进行了大幅度调整,所以功能和显示上稍有区别。 + +### 5. 为什么右上角状态栏电量一直在随机跳动 + +#### 原因 + +在模拟器上使用的是简单的随机数模拟电量,所以是正常现象。 + +### 6. 这个轨迹是模拟的吗 + +#### 原因 + +是的,它通过读取 [GPX](https://zh.wikipedia.org/wiki/GPX) 文件进行轨迹重放,模拟GNSS产生数据。 + +### 7. 怎么替换显示自己的轨迹文件 + +#### 解决方案 + +将您的轨迹文件(GPX格式),重命名为 `TRK_EXAMPLE.gpx`,用 `adb` 工具推送到 `/data/Track` 目录即可。 \ No newline at end of file