BL808学习日志-3-DPI-RGB屏幕使用-LVGL D0

一、DPI-RGB驱动

        BL808的手册上显示是支持RGB565屏幕显示输出的,但是一直没找到网上的使用例程。且官方的SDK显示也是能够使用的,只是缺少了驱动。这一部分驱动在SIPEED的SDK中已经内置了,今天就是简单的点亮一个800*480 RGB565的屏幕。

二、BL808支持的DPI-RGB屏幕格式

        1.从手册可以看到,BL808支持的显示范围如下表:

        Horizontal Active:屏幕横向最大显示分辨率为800,最小为176像素;

        Vertical Active:屏幕纵向最大显示分辨率为480,最小为208;

        也就是说日常的3英寸、4.3英寸、5英寸、7英寸的480*854类型是竖屏是不支持的,在这个地方我跳了坑,买了两块480*854的5英寸RGB屏幕,结果只能显示一半。因此只有横屏的高分辨率屏幕才是支持的。

        目前我使用的是这一块5英寸屏幕,横屏显示,800*480 RGB888,驱动IC为ST7265;40P管脚。

        使用0.5mm间距的FPC排线,上电不需要初始化屏参,直接输出屏幕数据就行。

(小知识点:一般竖屏的屏幕需要使用9bit的spi或者IIC来初始化屏幕主控,用来调节分辨率等各种参数,横屏的好像都是厂家默认设置好的参数,一般不需要调整,直接上电输出数据就可以)。

        2.BL808只支持RGB565格式,一般默认的屏幕都是RGB888格式的,所以我是用的这款屏幕需要将BL808所对应的数据在高地址上对齐,在物理接口连线上屏幕的R0-R2,G0-G1,B0-B2是悬空的,而信号线接法如下:

BL808GPIO序号BL808管脚定义RGB屏幕FPC定义
GPIO17DPI_DATA[0]R[3]
.........
GPIO21DPI_DATA[4]R[7]
GPIO22DPI_DATA[5]G[2]
.........
GPIO27DPI_DATA[10]G[7]
GPIO28DPI_DATA[11]B[3]
.........
GPIO32DPI_DATA[15]B[7]
GPIO33DPI_DELCD_DE
GPIO12DPI_VSLCD_VS
GPIO13DPI_HSLCD_HS
GPIO16DPI_PCLKLCD_CLK
GPIO8GPIO8LCD_RST/DISP

        其中上述GPIO8可以使用,也可以不使用,因为在不同的屏幕中对RST的要求是不太一样的。我在上面的5寸屏幕上是把FPC上的DISP管脚接到了GPIO8;用来进行复位控制。

三、M1s_Dock管脚复用

        M1s_Dock开发板的管脚是不太多的,其中在使用RGB屏幕时基本上不会剩什么管脚可以使用了。因此需要按照需求进行部分重新分配。

        按照上面的管脚需求表,开发板外接的2.54排座还剩如下管脚:GPIO6、GPIO7 、GPIO11、GPIO14、GPIO15、GPIO40、GPIO41。并且在M1s_Dock的BL702转双串口的时候,将GPIO14、GPIO15当作的E907(M0)内核的调试串口,将GPIO16、GPIO17当作C906(D0)的调试串口。现在后者被RGB屏幕占用了,因此需要将GPIO40、GPIO41这两个引脚,复用为C906的调试串口。

        在引脚复用的时候还有一个问题就是,手册中描述引脚分为2个等级,一种是AON_IO,一种是PDS_IO;如下表,其中GPIO40、GPIO41就是特殊的AON_IO,因此在复用的时候还需要额外操作。(这一点在没完全看完资料的我来说是致命的,搞了2天才搞清楚为什么C906一直没输出)。

        打开SIPEED对应的Linux下的开发SDK,对应目录为M1s_Bl808_SDK/components/sipeed/c906/m1s_start/src/start_main.c文件,这个是c906内核在freertos初始化的主函数对应文件;将第27-28行的管脚引用修改为

#define UART_TX_C906 (40)
#define UART_RX_C906 (41)

        在头文件区域增加一个头文件调用,     #include "bl808_glb.h"用来配置GPIO。   

        新增一个管脚配置函数,static void bfl_c906_uart0_tx_rx_remap_gpio_init(void),用来使GPIO11-GPIO13、GPIO40、GPIO41失能AON功能;

static void bfl_c906_uart0_tx_rx_remap_gpio_init(void)
{HBN_AON_PAD_CFG_Type aonPadCfg = {DISABLE,DISABLE,DISABLE,HBN_GPIO_PAD_PULL_NONE,};HBN_Aon_Pad_Cfg(DISABLE, HBN_AON_PAD_GPIO40, &aonPadCfg);HBN_Aon_Pad_Cfg(DISABLE, HBN_AON_PAD_GPIO41, &aonPadCfg);
}static void bfl_c906_gpio_11_to_gpio_15_remap_gpio_init(void)
{HBN_AON_PAD_CFG_Type aonPadCfg = {DISABLE,DISABLE,DISABLE,HBN_GPIO_PAD_PULL_NONE,};HBN_Aon_Pad_Cfg(DISABLE, HBN_AON_PAD_GPIO11, &aonPadCfg);HBN_Aon_Pad_Cfg(DISABLE, HBN_AON_PAD_GPIO12, &aonPadCfg);HBN_Aon_Pad_Cfg(DISABLE, HBN_AON_PAD_GPIO13, &aonPadCfg);}

        在主函数bfl_main函数开始处调用上面的bfl_c906_uart0_tx_rx_remap_gpio_init(void)函数,

void bfl_main()
{if(UART_TX_C906 == 40 && UART_RX_C906 == 41)    //当使用RGB屏幕时需要使用11-15和40 41管脚,复用为普通IO管脚{bfl_c906_uart0_tx_rx_remap_gpio_init();bfl_c906_gpio_11_to_gpio_15_remap_gpio_init();}bl_uart_c906_init(0, UART_TX_C906, UART_RX_C906, 0, 0, UART_BAUD_C906);puts("Starting bl808 now....\r\n");bl808_FreeRTOS_init();puts("[OS] Starting aos_loop_proc task...\r\n");xTaskCreate(aos_loop_proc, (char *)"event_loop", 1024, NULL, 15, NULL);puts("[OS] Stop c906 xram handle...\r\n");// m1s_c906_xram_init();puts("[OS] Starting OS Scheduler...\r\n");vTaskStartScheduler();
}

        完整的配置文件如下,因为我的C906并没有使用PWM功能,因此在主函数中注释掉了 m1s_c906_xram_init()函数,如果有使用的同学,还必须去E907的配置文件调节挺多项内容,来使用没有被RGB接口占用的GPIO管脚来操作PWM功能。


#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>/* FreeRTOS */
#include <FreeRTOS.h>
#include <task.h>
#include <timers.h>/* aos */
#include <aos/kernel.h>
#include <aos/yloop.h>
#include <cli.h>
#include <device/vfs_uart.h>
#include <event_device.h>
#include <vfs.h>/* driver */
#include <bl_uart.h>
#include <hosal_uart.h>
#include "bl808_glb.h"#include "m1s_c906_xram.h"
#define UART_ID_C906 (0)
#define UART_TX_C906 (40)
#define UART_RX_C906 (41)
#define UART_BAUD_C906 (2000000)HOSAL_UART_DEV_DECL(uart_stdio, UART_ID_C906, UART_TX_C906, UART_RX_C906, UART_BAUD_C906)static void bl808_FreeRTOS_init(void)
{extern uint8_t _heap_start_tcm;extern uint8_t _heap_size_tcm;static HeapRegion_t xHeapRegions[] = {{NULL, 0}, /* set on runtime */{NULL, 0}  /* Terminates the array */};xHeapRegions[0].pucStartAddress = (uint8_t *)&_heap_start_tcm;xHeapRegions[0].xSizeInBytes = (size_t)&_heap_size_tcm;printf("Heap Info: %ld KB @ [0x%p ~ 0x%p]\r\n", xHeapRegions[0].xSizeInBytes >> 10, xHeapRegions[0].pucStartAddress,xHeapRegions[0].pucStartAddress + xHeapRegions[0].xSizeInBytes);vPortDefineHeapRegions(xHeapRegions);
}void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
{puts("Stack Overflow checked\r\n");printf("Task Name %s\r\n", pcTaskName);while (1) {/*empty here*/}
}void vApplicationMallocFailedHook(void)
{printf("Memory Allocate Failed. Current left size is %lu bytes\r\n", xPortGetFreeHeapSize());while (1) {/*empty here*/}
}void vApplicationIdleHook(void) {}void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer,uint32_t *pulIdleTaskStackSize)
{/* If the buffers to be provided to the Idle task are declared inside thisfunction then they must be declared static - otherwise they will be allocated onthe stack and so not exists after this function exits. */static StaticTask_t xIdleTaskTCB;static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE];/* Pass out a pointer to the StaticTask_t structure in which the Idle task'sstate will be stored. */*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;/* Pass out the array that will be used as the Idle task's stack. */*ppxIdleTaskStackBuffer = uxIdleTaskStack;/* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.Note that, as the array is necessarily of type StackType_t,configMINIMAL_STACK_SIZE is specified in words, not bytes. */*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}/* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
application must provide an implementation of vApplicationGetTimerTaskMemory()
to provide the memory that is used by the Timer service task. */
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer,uint32_t *pulTimerTaskStackSize)
{/* If the buffers to be provided to the Timer task are declared inside thisfunction then they must be declared static - otherwise they will be allocated onthe stack and so not exists after this function exits. */static StaticTask_t xTimerTaskTCB;static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH];/* Pass out a pointer to the StaticTask_t structure in which the Timertask's state will be stored. */*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;/* Pass out the array that will be used as the Timer task's stack. */*ppxTimerTaskStackBuffer = uxTimerTaskStack;/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.Note that, as the array is necessarily of type StackType_t,configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}void vAssertCalled(void)
{volatile uint32_t ulSetTo1ToExitFunction = 0;taskDISABLE_INTERRUPTS();while (ulSetTo1ToExitFunction != 1) {__asm volatile("NOP");}
}static inline void main_warpper()
{extern void main(void);main();vTaskDelete(NULL);
}static void start_main(void *arg) { xTaskCreate(main_warpper, (char *)"main", 4096, NULL, 15, NULL); }static void aos_loop_proc(void *pvParameters)
{int fd_console;vfs_init();vfs_device_init();/* uart */vfs_uart_init_simple_mode(UART_ID_C906, UART_TX_C906, UART_RX_C906, UART_BAUD_C906,"/dev/ttyS0");  // UART for cliaos_loop_init();fd_console = aos_open("/dev/ttyS0", 0);if (fd_console >= 0) {printf("Init CLI with event Driven\r\n");aos_cli_init(0);aos_poll_read_fd(fd_console, aos_cli_event_cb_read_get(), (void *)0x12345678);}aos_post_delayed_action(100, start_main, NULL);aos_loop_run();puts("------------------------------------------\r\n");puts("+++++++++Critical Exit From Loop++++++++++\r\n");puts("******************************************\r\n");vTaskDelete(NULL);
}static void bfl_c906_uart0_tx_rx_remap_gpio_init(void)
{HBN_AON_PAD_CFG_Type aonPadCfg = {DISABLE,DISABLE,DISABLE,HBN_GPIO_PAD_PULL_NONE,};HBN_Aon_Pad_Cfg(DISABLE, HBN_AON_PAD_GPIO40, &aonPadCfg);HBN_Aon_Pad_Cfg(DISABLE, HBN_AON_PAD_GPIO41, &aonPadCfg);
}static void bfl_c906_gpio_11_to_gpio_15_remap_gpio_init(void)
{HBN_AON_PAD_CFG_Type aonPadCfg = {DISABLE,DISABLE,DISABLE,HBN_GPIO_PAD_PULL_NONE,};HBN_Aon_Pad_Cfg(DISABLE, HBN_AON_PAD_GPIO11, &aonPadCfg);HBN_Aon_Pad_Cfg(DISABLE, HBN_AON_PAD_GPIO12, &aonPadCfg);HBN_Aon_Pad_Cfg(DISABLE, HBN_AON_PAD_GPIO13, &aonPadCfg);}
void bfl_main()
{if(UART_TX_C906 == 40 && UART_RX_C906 == 41)    //当使用RGB屏幕时需要使用11-15和40 41管脚,复用为普通IO管脚{bfl_c906_uart0_tx_rx_remap_gpio_init();bfl_c906_gpio_11_to_gpio_15_remap_gpio_init();}bl_uart_c906_init(0, UART_TX_C906, UART_RX_C906, 0, 0, UART_BAUD_C906);puts("Starting bl808 now....\r\n");bl808_FreeRTOS_init();puts("[OS] Starting aos_loop_proc task...\r\n");xTaskCreate(aos_loop_proc, (char *)"event_loop", 1024, NULL, 15, NULL);puts("[OS] Stop c906 xram handle...\r\n");// m1s_c906_xram_init();puts("[OS] Starting OS Scheduler...\r\n");vTaskStartScheduler();
}

四、DPI驱动文件修改

        上面描述铺垫了这么多才真的到达正文,为自己丢掉的头发感到屈辱。。。。。再一次呼吁,厂家要不然就不要推出国产芯片,推出了就好好整啊,DIY玩家在没有资料和支持的时候,真的好难的。。。。

        博流官方已经做好了驱动文件,但是却没有在自己家的SDK中开放出来,真的是脑洞大,看起来支持TOB的业务才是他们的重要之处。

        1.打开SIPEED对应的Linux下的开发SDK,对应目录为M1s_Bl808_SDK/components/platform/soc/bl808/bl808_std/BSP_Common/lcd/mipi_dpistard_dpi.c文件。

        在文件开头进行管脚定义,因为一开始我使用的是需要9bit配置显示驱动芯片的竖屏480*854的屏幕,因此还保留了这部分驱动代码,如果有同学刚好使用480*480之类的方形屏幕,还可以按照需求进行修改。里面定义了GPIO11作为LCD_CS,GPIO6作为LCD_SCL,GPIO7作为LCD_SDA

