962|1

441

帖子

3

TA的资源

纯净的硅(高级)

楼主
 

【STM32F723 Discovery Kit】移植LVGL [复制链接]

本帖最后由 TL-LED 于 2023-10-23 17:35 编辑

这篇来学习下在STM32F723 Discovery Kit开发板上移植LVGL。

 

一、下载LVGL

 

1.1、源码地址

下载地址:

链接已隐藏,如需查看请登录或者注册

 

1.2、使用git下载源码

 

下载v8.3版本分支

执行命令:git clone -b release/v8.3 --depth=1

链接已隐藏,如需查看请登录或者注册

 

二、添加文件

 

在项目中添加源文件,将LVGL相应目录下的文件添加到项目。

 

三、修改文件

 

3.1、修改lv_port_disp_template.c

修改显示屏尺寸、初始化和驱动程序。

/**
 * @File lv_port_disp_templ.c
 *
 */

/*Copy this file as "lv_port_disp.c" and set this value to "1" to enable content*/
#if 1

/*********************
 *      INCLUDES
 *********************/
#include "lv_port_disp_template.h"
#include <stdbool.h>
#include "STM32F723E-Discovery/stm32f723e_discovery_lcd.h" 

/*********************
 *      DEFINES
 *********************/
//#ifndef MY_DISP_HOR_RES
//    #warning Please define or replace the macro MY_DISP_HOR_RES with the actual screen width, default value 320 is used for now.
//    #define MY_DISP_HOR_RES    320
//#endif

//#ifndef MY_DISP_VER_RES
//    #warning Please define or replace the macro MY_DISP_HOR_RES with the actual screen height, default value 240 is used for now.
//    #define MY_DISP_VER_RES    240
//#endif

/**********************
 *      TYPEDEFS
 **********************/
#define MY_DISP_HOR_RES    240
#define MY_DISP_VER_RES    240
 

/**********************
 *  STATIC PROTOTYPES
 **********************/
static void disp_init(void);

static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
//        const lv_area_t * fill_area, lv_color_t color);

/**********************
 *  STATIC VARIABLES
 **********************/

/**********************
 *      MACROS
 **********************/

/**********************
 *   GLOBAL FUNCTIONS
 **********************/

void lv_port_disp_init(void)
{
    /*-------------------------
     * Initialize your display
     * -----------------------*/
    disp_init();

    /*-----------------------------
     * Create a buffer for drawing
     *----------------------------*/

    /**
     * LVGL requires a buffer where it internally draws the widgets.
     * Later this buffer will passed to your display driver's `flush_cb` to copy its content to your display.
     * The buffer has to be greater than 1 display row
     *
     * There are 3 buffering configurations:
     * 1. Create ONE buffer:
     *      LVGL will draw the display's content here and writes it to your display
     *
     * 2. Create TWO buffer:
     *      LVGL will draw the display's content to a buffer and writes it your display.
     *      You should use DMA to write the buffer's content to the display.
     *      It will enable LVGL to draw the next part of the screen to the other buffer while
     *      the data is being sent form the first buffer. It makes rendering and flushing parallel.
     *
     * 3. Double buffering
     *      Set 2 screens sized buffers and set disp_drv.full_refresh = 1.
     *      This way LVGL will always provide the whole rendered screen in `flush_cb`
     *      and you only need to change the frame buffer's address.
     */

    /* Example for 1) */
    static lv_disp_draw_buf_t draw_buf_dsc_1;
    static lv_color_t buf_1[MY_DISP_HOR_RES * 10];                          /*A buffer for 10 rows*/
    lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10);   /*Initialize the display buffer*/

//    /* Example for 2) */
//    static lv_disp_draw_buf_t draw_buf_dsc_2;
//    static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10];                        /*A buffer for 10 rows*/
//    static lv_color_t buf_2_2[MY_DISP_HOR_RES * 10];                        /*An other buffer for 10 rows*/
//    lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10);   /*Initialize the display buffer*/

