Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions example/multimedia/lvgl/games/flappybird/README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# LVGL FlappyBird Game

Source Code Path: example/multimedia/lvgl/games/flappybird

This is a flappybird game example implemented based on LVGL. All operations are performed through the LVGL graphics library without the need to interface with underlying hardware. This example demonstrates how to use LVGL to create interactive game applications, including graphical interface rendering, user input handling, and game logic implementation.
## Usage

The following sections provide only absolutely necessary information. For complete steps on configuring SiFli-SDK and using it to build and run projects, please refer to the [SiFli-SDK Quick Start](https://docs.sifli.com/projects/sdk/latest/sf32lb52x/quickstart/index.html)

## Supported Development Boards

This example can run on the following development boards:
- eh-lb563
- SF32LB52x series
- SF32LB56x series

This example demonstrates a flappybird game where all operations are implemented based on LVGL without the need to interface with any underlying hardware.

## Project Compilation and Download:
Board projects in the project directory can be compiled for specific boards by specifying the board:
- To compile a project that can run on HDK 563, execute `scons --board=eh-lb563` to generate the project
- Download can be performed through download.bat in the build directory. For example, to flash the 563 project generated in the previous step, execute `build_eh-lb563\download.bat` for JLink download
- Special note: For SF32LB52x/SF32LB56x series, an additional uart_download.bat will be generated. You can execute this script and enter the download UART port number to perform the download
Simulator project is located in the simulator directory:
- Compile using scons. The simulator/msvc_setup.bat file needs to be modified accordingly to match your local MSVC configuration
- You can also use `scons --target=vs2017` to generate an MSVC project (project.vcxproj) for compilation with Visual Studio.

```{note}
If you are not using VS2017 (e.g., VS2022), you will be prompted to upgrade the MSVC SDK when loading the project. It can be used after upgrading.
```

## Troubleshooting

For any technical questions, please submit an [issue](https://github.com/OpenSiFli/SiFli-SDK/issues) on GitHub

## Reference Documentation
- [SiFli-SDK Quick Start](https://docs.sifli.com/projects/sdk/latest/sf32lb52x/quickstart/index.html)
39 changes: 39 additions & 0 deletions example/multimedia/lvgl/games/flappybird/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# LVGL 笨笨鸟游戏

源码路径: example/multimedia/lvgl/games/flappybird

这是一个基于LVGL实现的笨笨鸟游戏示例,所有操作均通过LVGL图形库完成,无需对接底层硬件接口。该示例展示了如何使用LVGL创建交互式游戏应用,包括图形界面渲染、用户输入处理和游戏逻辑实现。
## 用法

下面的小节仅提供绝对必要的信息。有关配置 SiFli-SDK 及使用其构建和运行项目的完整步骤,请参阅 [SiFli-SDK 快速入门](https://docs.sifli.com/projects/sdk/latest/sf32lb52x/quickstart/index.html)

## 支持的开发板

此示例可在以下开发板上运行:
- eh-lb563
- SF32LB52x系列
- SF32LB56x系列

本实例演示笨笨鸟小游戏,游戏所有操作均基于LVGL实现,无需对接任何底层接口

## 工程编译及下载:
板子工程在project目录下可以通过指定board来编译适应相对board的工程,
- 比如想编译可以在HDK 563上运行的工程,执行scons --board=eh-lb563即可生成工程
- 下载可以通过build目录下的download.bat进行,比如同样想烧录上一步生成的563工程,可以执行.\build_eh-lb563\download.bat来通过jlink下载
- 特别说明下,对于SF32LB52x/SF32LB56x系列会生成额外的uart_download.bat。可以执行该脚本并输入下载UART的端口号执行下载
模拟器工程在simulator目录下,
- 使用 scons 进行编译,simulator/msvc_setup.bat文件需要相应修改,和本机MSVC配置对应
- 也可以使用 scons --target=vs2017 生成 MSVC工程 project.vcxproj, 使用Visual Studio 进行编译。

```{note}
如果不是使用VS2017, 例如 VS2022, 加载工程的时候,会提示升级MSVC SDK, 升级后就可以使用了。
```

## 异常诊断

如有任何技术疑问,请在GitHub上提出 [issue](https://github.com/OpenSiFli/SiFli-SDK/issues)

## 参考文档
- [SiFli-SDK 快速入门](https://docs.sifli.com/projects/sdk/latest/sf32lb52x/quickstart/index.html)


3 changes: 3 additions & 0 deletions example/multimedia/lvgl/games/flappybird/project/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Kconfig root for APP.
source "$SIFLI_SDK/Kconfig.v2"
rsource "Kconfig.proj"
9 changes: 9 additions & 0 deletions example/multimedia/lvgl/games/flappybird/project/Kconfig.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#APP specific configuration.
config CUSTOM_MEM_MAP
bool
select custom_mem_map
default y if !SOC_SIMULATOR

config LV_BUILD_EXAMPLES
bool
default y
15 changes: 15 additions & 0 deletions example/multimedia/lvgl/games/flappybird/project/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
from building import *

cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)

# Add SDK
Import('SIFLI_SDK')
objs.extend(SConscript(os.path.join(SIFLI_SDK, 'SConscript'), variant_dir="sifli_sdk", duplicate=0))

# Add application source code
objs.extend(SConscript(cwd+'/../src/SConscript', variant_dir="src", duplicate=0))

Return('objs')
34 changes: 34 additions & 0 deletions example/multimedia/lvgl/games/flappybird/project/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
import rtconfig

# Check SDK
SIFLI_SDK = os.getenv('SIFLI_SDK')
if not SIFLI_SDK:
print("Please run set_env.bat in root folder of SIFLI SDK to set environment.")
exit()
from building import *

# Prepare environment.
PrepareEnv()

################################## change rtconfig.xxx to customize build ########################################

# Add bootloader project
AddBootLoader(SIFLI_SDK,rtconfig.CHIP)

# Set default compile options
SifliEnv()

TARGET = rtconfig.OUTPUT_DIR + rtconfig.TARGET_NAME + '.' + rtconfig.TARGET_EXT
# Prepare building environment
objs = PrepareBuilding(None)
env = GetCurrentEnv()

# Build application.
DoBuilding(TARGET, objs)

# Add flash table buld.
AddFTAB(SIFLI_SDK,rtconfig.CHIP)

# Generate download .bat script
GenDownloadScript(env)
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>vs</ProjectName>
<ProjectGuid>{4A6BF1B1-C645-4BAD-A9B7-7B6E3DB67B2C}</ProjectGuid>
<RootNamespace>vs2008</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\;..\..\include;..\..\bsp\vs2008;..\..\components\finsh;..\..\components\dfs\include;..\..\components\dfs\filesystems\uffs\src\inc\;..\..\components\dfs\filesystems\uffs;..\..\components\drivers\include;..\..\components\dfs\filesystems\jffs2\src;..\..\components\dfs\filesystems\jffs2\kernel;..\..\components\dfs\filesystems\jffs2\include;..\..\components\dfs\filesystems\jffs2\;..\..\components\dfs\filesystems\jffs2\cyg\compress;..\..\components\init;.\drivers;..\..\components\net\lwip\src\include\;..\..\components\net\lwip\src;..\..\components\net\lwip\src\arch\include;..\..\components\net\lwip\src\include\ipv4;.\pcap\Include;.\SDL2-2.0.7\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;MSVC;_TIME_T_DEFINED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4828;4116;4146;4715;4716;4090;4018;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>winmm.lib;sdl2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>.\pcap\Lib;.\SDL2-2.0.7\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>$(ProjectDir)\build_pc_hcpu\main.exe</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CONFIG_LCD_WINDOWS=y
CONFIG_RT_USING_POSIX=n
CONFIG_RT_USING_USER_MAIN=n
CONFIG_RT_USING_HWMAILBOX=n
CONFIG_USING_BUTTON_LIB=n
CONFIG_USING_CPU_USAGE_PROFILER=n
CONFIG_LV_USE_FS_WIN32=y
CONFIG_LV_FS_WIN32_LETTER=65
CONFIG_LV_FS_WIN32_PATH="./disk/"
36 changes: 36 additions & 0 deletions example/multimedia/lvgl/games/flappybird/project/proj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
CONFIG_RT_MAIN_THREAD_STACK_SIZE=4096
CONFIG_RT_MAIN_THREAD_PRIORITY=19
CONFIG_RT_SERIAL_RB_BUFSZ=256
CONFIG_RT_USING_HWMAILBOX=y
CONFIG_RT_USING_ULOG=y
CONFIG_ULOG_OUTPUT_LVL_I=y
CONFIG_ULOG_USING_ISR_LOG=y
CONFIG_ULOG_OUTPUT_FLOAT=y
# CONFIG_ULOG_USING_COLOR is not set
CONFIG_ULOG_OUTPUT_THREAD_NAME=y
CONFIG_RT_TIMER_THREAD_STACK_SIZE=1024
CONFIG_RT_USING_MEMHEAP=y
CONFIG_RT_USING_MEMTRACE=y
CONFIG_BSP_USING_FULL_ASSERT=y
CONFIG_USING_BUTTON_LIB=y
CONFIG_USING_CPU_USAGE_PROFILER=y
CONFIG_PKG_USING_LITTLEVGL2RTT=y
# CONFIG_LV_USING_EXT_RESOURCE_MANAGER is not set
CONFIG_LV_INDEV_DEF_READ_PERIOD=16
CONFIG_LV_IMG_CACHE_DEF_SIZE=16
CONFIG_LV_USE_PERF_MONITOR=y
CONFIG_LV_FONT_MONTSERRAT_12=y
# CONFIG_LV_FONT_MONTSERRAT_14 is not set
CONFIG_LV_FONT_MONTSERRAT_20=y
CONFIG_LV_FONT_MONTSERRAT_24=y
CONFIG_LV_FONT_MONTSERRAT_28=y
CONFIG_LV_FONT_MONTSERRAT_36=y
CONFIG_LV_FONT_DEFAULT_MONTSERRAT_16=y
# CONFIG_LV_USE_THEME_DEFAULT is not set
# CONFIG_LV_USE_THEME_BASIC is not set
CONFIG_LV_USE_FS_POSIX=y
CONFIG_LV_FS_POSIX_LETTER=47
CONFIG_LV_USE_SJPG=y
CONFIG_LV_USE_QRCODE=y
CONFIG_LV_USE_EZIP=y
CONFIG_LV_FB_LINE_NUM=152
6 changes: 6 additions & 0 deletions example/multimedia/lvgl/games/flappybird/project/rtconfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@






Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef RTCONFIG_PROJECT_H__
#define RTCONFIG_PROJECT_H__

#if defined(_MSC_VER)
#define RT_HEAP_SIZE (680000)
#define NORESOURCE //RT_VESRION in winuser.h
#define _CRT_ERRNO_DEFINED //errno macro redefinition
#define _INC_WTIME_INL//dfs_elm.c time.h conflicts with wtime.inl
#define _INC_TIME_INL //dfs_elm.c time.h conflicts with wtime.inl

/* disable some warning in MSC */
#pragma warning(disable:4273) /* to ignore: warning C4273: inconsistent dll linkage */
#pragma warning(disable:4312) /* to ignore: warning C4312: 'type cast' : conversion from 'rt_uint32_t' to 'rt_uint32_t *' */
#pragma warning(disable:4311) /* to ignore: warning C4311: 'type cast' : pointer truncation from 'short *__w64 ' to 'long' */
#pragma warning(disable:4996) /* to ignore: warning C4996: The POSIX name for this item is deprecated. */
#pragma warning(disable:4267) /* to ignore: warning C4267: conversion from 'size_t' to 'rt_size_t', possible loss of data */
#pragma warning(disable:4244) /* to ignore: warning C4244: '=' : conversion from '__w64 int' to 'rt_size_t', possible loss of data */

#endif /* end of _MSC_VER */

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>vs</ProjectName>
<ProjectGuid>{4A6BF1B1-C645-4BAD-A9B7-7B6E3DB67B2C}</ProjectGuid>
<RootNamespace>vs2008</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>11.0.50727.1</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\;..\..\include;..\..\bsp\vs2008;..\..\components\finsh;..\..\components\dfs\include;..\..\components\dfs\filesystems\uffs\src\inc\;..\..\components\dfs\filesystems\uffs;..\..\components\drivers\include;..\..\components\dfs\filesystems\jffs2\src;..\..\components\dfs\filesystems\jffs2\kernel;..\..\components\dfs\filesystems\jffs2\include;..\..\components\dfs\filesystems\jffs2\;..\..\components\dfs\filesystems\jffs2\cyg\compress;..\..\components\init;.\drivers;..\..\components\net\lwip\src\include\;..\..\components\net\lwip\src;..\..\components\net\lwip\src\arch\include;..\..\components\net\lwip\src\include\ipv4;.\pcap\Include;.\SDL2-2.0.7\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;MSVC;_TIME_T_DEFINED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4828;4116;4146;4715;4716;4090;4018;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>.\pcap\Lib;.\SDL2-2.0.7\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Loading
Loading