#define PIN_LCD_RESET (8)
#define PIN_LCD_CS (11)
#define PIN_LCD_SCL (6)
#define PIN_LCD_SDO (7)#define LCD_CS_H GLB_GPIO_Write(PIN_LCD_CS, 1)
#define LCD_CS_L GLB_GPIO_Write(PIN_LCD_CS, 0)#define LCD_SCL_H GLB_GPIO_Write(PIN_LCD_SCL, 1)
#define LCD_SCL_L GLB_GPIO_Write(PIN_LCD_SCL, 0)#define LCD_SDO_H GLB_GPIO_Write(PIN_LCD_SDO, 1)
#define LCD_SDO_L GLB_GPIO_Write(PIN_LCD_SDO, 0)

        下面进行重头戏,也就是配置文件的讲解,这一部分加上我对RGB屏幕的不了解,耗费了一周的时间进行摸索,真是一个头两个大。

        下面进行重要的参数寄存器讲解,

        hTotalCnt:水平方向的像素总数,=Hsync+HBP+HACT+HFP-1,其中为什么需要-1,我查阅了好多MPU的设计,可能是为了对其在16进制下第一个数是0的原因,(具体我也不知道。。反正是没有文件,只是瞎猜的情况下,很难说清楚。。。。。)

        hBlankCnt:水平方向的空白像素总数,=Hsync+HBP+HFP-1,也是就是总像素数-有效像素数。    

        vTotalCnt:纵向方向的总行数,=Vsync+VBP+VACT+VFP-1,

        vBlankCnt:纵向方向的空白行数,=Vsync+VBP+VFP-1,也是就是总行数-有效行数。

        hsyncWidth:水平信号同步宽度,我的屏幕手册是4个PCLK宽度,因此设置为4-1;

        hfpWidth:水平前廊信号宽度,我的屏幕手册是8个PCLK宽度,因此设置为8-1;

        vsyncWidth:纵向方向同步信号宽度,4-1;

        vfpWidth:纵向方向前廊信号宽度,16-1;

        下面附上我的屏幕参数表

        dvp源配置结构体dvpTsrcCfg和display显示参数配置结构体displayCfg如下:

static DVP_TSRC_Cfg_Type dvpTsrcCfg = {.dataFromSensor = DISABLE,             /* Enable: pixel data is from sensor, disable: pixel data is from AXI */.sensorHsyncInverse = DISABLE,         /* Enable or disable inverse signal of sensor hsync */.sensorVsyncInverse = DISABLE,         /* Enable or disable inverse signal of sensor vsync */.yuv420Enable = DISABLE,               /* Enable or disable YUV420 mode, YUV420 data is from 2 different planar buffers when enable */.lineType = DVP_TSRC_YUV420_LINE_EVEN, /* Select UV send in Y even lines or odd lines */.swapMode = ENABLE,                    /* Enable or disable swap mode */.swapControl = DVP_TSRC_SWAP_SOFTWARE, /* Set swap index controlled by hardware or software */.dvp2axi = DVP_TSRC_DVP2AXI_0,         /* Choose dvp2axi used */
#if (STANDARD_DPI_PIXEL_FORMAT == STANDARD_DPI_PIXEL_FORMAT_RGB565).format = DVP_TSRC_PIXEL_RGB565_16TO24BIT, /* Set pixel data format */.byte0 = 0,                                /* Byte 0 selection */.byte1 = 2,                                /* Byte 1 Selection */.byte2 = 1,                                /* Byte 2 Selection */
#elif (STANDARD_DPI_PIXEL_FORMAT == STANDARD_DPI_PIXEL_FORMAT_RGB888).format = DVP_TSRC_PIXEL_RGBA8888_32TO24BIT, /* Set pixel data format */.byte0 = 0,                                  /* Byte 0 selection */.byte1 = 1,                                  /* Byte 1 Selection */.byte2 = 2,                                  /* Byte 2 Selection */
#endif.burst = DVP_TSRC_BURST_TYPE_INCR16, /* AXI burst length */.hTotalCnt = 820-1,                /* Horizontal total pixel count */.hBlankCnt = 20-1,                /* Horizontal blank stage pixel count */.vTotalCnt = 516-1,                /* Vertical total pixel count */.vBlankCnt = 36-1,                 /* Vertical blank stage pixel count */.prefetch = 0,                                                               /* Vertical prefetch start position, relativeto blank start position */.fifoThreshold = STANDARD_DPI_W,                                             /* FIFO threshold for each DVP line to start to output */.memStartY0 = 0,                                                             /* AXI2DVP start address, Y-planar in YUV420 mode, frame 0 in swap mode */.memSizeY0 = sizeof(standard_dpi_color_t) *STANDARD_DPI_W * STANDARD_DPI_H,  /* AXI2DVP memory size of memStartY0 */.memStartY1 = 0,                                                             /* AXI2DVP start address, Y-planar in YUV420 mode,  frame 1 in swap mode, don't care if not swap mode */.memStartUV0 = 0,                                                            /* AXI2DVP start address, UV-planar in YUV420 mode, frame 0 in swap mode, don't care if not YUV420 mode */.memStartUV1 = 0,                                                            /* AXI2DVP start address, UV-planar in YUV420 mode, frame 1 in swap mode, don't care if not YUV420 swap mode */
};static DSP2_MISC_Display_Cfg_Type displayCfg = {.dpiEnable = ENABLE,                               /* Enable or disable dpi function */.bt1120Enable = DISABLE,                           /* Enable or disable BT1120 function, BT1120 and BT656 should not be enabled at the same time */.inputType = DSP2_MISC_DISPLAY_TSRC_RGB_OUTPUT,     /* Select display input */.osdType = DSP2_MISC_DISPLAY_OSD_TSRCYUV422_OUTPUT, /* Select display OSD input */.hsyncWidth = 4-1,                               /* Horizontal synchronization width */.hfpWidth = 8-1 ,                      /* Horizontal front porch width */.vsyncWidth = 4-1,                               /* Vertical synchronization width */.vfpWidth = 16-1,                        /* Vertical front porch width */
};

        配置完上述屏幕,还需要对PCLK时钟的频率进行配置。BL808的默认MIPIPLL时钟是1500M,可按照需求进行分频,分频设置函数很奇怪,GLB_Set_Display_CLK(ENABLE, GLB_DISP_CLK_MIPIPLL_1500M, 29)函数默认只能配置输入为偶数的数值,在具体实现过程中或发现,舍弃了最低位。

        我的屏幕在显示60FPS的情况下,需要的时钟频率为820*516*2*60=50.7744M,因此分频系数为1500/50.77=29,


static int standard_dpi_peripheral_init(standard_dpi_color_t *screen_buffer)
{/* MIPI clock config */GLB_Config_MIPI_PLL(GLB_XTAL_40M, mipiPllCfg_1500M);GLB_Set_Display_CLK(ENABLE, GLB_DISP_CLK_MIPIPLL_1500M, 29); //0-127// GLB_Set_Display_CLK(ENABLE, GLB_DISP_CLK_MIPIPLL_1500M, 59);dvpTsrcCfg.memStartY0 = (uint32_t)(uintptr_t)screen_buffer;/* DPI config */DVP_TSRC_Set_Swap_Index(DVP_TSRC1_ID, 1);DVP_TSRC_Init(DVP_TSRC1_ID, &dvpTsrcCfg);DSP2_MISC_Display_Init(&displayCfg);// DVP_TSRC_Fake_Data_Init(DVP_TSRC1_ID, &test_fake_data);/* Set display interrupt */DSP2_MISC_Int_Mask(DSP2_MISC_INT_ALL, MASK);DSP2_MISC_SEOF_Set_Source(DSP2_MISC_INT_DISPLAY, DSP2_MISC_SEOF_DISPLAY_OUTPUT);DSP2_MISC_SEOF_Set_Edge(DSP2_MISC_INT_DISPLAY, DSP2_MISC_SEOF_VSYNC_NEGEDGE);DSP2_MISC_Int_Callback_Install(DSP2_MISC_INT_DISPLAY, &standard_dpi_frame_interrupt);DSP2_MISC_Int_Mask(DSP2_MISC_INT_DISPLAY, UNMASK);CPU_Interrupt_Enable(DISPLAY_IRQn);System_NVIC_SetPriority(DISPLAY_IRQn, 4, 1);return 0;
}

        对使用到的LCD_RST、LCD_SDA、LCD_SCL、LCD_CS管脚进行初始化,对使用到的RGB管脚好像不初始化也可以。

static void lcd_dpi_gpio_init(void)
{GLB_GPIO_Cfg_Type cfg;uint8_t gpiopins[] = {GLB_GPIO_PIN_12, GLB_GPIO_PIN_13, GLB_GPIO_PIN_16, GLB_GPIO_PIN_17, GLB_GPIO_PIN_18, GLB_GPIO_PIN_19, GLB_GPIO_PIN_20, GLB_GPIO_PIN_21,GLB_GPIO_PIN_22,GLB_GPIO_PIN_23,GLB_GPIO_PIN_24,GLB_GPIO_PIN_33, GLB_GPIO_PIN_32, GLB_GPIO_PIN_31, GLB_GPIO_PIN_30, GLB_GPIO_PIN_29,GLB_GPIO_PIN_28, GLB_GPIO_PIN_27, GLB_GPIO_PIN_26, GLB_GPIO_PIN_25};int i;cfg.gpioMode=GPIO_MODE_AF;cfg.pullType=GPIO_PULL_NONE;cfg.drive=0;cfg.smtCtrl=1;for(i=0;i<sizeof(gpiopins)/sizeof(gpiopins[0]);i++){cfg.gpioPin=gpiopins[i];cfg.gpioFun=GPIO_FUN_DPI;GLB_GPIO_Init(&cfg);}
}static void LCD_FD050FW_GPIO_init(void)
{GLB_GPIO_Cfg_Type cfg;cfg.drive = 0;cfg.smtCtrl = 1;cfg.gpioFun = GPIO_FUN_GPIO;cfg.outputMode = 0;cfg.pullType = GPIO_PULL_NONE;cfg.gpioPin = PIN_LCD_CS;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_CS, true);GLB_GPIO_Output_Enable(PIN_LCD_CS);cfg.gpioPin = PIN_LCD_RESET;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_RESET, true);GLB_GPIO_Output_Enable(PIN_LCD_RESET);cfg.gpioPin = PIN_LCD_SCL;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_SCL, true);GLB_GPIO_Output_Enable(PIN_LCD_SCL);cfg.gpioPin = PIN_LCD_SDO;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_SDO, true);GLB_GPIO_Output_Enable(PIN_LCD_SDO);
}

        下面的函数为9bit_spi主控初始化的函数,横屏的是不需要用到的,但是竖屏的可能会使用到,我也就直接贴出来。


