1337|5

41

帖子

0

TA的资源

一粒金砂(中级)

楼主
 

航芯ACM32G103开发板评测 06 1.28圆形屏幕 LVGL移植 [复制链接]

 

航芯ACM32G103开发板评测 06 1.28圆形屏幕 LVGL移植

参考移植教程

https://bbs.eeworld.com.cn/thread-1270136-1-1.html

软硬件平台

  1. 航芯ACM32G103开发板
  2. 1.28寸圆形彩色TFT显示屏高清IPS 模块240X240 SPI接口 GC9A01驱动芯片
  3. LVGL V8.3.1源码

LVGL

LVGL(Light and Versatile Graphics Library)是一个免费的开源图形库,提供创建具有易 于使用的图形元素、漂亮的视觉效果和低内存占用的嵌入式 GUI。

LVGL 是一款具有丰富的部件,具备高级图形特性,支持多种输入设备, 多国语言和独立于硬件之外等免费的开源图形库。接下来我们来看一下 LVGL 图形用户库的主要特点:

强大的构建块:按钮、图表、列表、滑块、图像等部件。
具有高级图形属性:具有动画、抗锯齿、不透明度、平滑滚动的高级图形。
支持各种输入设备:如触摸、鼠标、键盘、编码器。
支持多语言:UTF-8 编码。
支持多显示器:它可以同时使用多个 TFT 或者单色显示器。
支持多种样式属性:它具有类 CSS 样式的完全可定制的图形元素。
独立于硬件之外:它与任何微控制器或显示器一起使用。
可扩展性:它能够以小内存运行(最低 64 kB 闪存,16 kB RAM 的 MCU)。
支持操作系统、外部存储器和 GPU(不是必需的)。
具有高级图形效果:可进行单帧缓冲区操作。
纯 C 编写: C 语言编写以获得最大的兼容性。

快速移植过程

  1. 在已有的ACM32G103RCT6 TFT 裸机移植LVGL的工程模板上进行修改 添加LVGL源代码文件

2.在已有的工程模板上,添加GC9A01驱动屏幕代码

3.在KEIL添加相关源文件,添加相关路径,删除之前的屏幕驱动文件

4.修改lv_port_disp屏幕显示接口文件

5.添加LCD屏幕初始化函数,绘图绘点函数

  1. /**********************
  2. * STATIC FUNCTIONS
  3. **********************/
  4. /*Initialize your display and the required peripherals.*/
  5. static void disp_init(void)
  6. {
  7. /*You code here*/
  8. LCD_Init();
  9. LCD_BLK_SET;//通过IO控制背光亮
  10. }
  11. volatile bool disp_flush_enabled = true;
  12. /* Enable updating the screen (the flushing process) when disp_flush() is called by LVGL
  13. */
  14. void disp_enable_update(void)
  15. {
  16. disp_flush_enabled = true;
  17. }
  18. /* Disable updating the screen (the flushing process) when disp_flush() is called by LVGL
  19. */
  20. void disp_disable_update(void)
  21. {
  22. disp_flush_enabled = false;
  23. }
  24. /*Flush the content of the internal buffer the specific area on the display
  25. *You can use DMA or any hardware acceleration to do this operation in the background but
  26. *'lv_disp_flush_ready()' has to be called when finished.*/
  27. static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
  28. {
  29. if(disp_flush_enabled) {
  30. /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
  31. uint16_t x,y;
  32. for(y = area->y1; y <= area->y2; y++) {
  33. for(x = area->x1; x <= area->x2; x++) {
  34. /*Put a pixel to the display. For example:*/
  35. /*put_px(x, y, *color_p)*/
  36. GUI_DrawPoint(x,y,lv_color_to16(*color_p));
  37. color_p++;
  38. }
  39. }
  40. }
  41. /*IMPORTANT!!!
  42. *Inform the graphics library that you are ready with the flushing*/
  43. lv_disp_flush_ready(disp_drv);
  44. }

基本上就完成了一个屏幕与LVGL的对接,当你换其他的屏幕是基本上也是这样子的操作,前提是屏幕驱动文件一定要适配成功。

