使用外部Flash存放GUIX资源
加载中文字体后,字体资源变得非常大,内部Flash空间有限,无法放下这些资源,因此需要使用外部Flash来存放这些资源。本文以GUIX的中文字体资源为例,介绍如何从外部Flash装载GUIX资源。
·
加载中文字体后,字体资源变得非常大,内部Flash空间有限,无法放下这些资源,因此需要使用外部Flash来存放这些资源。本文以GUIX的中文字体资源为例,介绍如何从外部Flash装载GUIX资源。
1 添加中文字体
- 指定中文字符区间、配置分辨率和高度。

- 字体资源大小大概在6兆字节左右

- 选择菜单Configure->Languages,取消选择“Statically Defined”

- 选择菜单Configure->Themes,取消选择“Statically Defined”

- 生成binary文件

2 烧录资源文件到外部Flash
- 打开STM32CubeProgrammer,选择外部装载器

- 打开前面生成的binary文件

- 指定下载地址、连接开发板、下载资源

3 从外部Flash装载资源
3.1 初始化QSPI用来从外部Flash读取数据
- 添加相关bsp文件

- 加上初始化代码
BSP_QSPI_Init();
BSP_QSPI_EnableMemoryMappedMode();
3.2 调用GUIX API装置资源
- 变量定义
GX_THEME *theme = GX_NULL;
GX_STRING **language_table = GX_NULL;
GX_UBYTE *binres_root_address = 0x90000000;
- 主题加载逻辑
UINT load_theme(GX_UBYTE *root_address, INT theme_id)
{
UINT status = GX_SUCCESS;
if (theme)
{
memory_free(theme);
theme = GX_NULL;
}
/* Load a theme from binary data memory. */
status = gx_binres_theme_load(root_address,/* Address of binary resource data. */
theme_id, /* Theme identification, 0, 1, 2: 1th, 2nd, 3rd theme in the binary resource data. */
&theme); /* Loaded theme. */
if (status == GX_SUCCESS)
{
/* Install themes to specified display. */
gx_display_theme_install(root->gx_window_root_canvas->gx_canvas_display, theme);
}
return status;
}
- 语言加载逻辑
UINT load_language_table(GX_UBYTE *root_address)
{
UINT status = GX_SUCCESS;
if (language_table)
{
memory_free(language_table);
language_table = GX_NULL;
}
/* Load language table from binary data memory. */
status = gx_binres_language_table_load_ext(root_address, /* Address of binary resource data. */
&language_table); /* Loaded language table that contains all languages in the specified binary resource data. */
if (language_table)
{
/* Set language table. */
gx_display_language_table_set_ext(root->gx_window_root_canvas->gx_canvas_display, (GX_CONST GX_STRING **)language_table, DISPLAY_1_LANGUAGE_TABLE_SIZE, DISPLAY_1_STRING_TABLE_SIZE);
/* Set active language. */
gx_system_active_language_set(LANGUAGE_ENGLISH);
}
return status;
}
- 在GUIX初始化阶段调用上面的主题和语言加载函数,就完成了所有资源的加载。
openvela 操作系统专为 AIoT 领域量身定制,以轻量化、标准兼容、安全性和高度可扩展性为核心特点。openvela 以其卓越的技术优势,已成为众多物联网设备和 AI 硬件的技术首选,涵盖了智能手表、运动手环、智能音箱、耳机、智能家居设备以及机器人等多个领域。
更多推荐



所有评论(0)