static void write_cmd(unsigned char cmd)
{unsigned char i;LCD_CS_L;LCD_SCL_L;LCD_SDO_L;LCD_SCL_H;for(i=0;i<8;i++){LCD_SCL_L;   if(cmd & 0x80)LCD_SDO_H;elseLCD_SDO_L;LCD_SCL_H;cmd = cmd << 1;}LCD_CS_H;    
}static void write_data(unsigned char data)
{unsigned char i;LCD_CS_L;LCD_SCL_L;LCD_SDO_H;LCD_SCL_H;for(i=0;i<8;i++){LCD_SCL_L;   if(data & 0x80)LCD_SDO_H;elseLCD_SDO_L;LCD_SCL_H;data = data << 1;}LCD_CS_H;    
}
static void lcd_dpi_gpio_init(void)
{GLB_GPIO_Cfg_Type cfg;uint8_t gpiopins[] = {GLB_GPIO_PIN_12, GLB_GPIO_PIN_13, GLB_GPIO_PIN_16, GLB_GPIO_PIN_17, GLB_GPIO_PIN_18, GLB_GPIO_PIN_19, GLB_GPIO_PIN_20, GLB_GPIO_PIN_21,GLB_GPIO_PIN_22,GLB_GPIO_PIN_23,GLB_GPIO_PIN_24,GLB_GPIO_PIN_33, GLB_GPIO_PIN_32, GLB_GPIO_PIN_31, GLB_GPIO_PIN_30, GLB_GPIO_PIN_29,GLB_GPIO_PIN_28, GLB_GPIO_PIN_27, GLB_GPIO_PIN_26, GLB_GPIO_PIN_25};int i;cfg.gpioMode=GPIO_MODE_AF;cfg.pullType=GPIO_PULL_NONE;cfg.drive=0;cfg.smtCtrl=1;for(i=0;i<sizeof(gpiopins)/sizeof(gpiopins[0]);i++){cfg.gpioPin=gpiopins[i];cfg.gpioFun=GPIO_FUN_DPI;GLB_GPIO_Init(&cfg);}
}static void LCD_FD050FW_GPIO_init(void)
{GLB_GPIO_Cfg_Type cfg;cfg.drive = 0;cfg.smtCtrl = 1;cfg.gpioFun = GPIO_FUN_GPIO;cfg.outputMode = 0;cfg.pullType = GPIO_PULL_NONE;cfg.gpioPin = PIN_LCD_CS;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_CS, true);GLB_GPIO_Output_Enable(PIN_LCD_CS);cfg.gpioPin = PIN_LCD_RESET;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_RESET, true);GLB_GPIO_Output_Enable(PIN_LCD_RESET);cfg.gpioPin = PIN_LCD_SCL;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_SCL, true);GLB_GPIO_Output_Enable(PIN_LCD_SCL);cfg.gpioPin = PIN_LCD_SDO;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_SDO, true);GLB_GPIO_Output_Enable(PIN_LCD_SDO);
}static void LCD_KD050FW_init(void)
{LCD_FD050FW_GPIO_init();GLB_GPIO_Write(PIN_LCD_RESET, true);bflb_platform_delay_ms(1);GLB_GPIO_Write(PIN_LCD_RESET, false);bflb_platform_delay_ms(10);GLB_GPIO_Write(PIN_LCD_RESET, true);bflb_platform_delay_ms(200);//***************************************************************//LCD SETINGwrite_cmd(0xFF);        // Change to Page 1 CMD write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x01); write_cmd(0x08); //Output    SDA write_data(0x10);write_cmd(0x20);    //set DE/VSYNC mode    write_data(0x00);  //00:DE mode    01:SYNC mode   write_cmd(0x21); //DE = 1 Active write_data(0x01); write_cmd(0x22); //设置扫描模式,镜像,翻转write_data(0x00); // write_cmd(0x25); //vfp=22//  write_data(0x16); //  write_cmd(0x26); ////  write_data(0x18); //  write_cmd(0x27); ////  write_data(0x2F); write_cmd(0x30);//Resolution setting 480 X 800write_data(0x02); //00:480*864 01:480*854 02:480*800 write_cmd(0x31); //Inversion setting 2-dot write_data(0x00); write_cmd(0x40); //BT  AVDD,AVDDwrite_data(0x16); //   VCI*2.5 / VCI X-3write_cmd(0x41);   write_data(0x33);//22  write_cmd(0x42);        write_data(0x03); //VGL=DDVDH+VCIP -DDVDL,VGH=2DDVDL-VCIP write_cmd(0x43);       write_data(0x09); //SET VGH clamp level write_cmd(0x44);       write_data(0x06); //SET VGL clamp level write_cmd(0x50); //VREG1 write_data(0x88); write_cmd(0x51); //VREG2 write_data(0x88); write_cmd(0x52); //Flicker MSB write_data(0x00); write_cmd(0x53); //Flicker LSB write_data(0x44); //VCOMwrite_cmd(0x55); // //Flicker              write_data(0x49);write_cmd(0x60);       write_data(0x07); write_cmd(0x61);        write_data(0x00); write_cmd(0x62);      write_data(0x07); write_cmd(0x63);      write_data(0x00); //++++++++++++++++++ Gamma Setting ++++++++++++++++++//write_cmd(0xA0);  //Positive Gamma write_data(0x00); write_cmd(0xA1);        // write_data(0x09); write_cmd(0xA2);        // write_data(0x11); write_cmd(0xA3);        // write_data(0x0B); write_cmd(0xA4);        // write_data(0x05); write_cmd(0xA5);        // write_data(0x08); write_cmd(0xA6);        // write_data(0x06); write_cmd(0xA7);        // write_data(0x04); write_cmd(0xA8);        // write_data(0x09); write_cmd(0xA9);        // write_data(0x0C); write_cmd(0xAA);        // write_data(0x15); write_cmd(0xAB);        // write_data(0x08); write_cmd(0xAC);        // write_data(0x0F); write_cmd(0xAD);        // write_data(0x12); write_cmd(0xAE);        // write_data(0x09); write_cmd(0xAF);        // write_data(0x00); ///==============Nagitivewrite_cmd(0xC0);        //Negative Gamma write_data(0x00); write_cmd(0xC1);        // write_data(0x09); write_cmd(0xC2);        // write_data(0x10); write_cmd(0xC3);        // write_data(0x0C); write_cmd(0xC4);        // write_data(0x05); write_cmd(0xC5);        // write_data(0x08); write_cmd(0xC6);        // write_data(0x06); write_cmd(0xC7);        // write_data(0x04); write_cmd(0xC8);        // write_data(0x08); write_cmd(0xC9);        // write_data(0x0C); write_cmd(0xCA);        // write_data(0x14); write_cmd(0xCB);        // write_data(0x08); write_cmd(0xCC);        // write_data(0x0F); write_cmd(0xCD);        // write_data(0x11); write_cmd(0xCE);        // write_data(0x09); write_cmd(0xCF);        // write_data(0x00); write_cmd(0xFF); // Change to Page 6 CMD for GIP timing   write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x06);write_cmd(0x00);        // write_data(0x20); write_cmd(0x01);        // write_data(0x0A); write_cmd(0x02);        // write_data(0x00); write_cmd(0x03);        // write_data(0x00); write_cmd(0x04);        // write_data(0x01); write_cmd(0x05);        // write_data(0x01); write_cmd(0x06);        // write_data(0x98); write_cmd(0x07);        // write_data(0x06); write_cmd(0x08);        // write_data(0x01); write_cmd(0x09);        // write_data(0x80); write_cmd(0x0A);        // write_data(0x00); write_cmd(0x0B);        // write_data(0x00); write_cmd(0x0C);        // write_data(0x01); write_cmd(0x0D);        // write_data(0x01); write_cmd(0x0E);        // write_data(0x05); write_cmd(0x0F);        // write_data(0x00);write_cmd(0x10);        // write_data(0xF0); write_cmd(0x11);        // write_data(0xF4); write_cmd(0x12);        // write_data(0x01); write_cmd(0x13);        // write_data(0x00); write_cmd(0x14);        // write_data(0x00); write_cmd(0x15);        // write_data(0xC0); write_cmd(0x16);        // write_data(0x08); write_cmd(0x17);        // write_data(0x00); write_cmd(0x18);        // write_data(0x00); write_cmd(0x19);        // write_data(0x00); write_cmd(0x1A);        // write_data(0x00); write_cmd(0x1B);        // write_data(0x00); write_cmd(0x1C);        // write_data(0x00); write_cmd(0x1D);        // write_data(0x00);write_cmd(0x20);        // write_data(0x01); write_cmd(0x21);        // write_data(0x23); write_cmd(0x22);        // write_data(0x45); write_cmd(0x23);        // write_data(0x67); write_cmd(0x24);        // write_data(0x01); write_cmd(0x25);        // write_data(0x23); write_cmd(0x26);        // write_data(0x45); write_cmd(0x27);        // write_data(0x67);write_cmd(0x30);        // write_data(0x11); write_cmd(0x31);        // write_data(0x11); write_cmd(0x32);        // write_data(0x00); write_cmd(0x33);        // write_data(0xEE); write_cmd(0x34);        // write_data(0xFF); write_cmd(0x35);        // write_data(0xBB); write_cmd(0x36);        // write_data(0xAA); write_cmd(0x37);        // write_data(0xDD); write_cmd(0x38);        // write_data(0xCC); write_cmd(0x39);        // write_data(0x66); write_cmd(0x3A);        // write_data(0x77); write_cmd(0x3B);        // write_data(0x22); write_cmd(0x3C);        // write_data(0x22); write_cmd(0x3D);        // write_data(0x22); write_cmd(0x3E);        // write_data(0x22); write_cmd(0x3F);        // write_data(0x22); write_cmd(0x40);        // write_data(0x22);write_cmd(0xFF);// Change to Page 7 CMD for GIP timing   write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x07);write_cmd(0x17);       write_data(0x22); write_cmd(0x02);        write_data(0x77);write_cmd(0x26);        write_data(0xB2);write_cmd(0xFF); // Change to Page 0 CMD for Normal command write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x00);write_cmd(0x3A);      write_data(0x50);  //0X50 16BIT 0X60 18BIT 0X70 24BIT write_cmd(0x11);    // SLEEP OUTbflb_platform_delay_ms(120);write_cmd(0x29);   // DISPLAY ONbflb_platform_delay_ms(25);}

        在DPI初始化函数中,对上述构造的功能函数进行调用,

int standard_dpi_init(standard_dpi_color_t *screen_buffer)
{if (screen_buffer == NULL) {return -1;}lcd_dpi_gpio_init();// LCD_KD050FW_init();/* init DBI and DPI peripheral*/standard_dpi_peripheral_init(screen_buffer);/* enable DPI, Start output data*/DVP_TSRC_Enable(DVP_TSRC1_ID);return 0;
}

       上述文件中,完整的文件如下:

/*** @file standard_dpi.c* @brief** Copyright (c) 2021 Bouffalolab team** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.  The* ASF licenses this file to you under the Apache License, Version 2.0 (the* "License"); you may not use this file except in compliance with the* License.  You may obtain a copy of the License at**   http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the* License for the specific language governing permissions and limitations* under the License.**/#include "../lcd.h"#if defined(LCD_DPI_STANDARD) #include "bflb_platform.h"#include "bl808_dvp_tsrc.h"
#include "bl808_dsp2_misc.h"
#include "bl808_dbi.h"
#include "bl808_glb.h"
#include "dtsrc_reg.h"#include "standard_dpi.h"#define PIN_LCD_RESET (8)
#define PIN_LCD_CS (11)
#define PIN_LCD_SCL (6)
#define PIN_LCD_SDO (7)#define LCD_CS_H GLB_GPIO_Write(PIN_LCD_CS, 1)
#define LCD_CS_L GLB_GPIO_Write(PIN_LCD_CS, 0)#define LCD_SCL_H GLB_GPIO_Write(PIN_LCD_SCL, 1)
#define LCD_SCL_L GLB_GPIO_Write(PIN_LCD_SCL, 0)#define LCD_SDO_H GLB_GPIO_Write(PIN_LCD_SDO, 1)
#define LCD_SDO_L GLB_GPIO_Write(PIN_LCD_SDO, 0)/* Video memory used for this frame, Update in frame interrupt*/
static volatile standard_dpi_color_t *screen_last = NULL;
typedef void (*standard_dpi_callback)(void);
static volatile standard_dpi_callback standard_dpi_frame_callback = NULL;
static volatile standard_dpi_callback standard_dpi_frame_swap_callback = NULL;static DVP_TSRC_Fake_Data_Cfg_Type test_fake_data={.minData = 0x0000,.maxData = 0xffff,.step = 0x10,
};static DVP_TSRC_Cfg_Type dvpTsrcCfg = {.dataFromSensor = DISABLE,             /* Enable: pixel data is from sensor, disable: pixel data is from AXI */.sensorHsyncInverse = DISABLE,         /* Enable or disable inverse signal of sensor hsync */.sensorVsyncInverse = DISABLE,         /* Enable or disable inverse signal of sensor vsync */.yuv420Enable = DISABLE,               /* Enable or disable YUV420 mode, YUV420 data is from 2 different planar buffers when enable */.lineType = DVP_TSRC_YUV420_LINE_EVEN, /* Select UV send in Y even lines or odd lines */.swapMode = ENABLE,                    /* Enable or disable swap mode */.swapControl = DVP_TSRC_SWAP_SOFTWARE, /* Set swap index controlled by hardware or software */.dvp2axi = DVP_TSRC_DVP2AXI_0,         /* Choose dvp2axi used */
#if (STANDARD_DPI_PIXEL_FORMAT == STANDARD_DPI_PIXEL_FORMAT_RGB565).format = DVP_TSRC_PIXEL_RGB565_16TO24BIT, /* Set pixel data format */.byte0 = 0,                                /* Byte 0 selection */.byte1 = 2,                                /* Byte 1 Selection */.byte2 = 1,                                /* Byte 2 Selection */
#elif (STANDARD_DPI_PIXEL_FORMAT == STANDARD_DPI_PIXEL_FORMAT_RGB888).format = DVP_TSRC_PIXEL_RGBA8888_32TO24BIT, /* Set pixel data format */.byte0 = 0,                                  /* Byte 0 selection */.byte1 = 1,                                  /* Byte 1 Selection */.byte2 = 2,                                  /* Byte 2 Selection */
#endif.burst = DVP_TSRC_BURST_TYPE_INCR16, /* AXI burst length */.hTotalCnt = 820-1,                /* Horizontal total pixel count */.hBlankCnt = 20-1,                /* Horizontal blank stage pixel count */.vTotalCnt = 516-1,                /* Vertical total pixel count */.vBlankCnt = 36-1,                 /* Vertical blank stage pixel count */.prefetch = 0,                                                               /* Vertical prefetch start position, relativeto blank start position */.fifoThreshold = STANDARD_DPI_W,                                             /* FIFO threshold for each DVP line to start to output */.memStartY0 = 0,                                                             /* AXI2DVP start address, Y-planar in YUV420 mode, frame 0 in swap mode */.memSizeY0 = sizeof(standard_dpi_color_t) *STANDARD_DPI_W * STANDARD_DPI_H,  /* AXI2DVP memory size of memStartY0 */.memStartY1 = 0,                                                             /* AXI2DVP start address, Y-planar in YUV420 mode,  frame 1 in swap mode, don't care if not swap mode */.memStartUV0 = 0,                                                            /* AXI2DVP start address, UV-planar in YUV420 mode, frame 0 in swap mode, don't care if not YUV420 mode */.memStartUV1 = 0,                                                            /* AXI2DVP start address, UV-planar in YUV420 mode, frame 1 in swap mode, don't care if not YUV420 swap mode */
};static DSP2_MISC_Display_Cfg_Type displayCfg = {.dpiEnable = ENABLE,                               /* Enable or disable dpi function */.bt1120Enable = DISABLE,                           /* Enable or disable BT1120 function, BT1120 and BT656 should not be enabled at the same time */.inputType = DSP2_MISC_DISPLAY_TSRC_RGB_OUTPUT,     /* Select display input */.osdType = DSP2_MISC_DISPLAY_OSD_TSRCYUV422_OUTPUT, /* Select display OSD input */.hsyncWidth = 4-1,                               /* Horizontal synchronization width */.hfpWidth = 8-1 ,                      /* Horizontal front porch width */.vsyncWidth = 4-1,                               /* Vertical synchronization width */.vfpWidth = 16-1,                        /* Vertical front porch width */
};void standard_dpi_frame_interrupt(void)
{uint8_t swap_flag = 0;DSP2_MISC_Int_Clear_1(DSP2_MISC_INT_DISPLAY);standard_dpi_color_t *screen_next = (standard_dpi_color_t *)(uintptr_t)BL_RD_REG(DVP_TSRC1_BASE, DTSRC_AXI2DVP_START_ADDR_BY);if (screen_last != screen_next) {swap_flag = 1;screen_last = screen_next;}if (standard_dpi_frame_callback != NULL) {standard_dpi_frame_callback();}if (standard_dpi_frame_swap_callback != 0 && swap_flag) {standard_dpi_frame_swap_callback();}
}static int standard_dpi_peripheral_init(standard_dpi_color_t *screen_buffer)
{/* MIPI clock config */GLB_Config_MIPI_PLL(GLB_XTAL_40M, mipiPllCfg_1500M);GLB_Set_Display_CLK(ENABLE, GLB_DISP_CLK_MIPIPLL_1500M, 29); //0-127// GLB_Set_Display_CLK(ENABLE, GLB_DISP_CLK_MIPIPLL_1500M, 59);dvpTsrcCfg.memStartY0 = (uint32_t)(uintptr_t)screen_buffer;/* DPI config */DVP_TSRC_Set_Swap_Index(DVP_TSRC1_ID, 1);DVP_TSRC_Init(DVP_TSRC1_ID, &dvpTsrcCfg);DSP2_MISC_Display_Init(&displayCfg);// DVP_TSRC_Fake_Data_Init(DVP_TSRC1_ID, &test_fake_data);/* Set display interrupt */DSP2_MISC_Int_Mask(DSP2_MISC_INT_ALL, MASK);DSP2_MISC_SEOF_Set_Source(DSP2_MISC_INT_DISPLAY, DSP2_MISC_SEOF_DISPLAY_OUTPUT);DSP2_MISC_SEOF_Set_Edge(DSP2_MISC_INT_DISPLAY, DSP2_MISC_SEOF_VSYNC_NEGEDGE);DSP2_MISC_Int_Callback_Install(DSP2_MISC_INT_DISPLAY, &standard_dpi_frame_interrupt);DSP2_MISC_Int_Mask(DSP2_MISC_INT_DISPLAY, UNMASK);CPU_Interrupt_Enable(DISPLAY_IRQn);System_NVIC_SetPriority(DISPLAY_IRQn, 4, 1);return 0;
}static void write_cmd(unsigned char cmd)
{unsigned char i;LCD_CS_L;LCD_SCL_L;LCD_SDO_L;LCD_SCL_H;for(i=0;i<8;i++){LCD_SCL_L;   if(cmd & 0x80)LCD_SDO_H;elseLCD_SDO_L;LCD_SCL_H;cmd = cmd << 1;}LCD_CS_H;    
}static void write_data(unsigned char data)
{unsigned char i;LCD_CS_L;LCD_SCL_L;LCD_SDO_H;LCD_SCL_H;for(i=0;i<8;i++){LCD_SCL_L;   if(data & 0x80)LCD_SDO_H;elseLCD_SDO_L;LCD_SCL_H;data = data << 1;}LCD_CS_H;    
}
static void lcd_dpi_gpio_init(void)
{GLB_GPIO_Cfg_Type cfg;uint8_t gpiopins[] = {GLB_GPIO_PIN_12, GLB_GPIO_PIN_13, GLB_GPIO_PIN_16, GLB_GPIO_PIN_17, GLB_GPIO_PIN_18, GLB_GPIO_PIN_19, GLB_GPIO_PIN_20, GLB_GPIO_PIN_21,GLB_GPIO_PIN_22,GLB_GPIO_PIN_23,GLB_GPIO_PIN_24,GLB_GPIO_PIN_33, GLB_GPIO_PIN_32, GLB_GPIO_PIN_31, GLB_GPIO_PIN_30, GLB_GPIO_PIN_29,GLB_GPIO_PIN_28, GLB_GPIO_PIN_27, GLB_GPIO_PIN_26, GLB_GPIO_PIN_25};int i;cfg.gpioMode=GPIO_MODE_AF;cfg.pullType=GPIO_PULL_NONE;cfg.drive=0;cfg.smtCtrl=1;for(i=0;i<sizeof(gpiopins)/sizeof(gpiopins[0]);i++){cfg.gpioPin=gpiopins[i];cfg.gpioFun=GPIO_FUN_DPI;GLB_GPIO_Init(&cfg);}
}static void LCD_FD050FW_GPIO_init(void)
{GLB_GPIO_Cfg_Type cfg;cfg.drive = 0;cfg.smtCtrl = 1;cfg.gpioFun = GPIO_FUN_GPIO;cfg.outputMode = 0;cfg.pullType = GPIO_PULL_NONE;cfg.gpioPin = PIN_LCD_CS;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_CS, true);GLB_GPIO_Output_Enable(PIN_LCD_CS);cfg.gpioPin = PIN_LCD_RESET;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_RESET, true);GLB_GPIO_Output_Enable(PIN_LCD_RESET);cfg.gpioPin = PIN_LCD_SCL;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_SCL, true);GLB_GPIO_Output_Enable(PIN_LCD_SCL);cfg.gpioPin = PIN_LCD_SDO;cfg.gpioMode = GPIO_MODE_OUTPUT;GLB_GPIO_Init(&cfg);GLB_GPIO_Write(PIN_LCD_SDO, true);GLB_GPIO_Output_Enable(PIN_LCD_SDO);
}static void LCD_KD050FW_init(void)
{LCD_FD050FW_GPIO_init();GLB_GPIO_Write(PIN_LCD_RESET, true);bflb_platform_delay_ms(1);GLB_GPIO_Write(PIN_LCD_RESET, false);bflb_platform_delay_ms(10);GLB_GPIO_Write(PIN_LCD_RESET, true);bflb_platform_delay_ms(200);//***************************************************************//LCD SETINGwrite_cmd(0xFF);        // Change to Page 1 CMD write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x01); write_cmd(0x08); //Output    SDA write_data(0x10);write_cmd(0x20);    //set DE/VSYNC mode    write_data(0x00);  //00:DE mode    01:SYNC mode   write_cmd(0x21); //DE = 1 Active write_data(0x01); write_cmd(0x22); //设置扫描模式,镜像,翻转write_data(0x00); // write_cmd(0x25); //vfp=22//  write_data(0x16); //  write_cmd(0x26); ////  write_data(0x18); //  write_cmd(0x27); ////  write_data(0x2F); write_cmd(0x30);//Resolution setting 480 X 800write_data(0x02); //00:480*864 01:480*854 02:480*800 write_cmd(0x31); //Inversion setting 2-dot write_data(0x00); write_cmd(0x40); //BT  AVDD,AVDDwrite_data(0x16); //   VCI*2.5 / VCI X-3write_cmd(0x41);   write_data(0x33);//22  write_cmd(0x42);        write_data(0x03); //VGL=DDVDH+VCIP -DDVDL,VGH=2DDVDL-VCIP write_cmd(0x43);       write_data(0x09); //SET VGH clamp level write_cmd(0x44);       write_data(0x06); //SET VGL clamp level write_cmd(0x50); //VREG1 write_data(0x88); write_cmd(0x51); //VREG2 write_data(0x88); write_cmd(0x52); //Flicker MSB write_data(0x00); write_cmd(0x53); //Flicker LSB write_data(0x44); //VCOMwrite_cmd(0x55); // //Flicker              write_data(0x49);write_cmd(0x60);       write_data(0x07); write_cmd(0x61);        write_data(0x00); write_cmd(0x62);      write_data(0x07); write_cmd(0x63);      write_data(0x00); //++++++++++++++++++ Gamma Setting ++++++++++++++++++//write_cmd(0xA0);  //Positive Gamma write_data(0x00); write_cmd(0xA1);        // write_data(0x09); write_cmd(0xA2);        // write_data(0x11); write_cmd(0xA3);        // write_data(0x0B); write_cmd(0xA4);        // write_data(0x05); write_cmd(0xA5);        // write_data(0x08); write_cmd(0xA6);        // write_data(0x06); write_cmd(0xA7);        // write_data(0x04); write_cmd(0xA8);        // write_data(0x09); write_cmd(0xA9);        // write_data(0x0C); write_cmd(0xAA);        // write_data(0x15); write_cmd(0xAB);        // write_data(0x08); write_cmd(0xAC);        // write_data(0x0F); write_cmd(0xAD);        // write_data(0x12); write_cmd(0xAE);        // write_data(0x09); write_cmd(0xAF);        // write_data(0x00); ///==============Nagitivewrite_cmd(0xC0);        //Negative Gamma write_data(0x00); write_cmd(0xC1);        // write_data(0x09); write_cmd(0xC2);        // write_data(0x10); write_cmd(0xC3);        // write_data(0x0C); write_cmd(0xC4);        // write_data(0x05); write_cmd(0xC5);        // write_data(0x08); write_cmd(0xC6);        // write_data(0x06); write_cmd(0xC7);        // write_data(0x04); write_cmd(0xC8);        // write_data(0x08); write_cmd(0xC9);        // write_data(0x0C); write_cmd(0xCA);        // write_data(0x14); write_cmd(0xCB);        // write_data(0x08); write_cmd(0xCC);        // write_data(0x0F); write_cmd(0xCD);        // write_data(0x11); write_cmd(0xCE);        // write_data(0x09); write_cmd(0xCF);        // write_data(0x00); write_cmd(0xFF); // Change to Page 6 CMD for GIP timing   write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x06);write_cmd(0x00);        // write_data(0x20); write_cmd(0x01);        // write_data(0x0A); write_cmd(0x02);        // write_data(0x00); write_cmd(0x03);        // write_data(0x00); write_cmd(0x04);        // write_data(0x01); write_cmd(0x05);        // write_data(0x01); write_cmd(0x06);        // write_data(0x98); write_cmd(0x07);        // write_data(0x06); write_cmd(0x08);        // write_data(0x01); write_cmd(0x09);        // write_data(0x80); write_cmd(0x0A);        // write_data(0x00); write_cmd(0x0B);        // write_data(0x00); write_cmd(0x0C);        // write_data(0x01); write_cmd(0x0D);        // write_data(0x01); write_cmd(0x0E);        // write_data(0x05); write_cmd(0x0F);        // write_data(0x00);write_cmd(0x10);        // write_data(0xF0); write_cmd(0x11);        // write_data(0xF4); write_cmd(0x12);        // write_data(0x01); write_cmd(0x13);        // write_data(0x00); write_cmd(0x14);        // write_data(0x00); write_cmd(0x15);        // write_data(0xC0); write_cmd(0x16);        // write_data(0x08); write_cmd(0x17);        // write_data(0x00); write_cmd(0x18);        // write_data(0x00); write_cmd(0x19);        // write_data(0x00); write_cmd(0x1A);        // write_data(0x00); write_cmd(0x1B);        // write_data(0x00); write_cmd(0x1C);        // write_data(0x00); write_cmd(0x1D);        // write_data(0x00);write_cmd(0x20);        // write_data(0x01); write_cmd(0x21);        // write_data(0x23); write_cmd(0x22);        // write_data(0x45); write_cmd(0x23);        // write_data(0x67); write_cmd(0x24);        // write_data(0x01); write_cmd(0x25);        // write_data(0x23); write_cmd(0x26);        // write_data(0x45); write_cmd(0x27);        // write_data(0x67);write_cmd(0x30);        // write_data(0x11); write_cmd(0x31);        // write_data(0x11); write_cmd(0x32);        // write_data(0x00); write_cmd(0x33);        // write_data(0xEE); write_cmd(0x34);        // write_data(0xFF); write_cmd(0x35);        // write_data(0xBB); write_cmd(0x36);        // write_data(0xAA); write_cmd(0x37);        // write_data(0xDD); write_cmd(0x38);        // write_data(0xCC); write_cmd(0x39);        // write_data(0x66); write_cmd(0x3A);        // write_data(0x77); write_cmd(0x3B);        // write_data(0x22); write_cmd(0x3C);        // write_data(0x22); write_cmd(0x3D);        // write_data(0x22); write_cmd(0x3E);        // write_data(0x22); write_cmd(0x3F);        // write_data(0x22); write_cmd(0x40);        // write_data(0x22);write_cmd(0xFF);// Change to Page 7 CMD for GIP timing   write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x07);write_cmd(0x17);       write_data(0x22); write_cmd(0x02);        write_data(0x77);write_cmd(0x26);        write_data(0xB2);write_cmd(0xFF); // Change to Page 0 CMD for Normal command write_data(0xFF); write_data(0x98); write_data(0x06); write_data(0x04); write_data(0x00);write_cmd(0x3A);      write_data(0x50);  //0X50 16BIT 0X60 18BIT 0X70 24BIT write_cmd(0x11);    // SLEEP OUTbflb_platform_delay_ms(120);write_cmd(0x29);   // DISPLAY ONbflb_platform_delay_ms(25);}int standard_dpi_init(standard_dpi_color_t *screen_buffer)
{if (screen_buffer == NULL) {return -1;}lcd_dpi_gpio_init();// LCD_KD050FW_init();/* init DBI and DPI peripheral*/standard_dpi_peripheral_init(screen_buffer);/* enable DPI, Start output data*/DVP_TSRC_Enable(DVP_TSRC1_ID);return 0;
}int standard_dpi_screen_switch(standard_dpi_color_t *screen_buffer)
{if (screen_buffer == NULL) {return -1;}csi_dcache_clean_range((void *)screen_buffer, (sizeof(standard_dpi_color_t) * STANDARD_DPI_W * STANDARD_DPI_H));BL_WR_REG(DVP_TSRC1_BASE, DTSRC_AXI2DVP_START_ADDR_BY, (uint32_t)(uintptr_t)screen_buffer);return 0;
}standard_dpi_color_t *standard_dpi_get_screen_using(void)
{return (standard_dpi_color_t *)screen_last;
}int standard_dpi_frame_callback_register(uint32_t callback_type, void (*callback)(void))
{if (callback_type == FRAME_INT_TYPE_SWAP) {standard_dpi_frame_swap_callback = callback;} else if (callback_type == FRAME_INT_TYPE_CYCLE) {standard_dpi_frame_callback = callback;}return 0;
}#elif defined(LCD_DPI_STANDARD)
#error "Devices that do not support DPI! Replace the driver port (lcd.h)"
#endif

         2.M1s_Bl808_SDK/components/platform/soc/bl808/bl808_std/BSP_Common/lcd/mipi_dpistard_dpi.h文件,需要对一部分参数进行配置

        主要是对水平宽度和垂直宽度进行设置分别是对应我的屏幕800 480

/*** @file standard_dpi.h* @brief** Copyright (c) 2021 Bouffalolab team** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.  The* ASF licenses this file to you under the Apache License, Version 2.0 (the* "License"); you may not use this file except in compliance with the* License.  You may obtain a copy of the License at**   http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the* License for the specific language governing permissions and limitations* under the License.**/#ifndef _STANDARD_DBI_H_
#define _STANDARD_DBI_H_#include "bflb_platform.h"/* Optional pixel data format type */
#define STANDARD_DPI_PIXEL_FORMAT_RGB888 888
#define STANDARD_DPI_PIXEL_FORMAT_RGB565 565/* Select pixel format */
#define STANDARD_DPI_PIXEL_FORMAT STANDARD_DPI_PIXEL_FORMAT_RGB565/* STANDARD LCD width */
#define STANDARD_DPI_W 800
/* STANDARD LCD height */
#define STANDARD_DPI_H 480#if (STANDARD_DPI_PIXEL_FORMAT == STANDARD_DPI_PIXEL_FORMAT_RGB565)
#define STANDARD_DPI_COLOR_DEPTH 16
typedef uint16_t standard_dpi_color_t;
#elif (STANDARD_DPI_PIXEL_FORMAT == STANDARD_DPI_PIXEL_FORMAT_RGB888)
#define STANDARD_DPI_COLOR_DEPTH 32
typedef uint32_t standard_dpi_color_t;
#endifint standard_dpi_init(standard_dpi_color_t *screen_buffer);
int standard_dpi_screen_switch(standard_dpi_color_t *screen_buffer);
standard_dpi_color_t *standard_dpi_get_screen_using(void);
int standard_dpi_frame_callback_register(uint32_t callback_type, void (*callback)(void));#endif

        3.M1s_Bl808_SDK/components/platform/soc/bl808/bl808_std/BSP_Common/lcd/lcd.h文件,这个文件是用来配置调用使用哪种屏幕的配置文件,主要是修改使用刚才配置的LCD_DPI_STANDARD驱动。需要注释掉原来的配置文件。

/*** @file lcd.h* @brief** Copyright (c) 2021 Bouffalolab team** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.  The* ASF licenses this file to you under the Apache License, Version 2.0 (the* "License"); you may not use this file except in compliance with the* License.  You may obtain a copy of the License at**   http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the* License for the specific language governing permissions and limitations* under the License.**/#ifndef _LCD_H_
#define _LCD_H_#include "font.h"/* Select screen Type */
/* 选择使用的接口与屏幕 */
// #define LCD_DBI_ILI9488
// #define LCD_DISP_QSPI_GC9C01
// #define LCD_DPI_ILI9488#define LCD_DPI_STANDARD
// #define LCD_DSI_VIDIO_ILI9881C
// #define LCD_SPI_ILI9488
// #define LCD_SPI_ILI9341
// #define LCD_SPI_ST7796
//#define LCD_SPI_ST7789V
// #define  LCD_DBI_ST7796V#define LCD_INTERFACE_SPI       1
#define LCD_INTERFACE_DBI       2
#define LCD_INTERFACE_DPI       3
#define LCD_INTERFACE_DSI_VIDIO 4#if defined LCD_DBI_ST7796V
#include "mipi_dbi/st7796v_dbi.h"#define LCD_INTERFACE_TYPE           LCD_INTERFACE_DBI
#define LCD_W                        st7796v_DBI_W
#define LCD_H                        st7796v_DBI_H
#define LCD_COLOR_DEPTH              st7796v_DBI_COLOR_DEPTH
#define LCD_COLOR_16_SWAP            (0)
#define _LCD_FUNC_DEFINE(_func, ...) st7796v_dbi_##_func(__VA_ARGS__)#elif defined LCD_DBI_ILI9488#include "mipi_dbi/ili9488_dbi.h"
#define LCD_INTERFACE_TYPE           LCD_INTERFACE_DBI
#define LCD_W                        ILI9488_DBI_W
#define LCD_H                        ILI9488_DBI_H
#define LCD_COLOR_DEPTH              ILI9488_DBI_COLOR_DEPTH
#define LCD_COLOR_16_SWAP            (0)
#define _LCD_FUNC_DEFINE(_func, ...) ili9488_dbi_##_func(__VA_ARGS__)#elif defined LCD_DISP_QSPI_GC9C01#include "disp_qspi/gc9c01_disp_qspi.h"
#define LCD_INTERFACE_TYPE           LCD_INTERFACE_DBI
#define LCD_W                        GC9C01_DISP_QSPI_W
#define LCD_H                        GC9C01_DISP_QSPI_H
#define LCD_COLOR_DEPTH              GC9C01_DISP_QSPI_COLOR_DEPTH
#define LCD_COLOR_16_SWAP            (0)
#define _LCD_FUNC_DEFINE(_func, ...) gc9c01_disp_qspi_##_func(__VA_ARGS__)#elif defined LCD_DPI_ILI9488#include "mipi_dpi/ili9488_dpi.h"
#define LCD_INTERFACE_TYPE           LCD_INTERFACE_DPI
#define LCD_W                        ILI9488_DPI_W
#define LCD_H                        ILI9488_DPI_H
#define LCD_COLOR_DEPTH              ILI9488_DPI_COLOR_DEPTH
#define LCD_COLOR_16_SWAP            (0)
#define _LCD_FUNC_DEFINE(_func, ...) ili9488_dpi_##_func(__VA_ARGS__)#elif defined LCD_DPI_STANDARD#include "mipi_dpi/standard_dpi.h"
#define LCD_INTERFACE_TYPE           LCD_INTERFACE_DPI
#define LCD_W                        STANDARD_DPI_W
#define LCD_H                        STANDARD_DPI_H
#define LCD_COLOR_DEPTH              STANDARD_DPI_COLOR_DEPTH
#define LCD_COLOR_16_SWAP            (0)
#define _LCD_FUNC_DEFINE(_func, ...) standard_dpi_##_func(__VA_ARGS__)#elif defined LCD_DSI_VIDIO_ILI9881C#include "mipi_dsi/ili9881c_dsi_vidio.h"
#define LCD_INTERFACE_TYPE           LCD_INTERFACE_DSI_VIDIO
#define LCD_W                        ILI9881C_DSI_VIDIO_W
#define LCD_H                        ILI9881C_DSI_VIDIO_H
#define LCD_COLOR_DEPTH              ILI9881C_DSI_VIDIO_COLOR_DEPTH
#define LCD_COLOR_16_SWAP            (0)
#define _LCD_FUNC_DEFINE(_func, ...) ili9881c_dsi_vidio_##_func(__VA_ARGS__)#elif defined LCD_SPI_ILI9488#include "spi/ili9488_spi.h"
#define LCD_INTERFACE_TYPE           LCD_INTERFACE_SPI
#define LCD_W                        ILI9488_SPI_W
#define LCD_H                        ILI9488_SPI_H
#define LCD_COLOR_DEPTH              ILI9488_SPI_COLOR_DEPTH
#define LCD_COLOR_16_SWAP            (0)
#define _LCD_FUNC_DEFINE(_func, ...) ili9488_spi_##_func(__VA_ARGS__)#elif defined LCD_SPI_ILI9341#include "spi/ili9341_spi.h"
#define LCD_INTERFACE_TYPE           LCD_INTERFACE_SPI
#define LCD_W                        ILI9341_SPI_W
#define LCD_H                        ILI9341_SPI_H
#define LCD_COLOR_DEPTH              ILI9341_SPI_COLOR_DEPTH
#define LCD_COLOR_16_SWAP            (0)
#define _LCD_FUNC_DEFINE(_func, ...) ili9341_spi_##_func(__VA_ARGS__)#elif defined LCD_SPI_ST7796#include "spi/st7796_spi.h"
#define LCD_INTERFACE_TYPE           LCD_INTERFACE_SPI
#define LCD_W                        ST7796_SPI_W
#define LCD_H                        ST7796_SPI_H
#define LCD_COLOR_DEPTH              ST7796_SPI_COLOR_DEPTH
#define LCD_COLOR_16_SWAP            (0)
#define _LCD_FUNC_DEFINE(_func, ...) st7796_spi_##_func(__VA_ARGS__)#elif defined LCD_SPI_ST7789V
#include "spi/st7789v_spi.h"
#define LCD_INTERFACE_TYPE           LCD_INTERFACE_SPI
#define LCD_W                        ST7789V_SPI_W
#define LCD_H                        ST7789V_SPI_H
#define LCD_COLOR_DEPTH              ST7789V_SPI_COLOR_DEPTH
#define LCD_COLOR_16_SWAP            (1)
#define _LCD_FUNC_DEFINE(_func, ...) st7789v_spi_##_func(__VA_ARGS__)#endif#define LCD_COLOR_RGB888(r, g, b) (((r << 16) | (g << 8) | (b)) & 0xffffff)
#define LCD_COLOR_RGB565(r, g, b) (((r >> 3) << 11 | (g >> 2) << 5 | (b >> 3)) & 0xffff)#if (LCD_COLOR_DEPTH == 16)
typedef uint16_t lcd_color_t;
#define LCD_COLOR_RGB(r, g, b) LCD_COLOR_RGB565(r, g, b)
#elif (LCD_COLOR_DEPTH == 32)
typedef uint32_t lcd_color_t;
#define LCD_COLOR_RGB(r, g, b) LCD_COLOR_RGB888(r, g, b)
#endif#define ABS(x) ((x) > 0 ? (x) : -(x))/* MCU LCD Common interface */
#if (LCD_INTERFACE_TYPE == LCD_INTERFACE_DBI) || (LCD_INTERFACE_TYPE == LCD_INTERFACE_SPI)extern struct device *lcd_dev_ifs;
extern struct device *lcd_dev_ifs_dma;
extern uint16_t lcd_max_x, lcd_max_y;int lcd_init(void);
int lcd_async_callback_register(void (*callback)(void));
int lcd_set_dir(uint8_t dir, uint8_t mir_flag);
int lcd_draw_point(uint16_t x, uint16_t y, lcd_color_t color);
int lcd_draw_area(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color);
int lcd_clear(lcd_color_t color);
int lcd_draw_picture_blocking(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t *picture);
int lcd_draw_picture_nonblocking(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t *picture);
int lcd_draw_is_busy(void);
int lcd_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color);
int lcd_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color);
int lcd_draw_circle(uint16_t x, uint16_t y, uint16_t r, lcd_color_t color);
#if FONT_ASCII_16X8
int lcd_draw_str_ascii16(uint16_t x, uint16_t y, lcd_color_t color, lcd_color_t bk_color, uint8_t *str, uint8_t num);
#endif/* RGB LCD Common interface */
#elif (LCD_INTERFACE_TYPE == LCD_INTERFACE_DPI) || (LCD_INTERFACE_TYPE == LCD_INTERFACE_DSI_VIDIO)/* frame int callback and frame swap int callback */
#define FRAME_INT_TYPE_CYCLE 0
#define FRAME_INT_TYPE_SWAP  1int lcd_init(lcd_color_t *screen_buffer);
int lcd_screen_switch(lcd_color_t *screen_buffer);
lcd_color_t *lcd_get_screen_using(void);
int lcd_frame_callback_register(uint32_t callback_type, void (*callback)(void));int lcd_clear(lcd_color_t *screen_buffer, lcd_color_t color);
int lcd_draw_point(lcd_color_t *screen_buffer, uint16_t x, uint16_t y, lcd_color_t color);
int lcd_draw_area(lcd_color_t *screen_buffer, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color);
int lcd_draw_picture(lcd_color_t *screen_buffer, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t *picture);
int lcd_draw_line(lcd_color_t *screen_buffer, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color);
int lcd_draw_rectangle(lcd_color_t *screen_buffer, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, lcd_color_t color);
int lcd_draw_circle(lcd_color_t *screen_buffer, uint16_t x, uint16_t y, uint16_t r, lcd_color_t color);
#if FONT_ASCII_16X8
int lcd_draw_str_ascii16(lcd_color_t *screen_buffer, uint16_t x, uint16_t y, lcd_color_t color, lcd_color_t bk_color, uint8_t *str, uint8_t num);
#endif#endif#endif

       4.M1s_Bl808_SDK/components/lvgl/lvgl/lvgl_conf.h文件,这个文件是用来配置lvgl在运行的时候的一些功能的,包括日志功能,和本次文件所采用的LVGL_BENCHMARK测试。

        需要修改的地方为第98行,对当前的屏幕PPI进行计算,我使用的屏幕是5英寸,800*480像素,因此PPI为 根号下(800*800+480*480) / 5=189,你可以计算你自己所需的屏幕PPI,方便显示的更加美观和清晰。其实这个参数也可以不修改。

        需要修改第757行,打开benchmark功能。#define LV_USE_DEMO_BENCHMARK 1

