当前位置:网站首页>LVGL V8.2字符串显示在Keil MDK上需要注意的事项(以小熊派为例)
LVGL V8.2字符串显示在Keil MDK上需要注意的事项(以小熊派为例)
2022-07-01 09:33:00 【Engineer-Bruce_Yang】
点击上方“嵌入式应用研究院”,选择“置顶/星标公众号”
干货福利,第一时间送达!
来源 | 嵌入式应用研究院
整理&排版 | 嵌入式应用研究院
之前在LVGL模拟器CodeBlock上写了一个多语言的demo,用于学习LVGL多国语言的应用,如下所示:

后来我将其移植到小熊派开发板以后,结果就成了这样,连控件显示的位置都变了(控件移位的具体原因不详,待后续分析LVGL源代码):

这一看就是编码问题。按以往的经验,直接在工程目录下找到有中文字符串的这个文件,用notepad++将其转成utf-8,然后直接保存再重新打开Keil MDK就可以了,那么试试吧:


接下来打开MDK工程,重新编译,出现了6个Error:

1、排坑找错

错误原因显示的是调用宏的参数过多,但实际上这就只是传了一个参数呀...不应该,我开始怀疑编译器是否支持宽字符显示的问题,因此搜索Keil MDK帮助手册看到了这一项:


按照文档的指示,我在Misc Controls这个配置项上添加了--no-multibyte-chars,然后重新编译工程:

接下来再将其下载到开发板上:


最终显示正常。
2、核心原因
通过STM32CubeMX生成的程序源文件的编码格式并不是UTF-8或者UTF16,因此如果在某些文件下写中文以及一些特殊国家语言字符则需要手动对该文件进行转换。如果源文件编码为 UTF-8 或 UTF-16,并且文件以字节顺序标记开头,则编译器将忽略 --locale 和 --[no_]multibyte_chars 选项并将文件解释为 UTF-8 或 UTF- 16。
3、正确做法
通常做多语言显示,我们需要将每个不同国家的语言需要单独拧到不同的文件中,然后将其单独进行转码,以方便进行统一管理,例如3D打印机固件Marlin代码,就是这么做的:

而一些模拟显示软件,编码环境较为完善,很多坑其实已经帮我们提前排除了,因此在面对一些编码环境没有那么完善的平台来说,了解环境配置以及一些编码规则则更有利于我们定位问题。如果你有更好的方法,欢迎评论区留言,一起交流LVGL应用技术。目前应用例程还在修改中,后续将会共享到Github或者Gitee,地址将在评论区给出。下期将分享如何将按键模拟旋转编码器来实现键盘输入。
往期精彩
分享一个在Keil开发环境中配置代码格式化工具Astyle(美化代码风格)
Keil MDK 将升级为 Keil Studio,你想要的黑色主题来了,附手把手使用教程
Keil MDK的一些推荐功能(编码格式、自动保存、代码提示、动态语法检查、多核编译)
觉得本次分享的文章对您有帮助,随手点[在看]并转发分享,也是对我的支持。
边栏推荐
- [ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DHT11 +nodejs local service + MySQL database
- Is it safe to dig up money and make new shares
- nacos簡易實現負載均衡
- Short circuit operator lazy evaluation
- How to launch circle of friends marketing and wechat group activities
- Tree structure -- binary tree 2 non recursive traversal
- Understanding and implementation of AVL tree
- js原型陷阱
- Weidongshan board compilation kernel problem solving
- 3D printing Arduino four axis aircraft
猜你喜欢
![[video game training] real topic of 2013 video game of infrared optical communication device](/img/ef/c2c45c1c6c24aed0a4e93101047372.png)
[video game training] real topic of 2013 video game of infrared optical communication device

【检测技术课案】简易数显电子秤的设计与制作

How to realize the usage of connecting multiple databases in idel

nacos簡易實現負載均衡

MapReduce编程基础

计网01-物理层

OSPF - virtual link details (including configuration commands)

nacos服务配置和持久化配置

NoSQL数据库的安装和使用

Mise en œuvre simple de l'équilibrage de la charge par nacos
随机推荐
MapReduce programming basics
SQL learning notes (03) -- data constraint relationship
[video game training] real topic of 2013 video game of infrared optical communication device
I use flask to write the website "one"
FAQ | FAQ for building applications for large screen devices
Why is the Ltd independent station a Web3.0 website!
2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据
Naoqi robot summary 28
Ranking list of domestic databases in February, 2022: oceanbase regained the "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
Introduction to mt7628k eCos development
SQL学习笔记(04)——数据更新、查询操作
Get the list of a column in phpexcel get the letters of a column
Bird recognition app
队列的实现和应用
JS variable lifting
js 使用toString 区分Object、Array
js this丢失问题分析 及 解决方案
Win7 pyinstaller reports an error DLL load failed while importing after packaging exe_ Socket: parameter error
Exception handling of classes in C #
ES6-const本质与完全不可改实现(Object.freeze)