当前位置:网站首页>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的一些推荐功能(编码格式、自动保存、代码提示、动态语法检查、多核编译)
觉得本次分享的文章对您有帮助,随手点[在看]并转发分享,也是对我的支持。
边栏推荐
- Introduction to mt7628k eCos development
- SQL learning notes (01) - basic knowledge of database
- PHP merges multiple arrays. The same element takes the intersection of different elements to form an array
- How to launch circle of friends marketing and wechat group activities
- js原型继承仅可继承实例而非构造器
- PR training notes
- Can diffusion models be regarded as an autoencoder?
- SQL learning notes (03) -- data constraint relationship
- [pytorch] softmax function
- Win7 pyinstaller reports an error DLL load failed while importing after packaging exe_ Socket: parameter error
猜你喜欢

计网01-物理层

Nacos service configuration and persistence configuration

Implementation and application of queue

MySQL optimization

樹結構---二叉樹2非遞歸遍曆

【pytorch】nn. Crossentropyloss() and nn NLLLoss()

2.4 激活函数

Preparing for the Blue Bridge Cup -- bit operation

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

Bird recognition app
随机推荐
Construction of esp8266 FreeRTOS development environment
微信小程序 webview 禁止页面滚动,同时又不影响业务内overflow的滚动的实现方式
PHP array functions (merge, split, append, find, delete, etc.)
[ESP nanny level tutorial] crazy completion chapter - Case: chemical environment system detection based on Alibaba cloud and Arduino, supporting nail robot alarm
tensorrt yolov5_ trt. Py comments
js 使用toString 区分Object、Array
富文本实现插值
Niuke monthly race 22- collect pieces of paper
js变量提升(hoisting)
【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
js this丢失问题分析 及 解决方案
R language observation log (part24) -- initialization settings
NiO zero copy
OSPF - virtual link details (including configuration commands)
How Kolo enables NFT music industry
Analysis and solution of JS this loss
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DHT11 +NodeJs本地服务+ MySQL数据库
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DS18B20 temperature sensor +nodejs local service + MySQL database
Structure de l'arbre - - - arbre binaire 2 traversée non récursive
Clickhouse: Test on query speed of A-share minute data [Part 2]