/*** @file lv_conf.h* Configuration file for v8.2.0*//** Copy this file as `lv_conf.h`* 1. simply next to the `lvgl` folder* 2. or any other places and*    - define `LV_CONF_INCLUDE_SIMPLE`*    - add the path as include path*//* clang-format off */
#if 1 /*Set it to "1" to enable content*/#ifndef LV_CONF_H
#define LV_CONF_H#include <stdint.h>#include "lcd.h"/*====================COLOR SETTINGS*====================*//*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
#define LV_COLOR_DEPTH LCD_COLOR_DEPTH/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/
#define LV_COLOR_16_SWAP LCD_COLOR_16_SWAP/*Enable features to draw on transparent background.*It's required if opa, and transform_* style properties are used.*Can be also used if the UI is above another layer, e.g. an OSD menu or video player.*/
#define LV_COLOR_SCREEN_TRANSP 1/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
#define LV_COLOR_MIX_ROUND_OFS 0/*Images pixels with this color will not be drawn if they are chroma keyed)*/
#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00)         /*pure green*//*=========================MEMORY SETTINGS*=========================*//*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
#define LV_MEM_CUSTOM 1
#if LV_MEM_CUSTOM == 0/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/#define LV_MEM_SIZE (48U * 1024U)          /*[bytes]*//*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/#define LV_MEM_ADR 0    /*0: unused*//*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/#if LV_MEM_ADR == 0#undef LV_MEM_POOL_INCLUDE#undef LV_MEM_POOL_ALLOC#endif#else       /*LV_MEM_CUSTOM*/#define LV_MEM_CUSTOM_INCLUDE <stdlib.h>   /*Header for the dynamic memory function*/#define LV_MEM_CUSTOM_ALLOC   malloc#define LV_MEM_CUSTOM_FREE    free#define LV_MEM_CUSTOM_REALLOC realloc
#endif     /*LV_MEM_CUSTOM*//*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms.*You will see an error log message if there wasn't enough buffers. */
#define LV_MEM_BUF_MAX_NUM 16/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/
#define LV_MEMCPY_MEMSET_STD 0/*====================HAL SETTINGS*====================*//*Default display refresh period. LVG will redraw changed areas with this period time*/
#define LV_DISP_DEF_REFR_PERIOD 20      /*[ms]*//*Input device read period in milliseconds*/
#define LV_INDEV_DEF_READ_PERIOD 20     /*[ms]*//*Use a custom tick source that tells the elapsed time in milliseconds.*It removes the need to manually update the tick with `lv_tick_inc()`)*/
#define LV_TICK_CUSTOM 1
#if LV_TICK_CUSTOM#define LV_TICK_CUSTOM_INCLUDE "lv_port_tick.h"         /*Header for the system time function*/#define LV_TICK_CUSTOM_SYS_TIME_EXPR custom_tick_get()    /*Expression evaluating to current system time in ms*/
#endif   /*LV_TICK_CUSTOM*//*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.*(Not so important, you can adjust it to modify default sizes and spaces)*/
#define LV_DPI_DEF 186     /*[px/inch]*//*=======================* FEATURE CONFIGURATION*=======================*//*-------------* Drawing*-----------*//*Enable complex draw engine.*Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/
#define LV_DRAW_COMPLEX 1
#if LV_DRAW_COMPLEX != 0/*Allow buffering some shadow calculation.*LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius`*Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/#define LV_SHADOW_CACHE_SIZE 0/* Set number of maximally cached circle data.* The circumference of 1/4 circle are saved for anti-aliasing* radius * 4 bytes are used per circle (the most often used radiuses are saved)* 0: to disable caching */#define LV_CIRCLE_CACHE_SIZE 4
#endif /*LV_DRAW_COMPLEX*//*** "Simple layers" are used when a widget has `style_opa < 255` to buffer the widget into a layer* and blend it as an image with the given opacity.* Note that `bg_opa`, `text_opa` etc don't require buffering into layer)* The widget can be buffered in smaller chunks to avoid using large buffers.** - LV_LAYER_SIMPLE_BUF_SIZE: [bytes] the optimal target buffer size. LVGL will try to allocate it* - LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE: [bytes]  used if `LV_LAYER_SIMPLE_BUF_SIZE` couldn't be allocated.** Both buffer sizes are in bytes.* "Transformed layers" (where transform_angle/zoom properties are used) use larger buffers* and can't be drawn in chunks. So these settings affects only widgets with opacity.*/
#define LV_LAYER_SIMPLE_BUF_SIZE          (24 * 1024)
#define LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE (3 * 1024)/*Default image cache size. Image caching keeps the images opened.*If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added)*With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images.*However the opened images might consume additional RAM.*0: to disable caching*/
#define LV_IMG_CACHE_DEF_SIZE 0/*Number of stops allowed per gradient. Increase this to allow more stops.*This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/
#define LV_GRADIENT_MAX_STOPS 2/*Default gradient buffer size.*When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again.*LV_GRAD_CACHE_DEF_SIZE sets the size of this cache in bytes.*If the cache is too small the map will be allocated only while it's required for the drawing.*0 mean no caching.*/
#define LV_GRAD_CACHE_DEF_SIZE 0/*Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display)*LV_DITHER_GRADIENT implies allocating one or two more lines of the object's rendering surface*The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion */
#define LV_DITHER_GRADIENT 0
#if LV_DITHER_GRADIENT/*Add support for error diffusion dithering.*Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing.*The increase in memory consumption is (24 bits * object's width)*/#define LV_DITHER_ERROR_DIFFUSION 0
#endif/*Maximum buffer size to allocate for rotation.*Only used if software rotation is enabled in the display driver.*/
#define LV_DISP_ROT_MAX_BUF (10*1024)/*-------------* GPU*-----------*//*Use Arm's 2D acceleration library Arm-2D */
#define LV_USE_GPU_ARM2D 0/*Use STM32's DMA2D (aka Chrom Art) GPU*/
#define LV_USE_GPU_STM32_DMA2D 0
#if LV_USE_GPU_STM32_DMA2D/*Must be defined to include path of CMSIS header of target processore.g. "stm32f769xx.h" or "stm32f429xx.h"*/#define LV_GPU_DMA2D_CMSIS_INCLUDE
#endif/*Use SWM341's DMA2D GPU*/
#define LV_USE_GPU_SWM341_DMA2D 0
#if LV_USE_GPU_SWM341_DMA2D#define LV_GPU_SWM341_DMA2D_INCLUDE "SWM341.h"
#endif/*Use NXP's PXP GPU iMX RTxxx platforms*/
#define LV_USE_GPU_NXP_PXP 0
#if LV_USE_GPU_NXP_PXP/*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c)*   and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS*   has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected.*0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init()*/#define LV_USE_GPU_NXP_PXP_AUTO_INIT 0
#endif/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/
#define LV_USE_GPU_NXP_VG_LITE 0/*Use SDL renderer API*/
#define LV_USE_GPU_SDL 0
#if LV_USE_GPU_SDL#define LV_GPU_SDL_INCLUDE_PATH <SDL2/SDL.h>/*Texture cache size, 8MB by default*/#define LV_GPU_SDL_LRU_SIZE (1024 * 1024 * 8)/*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/#define LV_GPU_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6))
#endif#if (defined(BL808) || defined(BL606P))#define LV_USE_GPU_LB_DMA2D  0#define LV_USE_GPU_LB_DMA2D_AUTO_INIT     1#if defined(CPU_D0) && (LV_COLOR_DEPTH != 16 || LV_COLOR_SCREEN_TRANSP == 0)#define LV_USE_RV_VECTOR_EXT 1#else#define LV_USE_RV_VECTOR_EXT 0#endif
#else#define LV_USE_GPU_LB_DMA2D  0#define LV_USE_GPU_LB_DMA2D_AUTO_INIT     0#define LV_USE_RV_VECTOR_EXT 0#endif/*-------------* Logging*-----------*//*Enable the log module*/
#define LV_USE_LOG 1
#if LV_USE_LOG/*How important log should be added:*LV_LOG_LEVEL_TRACE       A lot of logs to give detailed information*LV_LOG_LEVEL_INFO        Log important events*LV_LOG_LEVEL_WARN        Log if something unwanted happened but didn't cause a problem*LV_LOG_LEVEL_ERROR       Only critical issue, when the system may fail*LV_LOG_LEVEL_USER        Only logs added by the user*LV_LOG_LEVEL_NONE        Do not log anything*/#define LV_LOG_LEVEL LV_LOG_LEVEL_WARN/*1: Print the log with 'printf';*0: User need to register a callback with `lv_log_register_print_cb()`*/#define LV_LOG_PRINTF 0/*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/#define LV_LOG_TRACE_MEM        1#define LV_LOG_TRACE_TIMER      1#define LV_LOG_TRACE_INDEV      1#define LV_LOG_TRACE_DISP_REFR  1#define LV_LOG_TRACE_EVENT      1#define LV_LOG_TRACE_OBJ_CREATE 1#define LV_LOG_TRACE_LAYOUT     1#define LV_LOG_TRACE_ANIM       1#endif  /*LV_USE_LOG*//*-------------* Asserts*-----------*//*Enable asserts if an operation is failed or an invalid data is found.*If LV_USE_LOG is enabled an error message will be printed on failure*/
#define LV_USE_ASSERT_NULL          1   /*Check if the parameter is NULL. (Very fast, recommended)*/
#define LV_USE_ASSERT_MALLOC        1   /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/
#define LV_USE_ASSERT_STYLE         0   /*Check if the styles are properly initialized. (Very fast, recommended)*/
#define LV_USE_ASSERT_MEM_INTEGRITY 0   /*Check the integrity of `lv_mem` after critical operations. (Slow)*/
#define LV_USE_ASSERT_OBJ           0   /*Check the object's type and existence (e.g. not deleted). (Slow)*//*Add a custom handler when assert happens e.g. to restart the MCU*/
#define LV_ASSERT_HANDLER_INCLUDE <stdint.h>
#define LV_ASSERT_HANDLER while(1);   /*Halt by default*//*-------------* Others*-----------*//*1: Show CPU usage and FPS count*/
#define LV_USE_PERF_MONITOR 1
#if LV_USE_PERF_MONITOR#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
#endif/*1: Show the used memory and the memory fragmentation* Requires LV_MEM_CUSTOM = 0*/
#define LV_USE_MEM_MONITOR 1
#if LV_USE_MEM_MONITOR#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
#endif/*1: Draw random colored rectangles over the redrawn areas*/
#define LV_USE_REFR_DEBUG 0/*Change the built in (v)snprintf functions*/
#define LV_SPRINTF_CUSTOM 0
#if LV_SPRINTF_CUSTOM#define LV_SPRINTF_INCLUDE <stdio.h>#define lv_snprintf  snprintf#define lv_vsnprintf vsnprintf
#else   /*LV_SPRINTF_CUSTOM*/#define LV_SPRINTF_USE_FLOAT 0
#endif  /*LV_SPRINTF_CUSTOM*/#define LV_USE_USER_DATA 1/*Garbage Collector settings*Used if lvgl is bound to higher level language and the memory is managed by that language*/
#define LV_ENABLE_GC 0
#if LV_ENABLE_GC != 0#define LV_GC_INCLUDE "gc.h"                           /*Include Garbage Collector related things*/
#endif /*LV_ENABLE_GC*//*=====================*  COMPILER SETTINGS*====================*//*For big endian systems set to 1*/
#define LV_BIG_ENDIAN_SYSTEM 0/*Define a custom attribute to `lv_tick_inc` function*/
#define LV_ATTRIBUTE_TICK_INC/*Define a custom attribute to `lv_timer_handler` function*/
#define LV_ATTRIBUTE_TIMER_HANDLER/*Define a custom attribute to `lv_disp_flush_ready` function*/
#define LV_ATTRIBUTE_FLUSH_READY/*Required alignment size for buffers*/
#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default).* E.g. __attribute__((aligned(4)))*/
#define LV_ATTRIBUTE_MEM_ALIGN/*Attribute to mark large constant arrays for example font's bitmaps*/
#define LV_ATTRIBUTE_LARGE_CONST/*Compiler prefix for a big array declaration in RAM*/
#define LV_ATTRIBUTE_LARGE_RAM_ARRAY/*Place performance critical functions into a faster memory (e.g RAM)*/
#define LV_ATTRIBUTE_FAST_MEM/*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/
#define LV_ATTRIBUTE_DMA/*Export integer constant to binding. This macro is used with constants in the form of LV_<CONST> that*should also appear on LVGL binding API such as Micropython.*/
#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*//*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/
#define LV_USE_LARGE_COORD 0/*==================*   FONT USAGE*===================*//*Montserrat fonts with ASCII range and some symbols using bpp = 4*https://fonts.google.com/specimen/Montserrat*/
#define LV_FONT_MONTSERRAT_8  0
#define LV_FONT_MONTSERRAT_10 0
#define LV_FONT_MONTSERRAT_12 0
#define LV_FONT_MONTSERRAT_14 1
#define LV_FONT_MONTSERRAT_16 0
#define LV_FONT_MONTSERRAT_18 0
#define LV_FONT_MONTSERRAT_20 0
#define LV_FONT_MONTSERRAT_22 0
#define LV_FONT_MONTSERRAT_24 0
#define LV_FONT_MONTSERRAT_26 0
#define LV_FONT_MONTSERRAT_28 0
#define LV_FONT_MONTSERRAT_30 0
#define LV_FONT_MONTSERRAT_32 0
#define LV_FONT_MONTSERRAT_34 0
#define LV_FONT_MONTSERRAT_36 0
#define LV_FONT_MONTSERRAT_38 0
#define LV_FONT_MONTSERRAT_40 0
#define LV_FONT_MONTSERRAT_42 0
#define LV_FONT_MONTSERRAT_44 0
#define LV_FONT_MONTSERRAT_46 0
#define LV_FONT_MONTSERRAT_48 0/*Demonstrate special features*/
#define LV_FONT_MONTSERRAT_12_SUBPX      0
#define LV_FONT_MONTSERRAT_28_COMPRESSED 0  /*bpp = 3*/
#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0  /*Hebrew, Arabic, Persian letters and all their forms*/
#define LV_FONT_SIMSUN_16_CJK            0  /*1000 most common CJK radicals*//*Pixel perfect monospace fonts*/
#define LV_FONT_UNSCII_8  0
#define LV_FONT_UNSCII_16 0/*Optionally declare custom fonts here.*You can use these fonts as default font too and they will be available globally.*E.g. #define LV_FONT_CUSTOM_DECLARE   LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/
#define LV_FONT_CUSTOM_DECLARE/*Always set a default font*/
#define LV_FONT_DEFAULT &lv_font_montserrat_14/*Enable handling large font and/or fonts with a lot of characters.*The limit depends on the font size, font face and bpp.*Compiler error will be triggered if a font needs it.*/
#define LV_FONT_FMT_TXT_LARGE 0/*Enables/disables support for compressed fonts.*/
#define LV_USE_FONT_COMPRESSED 1/*Enable subpixel rendering*/
#define LV_USE_FONT_SUBPX 1
#if LV_USE_FONT_SUBPX/*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/#define LV_FONT_SUBPX_BGR 0  /*0: RGB; 1:BGR order*/
#endif/*=================*  TEXT SETTINGS*=================*//*** Select a character encoding for strings.* Your IDE or editor should have the same character encoding* - LV_TXT_ENC_UTF8* - LV_TXT_ENC_ASCII*/
#define LV_TXT_ENC LV_TXT_ENC_UTF8/*Can break (wrap) texts on these chars*/
#define LV_TXT_BREAK_CHARS " ,.;:-_"/*If a word is at least this long, will break wherever "prettiest"*To disable, set to a value <= 0*/
#define LV_TXT_LINE_BREAK_LONG_LEN 0/*Minimum number of characters in a long word to put on a line before a break.*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3/*Minimum number of characters in a long word to put on a line after a break.*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3/*The control character to use for signalling text recoloring.*/
#define LV_TXT_COLOR_CMD "#"/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts.*The direction will be processed according to the Unicode Bidirectional Algorithm:*https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/
#define LV_USE_BIDI 0
#if LV_USE_BIDI/*Set the default direction. Supported values:*`LV_BASE_DIR_LTR` Left-to-Right*`LV_BASE_DIR_RTL` Right-to-Left*`LV_BASE_DIR_AUTO` detect texts base direction*/#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO
#endif/*Enable Arabic/Persian processing*In these languages characters should be replaced with an other form based on their position in the text*/
#define LV_USE_ARABIC_PERSIAN_CHARS 0/*==================*  WIDGET USAGE*================*//*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/#define LV_USE_ARC        1#define LV_USE_BAR        1#define LV_USE_BTN        1#define LV_USE_BTNMATRIX  1#define LV_USE_CANVAS     1#define LV_USE_CHECKBOX   1#define LV_USE_DROPDOWN   1   /*Requires: lv_label*/#define LV_USE_IMG        1   /*Requires: lv_label*/#define LV_USE_LABEL      1
#if LV_USE_LABEL#define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/#define LV_LABEL_LONG_TXT_HINT 1  /*Store some extra info in labels to speed up drawing of very long texts*/
#endif#define LV_USE_LINE       1#define LV_USE_ROLLER     1   /*Requires: lv_label*/
#if LV_USE_ROLLER#define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/
#endif#define LV_USE_SLIDER     1   /*Requires: lv_bar*/#define LV_USE_SWITCH     1#define LV_USE_TEXTAREA   1   /*Requires: lv_label*/
#if LV_USE_TEXTAREA != 0#define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500    /*ms*/
#endif#define LV_USE_TABLE      1/*==================* EXTRA COMPONENTS*==================*//*-----------* Widgets*----------*/
#define LV_USE_ANIMIMG    1#define LV_USE_CALENDAR   1
#if LV_USE_CALENDAR#define LV_CALENDAR_WEEK_STARTS_MONDAY 0#if LV_CALENDAR_WEEK_STARTS_MONDAY#define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"}#else#define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}#endif#define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March",  "April", "May",  "June", "July", "August", "September", "October", "November", "December"}#define LV_USE_CALENDAR_HEADER_ARROW 1#define LV_USE_CALENDAR_HEADER_DROPDOWN 1
#endif  /*LV_USE_CALENDAR*/#define LV_USE_CHART      1#define LV_USE_COLORWHEEL 1#define LV_USE_IMGBTN     1#define LV_USE_KEYBOARD   1#define LV_USE_LED        1#define LV_USE_LIST       1#define LV_USE_MENU       1#define LV_USE_METER      1#define LV_USE_MSGBOX     1#define LV_USE_SPAN       1
#if LV_USE_SPAN/*A line text can contain maximum num of span descriptor */#define LV_SPAN_SNIPPET_STACK_SIZE 64
#endif#define LV_USE_SPINBOX    1#define LV_USE_SPINNER    1#define LV_USE_TABVIEW    1#define LV_USE_TILEVIEW   1#define LV_USE_WIN        1/*-----------* Themes*----------*//*A simple, impressive and very complete theme*/
#define LV_USE_THEME_DEFAULT 1
#if LV_USE_THEME_DEFAULT/*0: Light mode; 1: Dark mode*/#define LV_THEME_DEFAULT_DARK 0/*1: Enable grow on press*/#define LV_THEME_DEFAULT_GROW 1/*Default transition time in [ms]*/#define LV_THEME_DEFAULT_TRANSITION_TIME 80
#endif /*LV_USE_THEME_DEFAULT*//*A very simple theme that is a good starting point for a custom theme*/
#define LV_USE_THEME_BASIC 1/*A theme designed for monochrome displays*/
#define LV_USE_THEME_MONO 1/*-----------* Layouts*----------*//*A layout similar to Flexbox in CSS.*/
#define LV_USE_FLEX 1/*A layout similar to Grid in CSS.*/
#define LV_USE_GRID 1/*---------------------* 3rd party libraries*--------------------*//*File system interfaces for common APIs *//*API for fopen, fread, etc*/
#define LV_USE_FS_STDIO 0
#if LV_USE_FS_STDIO#define LV_FS_STDIO_LETTER '\0'     /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/#define LV_FS_STDIO_PATH ""         /*Set the working directory. File/directory paths will be appended to it.*/#define LV_FS_STDIO_CACHE_SIZE 0    /*>0 to cache this number of bytes in lv_fs_read()*/
#endif/*API for open, read, etc*/
#define LV_USE_FS_POSIX 0
#if LV_USE_FS_POSIX#define LV_FS_POSIX_LETTER '\0'     /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/#define LV_FS_POSIX_PATH ""         /*Set the working directory. File/directory paths will be appended to it.*/#define LV_FS_POSIX_CACHE_SIZE 0    /*>0 to cache this number of bytes in lv_fs_read()*/
#endif/*API for CreateFile, ReadFile, etc*/
#define LV_USE_FS_WIN32 0
#if LV_USE_FS_WIN32#define LV_FS_WIN32_LETTER '\0'     /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/#define LV_FS_WIN32_PATH ""         /*Set the working directory. File/directory paths will be appended to it.*/#define LV_FS_WIN32_CACHE_SIZE 0    /*>0 to cache this number of bytes in lv_fs_read()*/
#endif/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/
#if defined(BL808) || defined(BL606P) || defined(BL616)
#define LV_USE_FS_FATFS 0
#else
#define LV_USE_FS_FATFS 0
#endif#if LV_USE_FS_FATFS#define LV_FS_FATFS_LETTER 'S'     /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/#define LV_FS_FATFS_CACHE_SIZE 0    /*>0 to cache this number of bytes in lv_fs_read()*/
#endif/*PNG decoder library*/
#define LV_USE_PNG 1/*BMP decoder library*/
#define LV_USE_BMP 0/* JPG + split JPG decoder library.* Split JPG is a custom format optimized for embedded systems. */
#define LV_USE_SJPG 0/*GIF decoder library*/
#define LV_USE_GIF 0/*QR code library*/
#define LV_USE_QRCODE 0/*FreeType library*/
#define LV_USE_FREETYPE 0
#if LV_USE_FREETYPE/*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/#define LV_FREETYPE_CACHE_SIZE (16 * 1024)#if LV_FREETYPE_CACHE_SIZE >= 0/* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. *//* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) *//* if font size >= 256, must be configured as image cache */#define LV_FREETYPE_SBIT_CACHE 0/* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. *//* (0:use system defaults) */#define LV_FREETYPE_CACHE_FT_FACES 0#define LV_FREETYPE_CACHE_FT_SIZES 0#endif
#endif/*Rlottie library*/
#define LV_USE_RLOTTIE 0/*FFmpeg library for image decoding and playing videos*Supports all major image formats so do not enable other image decoder with it*/
#define LV_USE_FFMPEG 0
#if LV_USE_FFMPEG/*Dump input information to stderr*/#define LV_FFMPEG_DUMP_FORMAT 0
#endif/*-----------* Others*----------*//*1: Enable API to take snapshot for object*/
#define LV_USE_SNAPSHOT 0/*1: Enable Monkey test*/
#define LV_USE_MONKEY 0/*1: Enable grid navigation*/
#define LV_USE_GRIDNAV 0/*1: Enable lv_obj fragment*/
#define LV_USE_FRAGMENT 0/*1: Support using images as font in label or span widgets */
#define LV_USE_IMGFONT 0/*1: Enable a published subscriber based messaging system */
#define LV_USE_MSG 0/*1: Enable Pinyin input method*/
/*Requires: lv_keyboard*/
#define LV_USE_IME_PINYIN 0
#if LV_USE_IME_PINYIN/*1: Use default thesaurus*//*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/#define LV_IME_PINYIN_USE_DEFAULT_DICT 1/*Set the maximum number of candidate panels that can be displayed*//*This needs to be adjusted according to the size of the screen*/#define LV_IME_PINYIN_CAND_TEXT_NUM 6/*Use 9 key input(k9)*/#define LV_IME_PINYIN_USE_K9_MODE      1#if LV_IME_PINYIN_USE_K9_MODE == 1#define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3#endif // LV_IME_PINYIN_USE_K9_MODE
#endif/*==================
* EXAMPLES
*==================*//*Enable the examples to be built with the library*/
#define LV_BUILD_EXAMPLES 1/*===================* DEMO USAGE====================*//*Show some widget. It might be required to increase `LV_MEM_SIZE` */
#define LV_USE_DEMO_WIDGETS 1
#if LV_USE_DEMO_WIDGETS
#define LV_DEMO_WIDGETS_SLIDESHOW 0
#endif/*Demonstrate the usage of encoder and keyboard*/
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0/*Benchmark your system*/
#define LV_USE_DEMO_BENCHMARK 1
#if LV_USE_DEMO_BENCHMARK
/*Use RGB565A8 images with 16 bit color depth instead of ARGB8565*/
#define LV_DEMO_BENCHMARK_RGB565A8 0
#endif/*Stress test for LVGL*/
#define LV_USE_DEMO_STRESS 0/*Music player demo*/
#define LV_USE_DEMO_MUSIC 0
#if LV_USE_DEMO_MUSIC#define LV_DEMO_MUSIC_SQUARE    0#define LV_DEMO_MUSIC_LANDSCAPE 0#define LV_DEMO_MUSIC_ROUND     0#define LV_DEMO_MUSIC_LARGE     0#define LV_DEMO_MUSIC_AUTO_PLAY 0
#endif/*--END OF LV_CONF_H--*/#endif /*LV_CONF_H*/#endif /*End of "Content enable"*/