//    /* Example for 3) also set disp_drv.full_refresh = 1 below*/
//    static lv_disp_draw_buf_t draw_buf_dsc_3;
//    static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES];            /*A screen sized buffer*/
//    static lv_color_t buf_3_2[MY_DISP_HOR_RES * MY_DISP_VER_RES];            /*Another screen sized buffer*/
//    lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2,
//                          MY_DISP_VER_RES * LV_VER_RES_MAX);   /*Initialize the display buffer*/

    /*-----------------------------------
     * Register the display in LVGL
     *----------------------------------*/

    static lv_disp_drv_t disp_drv;                         /*Descriptor of a display driver*/
    lv_disp_drv_init(&disp_drv);                    /*Basic initialization*/

    /*Set up the functions to access to your display*/

    /*Set the resolution of the display*/
    disp_drv.hor_res = MY_DISP_HOR_RES;
    disp_drv.ver_res = MY_DISP_VER_RES;

    /*Used to copy the buffer's content to the display*/
    disp_drv.flush_cb = disp_flush;

    /*Set a display buffer*/
    disp_drv.draw_buf = &draw_buf_dsc_1;

    /*Required for Example 3)*/
    //disp_drv.full_refresh = 1;

    /* Fill a memory array with a color if you have GPU.
     * Note that, in lv_conf.h you can enable GPUs that has built-in support in LVGL.
     * But if you have a different GPU you can use with this callback.*/
    //disp_drv.gpu_fill_cb = gpu_fill;

    /*Finally register the driver*/
    lv_disp_drv_register(&disp_drv);
}

/**********************
 *   STATIC FUNCTIONS
 **********************/

/*Initialize your display and the required peripherals.*/
static void disp_init(void)
{
    /*You code here*/
	BSP_LCD_Init();
	BSP_LCD_Clear(LCD_COLOR_RED);
}

volatile bool disp_flush_enabled = true;

/* Enable updating the screen (the flushing process) when disp_flush() is called by LVGL
 */
void disp_enable_update(void)
{
    disp_flush_enabled = true;
}

/* Disable updating the screen (the flushing process) when disp_flush() is called by LVGL
 */
void disp_disable_update(void)
{
    disp_flush_enabled = false;
}

/*Flush the content of the internal buffer the specific area on the display
 *You can use DMA or any hardware acceleration to do this operation in the background but
 *'lv_disp_flush_ready()' has to be called when finished.*/
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
		if (disp_flush_enabled) 
		{
		BSP_LCD_DrawRGBImage(area->x1, area->y1, area->x2 - area->x1 + 1, area->y2 - area->y1 + 1, (uint8_t *)color_p);
    }
	
    /*IMPORTANT!!!
     *Inform the graphics library that you are ready with the flushing*/
    lv_disp_flush_ready(disp_drv);
}

/*OPTIONAL: GPU INTERFACE*/

/*If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color*/
//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
//                    const lv_area_t * fill_area, lv_color_t color)
//{
//    /*It's an example code which should be done by your GPU*/
//    int32_t x, y;
//    dest_buf += dest_width * fill_area->y1; /*Go to the first line*/
//
//    for(y = fill_area->y1; y <= fill_area->y2; y++) {
//        for(x = fill_area->x1; x <= fill_area->x2; x++) {
//            dest_buf[x] = color;
//        }
//        dest_buf+=dest_width;    /*Go to the next line*/
//    }
//}


#else /*Enable this file at the top*/

/*This dummy typedef exists purely to silence -Wpedantic.*/
typedef int keep_pedantic_happy;
#endif

 

3.2、心跳程序

/**
  * @brief  This function handles SysTick Handler.
  * @param  None
  * @retval None
  */
void SysTick_Handler(void)
{
  HAL_IncTick();
	lv_tick_inc(1);
}

 

3.3、main.c