案例测试

  1. 官方案例demo函数 添加官方demo代码,打开LV_USE_DEMO_WIDGETS宏定义
  1. /******************************************************************************
  2. *<a href="https://bbs.eeworld.com.cn/home.php?mod=space&uid=1307177" target="_blank">@File</a> : main.c
  3. *<a href="https://bbs.eeworld.com.cn/home.php?mod=space&uid=159083" target="_blank">@brief</a> : main program
  4. ******************************************************************************/
  5. #include "main.h"
  6. #include "lvgl_timer.h"
  7. LoopFunction loopFunction[MAX_INIT_FUNCTIONS];
  8. int loopFunctionCount = 0;
  9. void callInitFunctions(void){
  10. uint8_t i ;
  11. for(i = 0 ; i<loopFunctionCount;i++){
  12. loopFunction<i>();
  13. }
  14. }
  15. /******************************************************************************
  16. *@brief : main program
  17. *@param : none
  18. *@return: none
  19. ******************************************************************************/
  20. #include "lvgl.h"
  21. #include "lv_port_disp.h"
  22. #include "lv_port_indev.h"
  23. #include "lv_demo_widgets.h"
  24. #include "lv_examples.h"
  25. int main(void)
  26. {
  27. HAL_Init();
  28. SystemClock_Config();
  29. BSP_UART_Init();
  30. TIM6_Init();
  31. //LVGL初始化
  32. lv_init();
  33. //显示器初始化
  34. lv_port_disp_init();
  35. //界面生成
  36. lv_demo_widgets();
  37. while(1)
  38. {
  39. lv_task_handler();
  40. HAL_Delay(5);
  41. }
  42. }
  1. 编写自定义LVGL显示代码
  1. /******************************************************************************
  2. *@file : main.c
  3. *@brief : main program
  4. ******************************************************************************/
  5. #include "main.h"
  6. #include "lvgl_timer.h"
  7. LoopFunction loopFunction[MAX_INIT_FUNCTIONS];
  8. int loopFunctionCount = 0;
  9. void callInitFunctions(void){
  10. uint8_t i ;
  11. for(i = 0 ; i<loopFunctionCount;i++){
  12. loopFunction<i>();
  13. }
  14. }
  15. /******************************************************************************
  16. *@brief : main program
  17. *@param : none
  18. *@return: none
  19. ******************************************************************************/
  20. #include "lvgl.h"
  21. #include "lv_port_disp.h"
  22. #include "lv_port_indev.h"
  23. #include "lv_demo_widgets.h"
  24. #include "lv_examples.h"
  25. static void lv_ex_label_1(void)
  26. {
  27. /* Create a screen */
  28. lv_obj_t * scr = lv_obj_create(NULL);
  29. lv_scr_load(scr);
  30. lv_obj_set_style_bg_color(scr,lv_palette_main(LV_PALETTE_ORANGE),0);
  31. lv_obj_align(scr,LV_ALIGN_CENTER,0,0);
  32. /* Create a button */
  33. lv_obj_t * btn = lv_btn_create(scr);
  34. lv_obj_align(btn, NULL, LV_ALIGN_CENTER, 40);
  35. /* Create a label for the button */
  36. lv_obj_t * label = lv_label_create(btn);
  37. lv_label_set_text(label, "Hello EEWORLD !");
  38. /* Create a button */
  39. lv_obj_t * btn1 = lv_btn_create(scr);
  40. lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 90);
  41. /* Create a label for the button */
  42. lv_obj_t * label1 = lv_label_create(btn1);
  43. lv_label_set_text(label1, "By End 2024.01.24!");
  44. /* Create a button */
  45. lv_obj_t * btn2 = lv_btn_create(scr);
  46. lv_obj_align(btn2, NULL, LV_ALIGN_CENTER, 140);
  47. /* Create a label for the button */
  48. lv_obj_t * label2 = lv_label_create(btn2);
  49. lv_label_set_text(label2, "ACM32G103-Board Testing");
  50. }
  51. int main(void)
  52. {
  53. HAL_Init();
  54. SystemClock_Config();
  55. BSP_UART_Init();
  56. TIM6_Init();
  57. //LVGL初始化
  58. lv_init();
  59. //显示器初始化
  60. lv_port_disp_init();
  61. //界面生成
  62. lv_ex_label_1();
  63. while(1)
  64. {
  65. lv_task_handler();
  66. HAL_Delay(5);
  67. }
  68. }
  1. 测试效果

最新回复

提高点SPI速率看看呢。   详情 回复 发表于 2024-1-26 11:24
点赞 关注
 
 

回复
举报

7069

帖子

0

TA的资源

五彩晶圆(高级)

沙发
 

在已有的ACM32G103RCT6 TFT 裸机移植LVGL的工程模板上进行修改 添加LVGL源代码文件,这个过程介绍的比较清楚了

 
 
 

回复

485

帖子

3

TA的资源

五彩晶圆(初级)

板凳
 

圆屏显示效果看着不错 

 
 
 

回复

7572

帖子

2

TA的资源

版主

4
 

滑动的时候帧率怎么样?

点评

我这个效果一般,感觉很慢,后面看看这么加速一波,  详情 回复 发表于 2024-1-25 17:47
 
 
 

回复

41

帖子

0

TA的资源

一粒金砂(中级)

5
 
wangerxian 发表于 2024-1-25 17:40 滑动的时候帧率怎么样?

我这个效果一般,感觉很慢,后面看看这么加速一波,

点评

提高点SPI速率看看呢。  详情 回复 发表于 2024-1-26 11:24
 
 
 

回复

7572

帖子

2

TA的资源

版主

6
 
みずじ 发表于 2024-1-25 17:47 我这个效果一般,感觉很慢,后面看看这么加速一波,

提高点SPI速率看看呢。

 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 2/10 下一条
【干货上新】电源解决方案和技术第二趴 | DigiKey 应用探索站
当月好物、电源技术资源、特色活动、DigiKey在线实用工具,干货多多~

查看 »

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网 4

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表