五、LVGL_DEMO文件修改

        基本上上述文件修改完成以后,就只需要修改M1s_BL808_example/c906_app/lvgl_demo/main.c文件就可以启用测试功能了。

        需要注释掉一部分不需要的背光控制功能,然后使能 lv_demo_benchmark();

#include <stdbool.h>
#include <stdio.h>/* FreeRTOS */
#include <FreeRTOS.h>
#include <task.h>/* bl808 c906 std driver */
#include <bl808_glb.h>#include "demos/lv_demos.h"
#include "lv_port_disp.h"
#include "lv_port_indev.h"
#include "lvgl.h"// #include "ui.h"
#include "m1s_c906_xram_pwm.h"// #include "bl-osd-app.h"#define PWM_PORT (0)
#define PWM_PIN (8)
#define LCD_BL_PWM_PIN (11)void backlight_init(void)
{// m1s_xram_pwm_init(PWM_PORT, PWM_PIN, 2000, 25);// m1s_xram_pwm_start(PWM_PORT, PWM_PIN);// m1s_xram_pwm_init(PWM_PORT, LCD_BL_PWM_PIN, 2000, 25);// m1s_xram_pwm_start(PWM_PORT, LCD_BL_PWM_PIN);
}/* lvgl log cb */
void lv_log_print_g_cb(const char *buf)
{printf("[LVGL] %s", buf);
}static void lvgl_task(void *param)
{while (1) {lv_task_handler();vTaskDelay(1);}vTaskDelete(NULL);
}void main()
{backlight_init();lv_log_register_print_cb(lv_log_print_g_cb);lv_init();lv_port_disp_init();// lv_port_indev_init();lv_demo_benchmark();// lv_demo_widgets();// ui_init();// bl_osd_init();xTaskCreate(lvgl_task, (char *)"lvgl task", 512, NULL, 15, NULL);}

六、固件编译及烧录

        按照SIPEED的介绍,对lvgl_demo文件进行编译,然后进行烧录,接好屏幕,接好屏幕的背光。按下重启键,就可以看到美妙的LVGL_BENCHMARK正在运行啦,下面贴一个测试的成绩,使用的是800*480的屏幕,RGB565输出。

Starting bl808 now....
Heap Info: 63455 KB @ [0x0x0000000050208400 ~ 0x0x0000000054000000]
[OS] Starting aos_loop_proc task...
[OS] Stop c906 xram handle...
[OS] Starting OS Scheduler...
Init CLI with event Driven
[LVGL] 
LVGL v8.3.1  Benchmark (in csv format)
[LVGL] Weighted FPS: 99
[LVGL] Opa. speed: 85%
[LVGL] Rectangle,166
[LVGL] Rectangle + opa,[LVGL] 87
[LVGL] Rectangle rounded,141
[LVGL] Rectangle rounded + opa,[LVGL] 79
[LVGL] Circle,99
[LVGL] Circle + opa,[LVGL] 52
[LVGL] Border,198
[LVGL] Border + opa,[LVGL] 198
[LVGL] Border rounded,180
[LVGL] Border rounded + opa,[LVGL] 172
[LVGL] Circle border,96
[LVGL] Circle border + opa,[LVGL] 92
[LVGL] Border top,198
[LVGL] Border top + opa,[LVGL] 198
[LVGL] Border left,198
[LVGL] Border left + opa,[LVGL] 198
[LVGL] Border top + left,197
[LVGL] Border top + left + opa,[LVGL] 179
[LVGL] Border left + right,174
[LVGL] Border left + right + opa,[LVGL] 173
[LVGL] Border top + bottom,197
[LVGL] Border top + bottom + opa,[LVGL] 196
[LVGL] Shadow small,84
[LVGL] Shadow small + opa,[LVGL] 80
[LVGL] Shadow small offset,78
[LVGL] Shadow small offset + opa,[LVGL] 66
[LVGL] Shadow large,52
[LVGL] Shadow large + opa,[LVGL] 50
[LVGL] Shadow large offset,51
[LVGL] Shadow large offset + opa,[LVGL] 46
[LVGL] Image RGB,167
[LVGL] Image RGB + opa,[LVGL] 112
[LVGL] Image ARGB,124
[LVGL] Image ARGB + opa,[LVGL] 106
[LVGL] Image chorma keyed,139
[LVGL] Image chorma keyed + opa,[LVGL] 109
[LVGL] Image indexed,80
[LVGL] Image indexed + opa,[LVGL] 71
[LVGL] Image alpha only,74
[LVGL] Image alpha only + opa,[LVGL] 66
[LVGL] Image RGB recolor,87
[LVGL] Image RGB recolor + opa,[LVGL] 68
[LVGL] Image ARGB recolor,75
[LVGL] Image ARGB recolor + opa,[LVGL] 68
[LVGL] Image chorma keyed recolor,80
[LVGL] Image chorma keyed recolor + opa,[LVGL] 70
[LVGL] Image indexed recolor,57
[LVGL] Image indexed recolor + opa,[LVGL] 52
[LVGL] Image RGB rotate,76
[LVGL] Image RGB rotate + opa,[LVGL] 55
[LVGL] Image RGB rotate anti aliased,35
[LVGL] Image RGB rotate anti aliased + opa,[LVGL] 30
[LVGL] Image ARGB rotate,66
[LVGL] Image ARGB rotate + opa,[LVGL] 58
[LVGL] Image ARGB rotate anti aliased,31
[LVGL] Image ARGB rotate anti aliased + opa,[LVGL] 29
[LVGL] Image RGB zoom,100
[LVGL] Image RGB zoom + opa,[LVGL] 76
[LVGL] Image RGB zoom anti aliased,49
[LVGL] Image RGB zoom anti aliased + opa,[LVGL] 43
[LVGL] Image ARGB zoom,90
[LVGL] Image ARGB zoom + opa,[LVGL] 83
[LVGL] Image ARGB zoom anti aliased,43
[LVGL] Image ARGB zoom anti aliased + opa,[LVGL] 40
[LVGL] Text small,68
[LVGL] Text small + opa,[LVGL] 69
[LVGL] Text medium,69
[LVGL] Text medium + opa,[LVGL] 69
[LVGL] Text large,69
[LVGL] Text large + opa,[LVGL] 69
[LVGL] Text small compressed,49
[LVGL] Text small compressed + opa,[LVGL] 49
[LVGL] Text medium compressed,43
[LVGL] Text medium compressed + opa,[LVGL] 43
[LVGL] Text large compressed,31
[LVGL] Text large compressed + opa,[LVGL] 31
[LVGL] Line,114
[LVGL] Line + opa,[LVGL] 116
[LVGL] Arc think,132
[LVGL] Arc think + opa,[LVGL] 130
[LVGL] Arc thick,130
[LVGL] Arc thick + opa,[LVGL] 121
[LVGL] Substr. rectangle,52
[LVGL] Substr. rectangle + opa,[LVGL] 26
[LVGL] Substr. border,55
[LVGL] Substr. border + opa,[LVGL] 54
[LVGL] Substr. shadow,22
[LVGL] Substr. shadow + opa,[LVGL] 22
[LVGL] Substr. image,55
[LVGL] Substr. image + opa,[LVGL] 55
[LVGL] Substr. line,55
[LVGL] Substr. line + opa,[LVGL] 60
[LVGL] Substr. arc,124
[LVGL] Substr. arc + opa,[LVGL] 124
[LVGL] Substr. text,41
[LVGL] Substr. text + opa,[LVGL] 41

运行的图片

运行视频,点我走你!!!!!!!!

800-480-BL808-LVGL

上面的图片是自己打了一块PCB,屏幕显示发绿是因为在设计的时候并没有做到像上面介绍的将RGB565和屏幕的高位对其,而是低位对齐了,可以自己修改一下。背光使用的是16-18V可调电源,自己调节亮度。文件在此!!!!点我直达

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/655965.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java基础数据结构之Lambda表达式

一.语法 基本语法&#xff1a;(parameters)->expression或者(parameters)->{statements;} parameters&#xff1a;类似方法中的形参列表&#xff0c;这里的参数是函数式接口里面的参数。这里的参数可以明确说明&#xff0c;也可以不声明而由JVM隐含的推断。当只有一个推…

C++实习报告(集合交,并,差运算的实现)

一、问题描述 1、问题描述 集合元素类型可以是整数、字符串和小数&#xff0c;实现集合的交、并、差运算。 2、功能要求 &#xff08;1&#xff09;用户能够输入两个集合元素&#xff1b; &#xff08;2&#xff09;能够完成集合的交、并、差运算&#xff1b; &#xff08;3&a…

07. STP的基本配置

文章目录 一. 初识STP1.1. STP概述1.2. STP的出现1.3. STP的作用1.4. STP的专业术语1.5. BPDU的报文格式1.6. STP的选择原则&#xff08;1&#xff09;选择根桥网桥原则&#xff08;2&#xff09;选择根端口原则 1.7. 端口状态1.8. STP报文类型1.9. STP的收敛时间 二. 实验专题…

【MySQL 流浪之旅】 第六讲 浅谈 MySQL 锁

系列文章目录 【MySQL 流浪之旅】 第一讲 MySQL 安装【MySQL 流浪之旅】 第二讲 MySQL 基础操作【MySQL 流浪之旅】 第三讲 MySQL 基本工具【MySQL 流浪之旅】 第四讲 MySQL 逻辑备份【MySQL 流浪之旅】 第五讲 数据库设计的三个范式 目录 系列文章目录 一、什么是锁&#x…

07-Nacos-接入Mysql实现持久化

1、默认内嵌的数据库 Derby 存于/data目录 2、扩展仅支持Mysql 5.6.5 执行Nacos中的SQL脚本&#xff0c;该脚本是Nacos-server文件夹中的nacos-mysql.sql 详见 01-Nacos源码打包、部署-CSDN博客 3、修改配置文件 Nacos-server中的conf目录下&#xff0c;application.proper…

5种ai智能自动写作,让你的写作效率秒拔高

写作是一项需要耗费大量时间和精力的任务&#xff0c;但现在有了AI智能自动写作软件&#xff0c;我们可以轻松提高写作效率。在国内市场上&#xff0c;有许多优秀的写作软件可供选择。本文将向您推荐5款国内的写作软件&#xff0c;并详细说明每款软件的功能特点。 爱制作AI 使…

小项目:使用MQTT上传温湿度到Onenet服务器

前言 我们之前分别编写了 DHT11、ESP8266 和 MQTT 的代码&#xff0c;现在我们将它们仨整合在一起&#xff0c;来做一个温湿度检测小项目。这个项目可以实时地将 DHT11 传感器获取到的温湿度数据上传到 OneNET 平台。通过登录 OneNET&#xff0c;我们随时随地可以查看温湿度数…

山体滑坡在线安全监测预警系统(解决方案)

在近年来&#xff0c;随着全球气候变化的影响&#xff0c;山体滑坡等自然灾害频发&#xff0c;给人们的生命财产安全带来了严重威胁。为了有效预防和减少山体滑坡带来的危害&#xff0c;许多地方开始在山上安装山体滑坡在线安全监测预警系统&#xff08;解决方案&#xff09;。…

Java版大厂算法题1——数字颠倒

问题描述 输入一个整数&#xff0c;将这个整数以字符串的形式逆序输出&#xff0c;程序不考虑负数的情况&#xff0c;若数字含有0&#xff0c;则逆序形式也含有0。如果输入为100&#xff0c;则输出为001。 数据范围&#xff1a;0<n<(2^30)-1 * 输入描述&#xff1a;输入…

SpringBoot+SqlServer查询接口

SpringBootSqlServer查询接口 文章目录 SpringBootSqlServer查询接口1. pom环境配置2. common工具包3. 实体类接口映射4. Service层Controller层 需求&#xff1a;根据站号查询前一个小时的所有数据&#xff0c;将数据返回格式为Map<String,List<Map<String,String>…

【硬件产品经理】避免硬件产品失败 | 技术维度

目录 简介 技术维度一&#xff1a;低估产品开发 技术维度二&#xff1a;低估规模生产的复杂性 技术维度三&#xff1a;测试不足 技术维度四&#xff1a;产品太复杂 技术维度五&#xff1a;对客户承诺太高 推荐内容 简介 这节内容主要从技术维度来谈谈避免硬件产品失败这…

vue3封装el-pagination分页组件

1、效果如图&#xff1a; 2、分页组件代码&#xff1a; <template><div class"paging"><el-config-provider :locale"zhCn"><el-paginationv-model:current-page"page.currentPage"v-model:page-size"page.pageSize…

基于Prompt Learning的信息抽取

PTR: Prompt Tuning with Rules for Text Classification 清华&#xff1b;liuzhiyuan&#xff1b;通过规则制定subpromptRelation Extraction as Open-book Examination: Retrieval-enhanced Prompt Tuning Relation Extraction as Open-book Examination: Retrieval-enhance…

iPhone 14支持NFC吗?如果支持,那么怎么启用

你准备好通过启用NFC来释放iPhone 14的全部潜力了吗&#xff1f;如果你曾经想知道如何在你的设备上利用NFC&#xff0c;那么你就来对地方了。 在本综合指南中&#xff0c;我们将引导你完成在iPhone 14上激活NFC的步骤&#xff0c;使你能够无缝连接其他设备&#xff0c;进行非接…

github添加 SSH 密钥

1 打开终端 输入 ssh-keygen -t rsa -b 4096 -C "github邮箱地址"如果不需要密码可以一路回车 出现这个页面就是生存成功了 open ~/.ssh // 打开.ssh 找到id_rsa.pub复制出内容新建ssh密钥输入内容,保存即可

网络安全|重大失误!微软被盗测试账号拥有公司Office 365管理员权限

微软网络近期遭黑客入侵&#xff0c;高管电子邮件被监视长达两个月。 一位研究员表示&#xff0c;黑客通过获取一个拥有管理员权限的老旧测试帐号的访问权限来实施入侵&#xff0c;这是微软犯下的重大失误。 微软在1月25日&#xff08;上周四&#xff09;发布第二篇公告&…

Linux:重定向

Linux&#xff1a;重定向 输出重定向追加重定向输出重定向与追加重定向的本质输入重定向 输出重定向 在Linux中&#xff0c;输出重定向是一种将命令的输出发送到不同位置的方法。通常&#xff0c;执行命令时&#xff0c;输出会显示在终端上。然而&#xff0c;使用输出重定向&a…

vue3 + antd 封装动态表单组件(三)

传送带&#xff1a; vue3 antd 封装动态表单组件&#xff08;一&#xff09; vue3 antd 封装动态表单组件&#xff08;二&#xff09; 前置条件&#xff1a; vue版本 v3.3.11 ant-design-vue版本 v4.1.1 我们发现ant-design-vue Input组件和FormItem组件某些属性支持slot插…

数据写入HBase(scala)

package sourceimport org.apache.hadoop.hbase.{HBaseConfiguration, TableName} import org.apache.hadoop.hbase.client.{ConnectionFactory, Put} import org.apache.hadoop.hbase.util.Bytesobject ffff {def main(args: Array[String]): Unit {//hbase连接配置val conf …

Tensorflow2.0笔记 - tensor的padding和tile

本笔记记录tensor的填充和tile操作&#xff0c;对应tf.pad和tf.tile import tensorflow as tf import numpy as nptf.__version__#pad做填充 # tf.pad( tensor,paddings, modeCONSTANT,nameNone) #1维tensor填充 tensor tf.random.uniform([5], maxval10, dtypetf.int32) pri…