当前位置:网站首页>Esp32 development -lvgl display picture
Esp32 development -lvgl display picture
2022-06-11 04:07:00 【z_ Curtain】
How to use pictures
LVGL There are two ways to display pictures in
1、 As internal memory (RAM or ROM) The variables in the
2、 As a document
Read pictures internally
advantage : Data is compiled into firmware along with code , Easy to use .
shortcoming : Images need to be converted into array form by tools , Too many pictures perhaps The picture resolution is too large Compilation errors may occur during ( Constant data exceeded DROM).
The method of use is similar to the external font library , Use the tool to turn the picture into a .c file , In the file, there will be a constant array and... For storing image data LVGL Picture data type structure of , At the same time, the structure variable can use the picture .
const lv_img_dsc_t test = {
.header.always_zero = 0,
.header.w = 225,
.header.h = 113,
.data_size = 25425 * LV_COLOR_SIZE / 8,
.header.cf = LV_IMG_CF_TRUE_COLOR,
.data = test_map,
};
adopt LVGL api The picture can be displayed
lv_obj_t * icon = lv_img_create(lv_scr_act(), NULL);
/*From variable*/
LV_IMG_DECLARE(test );
lv_img_set_src(icon, &test );
If the image is converted using an online or tool converter , You should use LV_IMG_DECLARE(my_icon_dsc) The image declares the bits to be used in the file
Set up .
// amount to extern
#define LV_IMG_DECLARE(var_name) extern const lv_img_dsc_t var_name;
External read picture
There are two ways to store external pictures
1、 As png、jpg Wait for the picture format
Need to use SD Memory devices such as cards store pictures , It also needs to decode the picture ,LVGL Provide picture decoding API( Only partial format decoding should be supported , for example PNG)
lv_res_t res;
lv_img_decoder_dsc_t dsc;
res = lv_img_decoder_open(&dsc, &my_img_dsc, LV_COLOR_WHITE);
if(res == LV_RES_OK) {
/*Do something with `dsc->img_data`*/
lv_img_decoder_close(&dsc);
}
2、 As bin file
When pictures are bin When the file is read , need esp32 Run the file system , For details, please refer to ESP-IDF demo Medium spiffs.
Besides , It needs to be realized lvgl File manipulation functions in the file system . Refer to the following figure for specific documents .
As a binary file ,bin The file can specify the desired color format :
RGB332 be used for 8 Metachromatic depth
RGB565 be used for 16 Metachromatic depth
RGB565 In exchange for 16 Bit color depth ( Swapped two bytes )
RGB888 be used for 32 Metachromatic depth
lv_obj_t * icon = lv_img_create(lv_scr_act(), NULL);
/*From file*/
lv_img_set_src(icon, "S:test.bin");
边栏推荐
- Market prospect analysis and Research Report of programmable digital temperature regulator in 2022
- Implementation of one-dimensional convolutional neural network CNN based on FPGA (V) data quantization (with code)
- Source insight 4.0 setting shortcut keys for comments and uncomments
- Embedded basic interface-i2c
- 如何提高回归测试效率
- ETH 中继接口
- Eth Transfer
- Unity prefab scene 冲突合并工具 UnityYAMLMerge
- Evil CSRF
- Code replicates CSRF attack and resolves it
猜你喜欢

Shell script binary encryption

2022 年 5 月产品大事记

Comparison of four delivery modes of Message Oriented Middleware

Source insight 4.0 setting shortcut keys for comments and uncomments

Source Insight 4.0设置注释与反注释的快捷键

Manual testing cannot be changed to automated testing. What is missing?

A - Eddy‘s AC难题(C语言)

合理使用线程池以及线程变量

JMeter piezometric interface programming North

数据分析师必知必会的统计学知识
随机推荐
Pictures that make people feel calm and warm
Market prospect analysis and Research Report of surround packing machine in 2022
VIM quickly select a method / function
合理使用线程池以及线程变量
[interpretable] | axiomatic attribute for deep networks
Evil CSRF
Linq. pdf
Build local source 2.0 for Galaxy Kirin server version
Large factory outsourcing or self research company? How to choose a job for a tester?
Typera+picgo+ common configurations of Tencent cloud cos
Discussion on the development trend of remote power management unit (Intelligent PDU)
Eth Of Erc20 And Erc721
Go failing - expected ‘package‘, found ‘EOF‘
[signalr complete series] Net6 Zhongshi signalr communication
MAUI 迁移指南
Pci/pcie related knowledge
Detailed explanation of network time synchronization (NTP network timing) of video monitoring system
AI助力,释放法务势能!iTerms合同智审系统重磅发布
密码找回功能可能存在的问题(补充)
A Security Analysis Of Browser Extensions