#include "main.h"
#include "led/led.h"
#include "delay/delay.h"
#include "key/key.h"
#include "usart/usart.h"
#include "sram/sram.h"
#include "STM32F723E-Discovery/stm32f723e_discovery_lcd.h"  
#include "STM32F723E-Discovery/stm32f723e_discovery_qspi.h"
#include "lvgl.h"
#include "lv_port_indev_template.h"
#include "lv_port_disp_template.h"
#include "lv_port_indev_template.h"
#include "lvgl/demos/benchmark/lv_demo_benchmark.h"

static void MPU_Config(void);
static void SystemClock_Config(void);
static void CPU_CACHE_Enable(void);

int main(void)
{
	uint16_t i=0;
	uint8_t txbuf[10];
	uint8_t rxbuf[10];
	
	HAL_Init();
  MPU_Config();					/* Configure the MPU attributes */
  CPU_CACHE_Enable();		/* Enable the CPU Cache */
  
  SystemClock_Config();	/* Configure the system clock to 216 MHz */
	delay_init(216);
	led_init();
	usart_init(115200);
	
	lv_init();
	lv_port_disp_init();
	
	lv_demo_benchmark();
	
  while (1)
  {
		LED5_TOGGLE();
    delay_ms(5);
		lv_task_handler();
  }
}

 

 

四、程序运行

lvgl

 

 

 
 
 
 
 
 

 

此帖出自stm32/stm8论坛

最新回复

谢谢分享,期待后续   详情 回复 发表于 2023-10-25 16:48
点赞 关注
 

回复
举报

7628

帖子

2

TA的资源

五彩晶圆(高级)

沙发
 

谢谢分享,期待后续

此帖出自stm32/stm8论坛
 
个人签名

默认摸鱼,再摸鱼。2022、9、28

 

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

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
推荐帖子
FPGA——人工智能的未来

FPGA——人工智能的未来 基于大规模数字逻辑的人工智能实现的可行性分析 注:本文为一年前写成,具有一定的科普性,其中有一些 ...

1602的学习总结(菜鸟入门级)

先来叙述一些概念。 LCM和LCD的区别 LCM【Liquid Crystal Module】液晶显示模块,通常包括显示驱动电路,接口电路等等。往 ...

ubuntu下修改内核发生“ncurses libraries“错误(解决方法)

BSEC@bsec-server:~/kernel/Kernel$ make menuconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/basic/docproc HOSTCC script ...

有奖直播:nanoPower技术:延长电池寿命,提升传感器性能 直播资料合集

直播资料合集 nanoPower技术:延长电池寿命,提升传感器性能 直播回放: >>点击观看 直播文档: > ...

【小熊派BearPi-HM Micro】三:烧录编译的固件程序

本帖最后由 数码小叶 于 2022-4-5 13:15 编辑 上一篇已经成功编译了源码,接下来就是把编译的源码结果烧录到小熊派BearPi-HM ...

DC-DC升压到5V异常

我的升压电路图如下图: 608263 我的BAT输入是三节7号干电池,用的DC-DC升压芯片是PT1311,下图是PT1311部分介绍: 608 ...

【花雕动手做】有趣好玩的音乐可视化系列小项目(19)--通体光纤灯

偶然心血来潮,想要做一个音乐可视化的系列专题。这个专题的难度有点高,涉及面也比较广泛,相关的FFT和FHT等算法也相当复杂,不 ...

请问你们平常芯片或者元件都是去哪买的?

请问你们平常芯片或者元件都是去哪买的?我发现某宝现在太病态了,价格乱七八糟,每一个标实价的,只要你拍了,基本都不发货,要 ...

System Identification Methods for (Operational) Modal Analysis Review and Com...

本帖最后由 lihuanyang 于 2022-12-19 09:49 编辑 基于模型分析预览对照的系统辨识方法;全英文原版

【大学生电子竞赛题目分析】——2023年全国赛B题《同轴电缆长度与终端负载检测装置》

没有在论坛内看到这次竞赛B题的讨论,只看到一个问的,还没人回答 其实,今年的竞赛题中,B题是工作量最小的一个。问题是必须 ...

关闭
站长推荐上一条 1/8 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

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

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

北京市海淀区中关村大街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
快速回复 返回顶部 返回列表