办公室里的艺术革命:迪达拉的“黑土”新篇章

核心内容摘要

中文字幕99视频精彩合集:打开视界,点燃激情
鞠婧祎“17c”风暴背后的真相:一次流量与真实的博弈

“老少配”的那些事儿:情之所至,年龄只是数字?

本篇讲述驱动LCD显示。

原理开发板使用204*240 RGB LCD。

原理如下

代码准备

GPIO引脚配置如下主要是复位引脚、背光引脚、电源控制引脚。

LCD FMC接口配置至此实现硬件引脚配置。

后面以STM32Cube MCU Packages安装包下的BSP库为基础代码展开。

LCD初始化。

在SystemHardwareInit函数内实现包含GPIO引脚初始化与设置复制staticvoidSystemHardwareInit(void){/*......*/LCD_UTILS_Drv_t lcdDrv;/* Set UTIL_LCD functions */lcdDrv.DrawBitmap BSP_LCD_DrawBitmap;lcdDrv.FillRGBRect BSP_LCD_FillRGBRect;lcdDrv.DrawHLine BSP_LCD_DrawHLine;lcdDrv.DrawVLine BSP_LCD_DrawVLine;lcdDrv.FillRect BSP_LCD_FillRect;lcdDrv.GetPixel BSP_LCD_ReadPixel;lcdDrv.SetPixel BSP_LCD_WritePixel;lcdDrv.GetXSize BSP_LCD_GetXSize;lcdDrv.GetYSize BSP_LCD_GetYSize;lcdDrv.SetLayer BSP_LCD_SetActiveLayer;lcdDrv.GetFormat BSP_LCD_GetFormat;UTIL_LCD_SetFuncDriver(lcdDrv);/* Clear the LCD */UTIL_LCD_Clear(UTIL_LCD_COLOR_WHITE);/* Set the display on */if(BSP_LCD_DisplayOn(

! BSP_ERROR_NONE){Error_Handler();}}

LCD刷屏显示红、绿、蓝复制UTIL_LCD_FillRect(0, 0, 240, 240, UTIL_LCD_COLOR_RED);HAL_Delay(

;UTIL_LCD_FillRect(0, 0, 240, 240, UTIL_LCD_COLOR_GREEN);HAL_Delay(

;UTIL_LCD_FillRect(0, 0, 240, 240, UTIL_LCD_COLOR_BLUE);HAL_Delay(

;

LCD显示字符串复制UTIL_LCD_SetFont(Font

;/* Set the LCD Text Color */UTIL_LCD_SetBackColor(UTIL_LCD_COLOR_LIGHTMAGENTA);UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_BLUE);UTIL_LCD_FillRect(0,0,240,30, UTIL_LCD_COLOR_LIGHTMAGENTA);/* Display LCD messages */UTIL_LCD_DisplayStringAt(0,10, (uint8_t*)STM32L562E-DK Board, CENTER_MODE);

LCD显示图像(

制作200*200像素图片使用Image2Lcd工具加载设置如下图所示生成图像数组。

(

编写画图函数复制voidLCD_ShowPicture(uint16_tx,uint16_ty,uint16_tcolumn,uint16_trow,uint32_t*pic){uint16_tm,h;uint32_t*data(uint32_t*)pic;for(h0y;hrowy;h)//60{for(m0x;mcolumnx;m)//180{// LCD_Fast_DrawPoint(m,h,*data);UTIL_LCD_SetPixel(m,h,*data);}}}

main函数复制intmain(void){/* STM32L5xx HAL library initialization:- Systick timer is configured by default as source of time base, but usercan eventually implement his proper time base source (a general purposetimer for example or other time source), keeping in mind that Time baseduration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined andhandled in milliseconds basis.- Set NVIC Group Priority to 3- Low Level Initialization*/HAL_Init();/* Configure the System clock to have a frequency of 110 MHz */SystemClock_Config();/* For better performances, enable the instruction cache in 1-way direct mapped mode */HAL_ICACHE_ConfigAssociativityMode(ICACHE_1WAY);if(HAL_ICACHE_Enable() ! HAL_OK){/* Initialization Error */Error_Handler();}/* System common Hardware components initialization (Leds, button, joystick and LCD) */SystemHardwareInit();UTIL_LCD_FillRect(0,0,240,240, UTIL_LCD_COLOR_RED);HAL_Delay(

;UTIL_LCD_FillRect(0,0,240,240, UTIL_LCD_COLOR_GREEN);HAL_Delay(

;UTIL_LCD_FillRect(0,0,240,240, UTIL_LCD_COLOR_BLUE);HAL_Delay(

;/* Clear the LCD */UTIL_LCD_Clear(UTIL_LCD_COLOR_WHITE);UTIL_LCD_SetFont(Font

;/* Set the LCD Text Color */UTIL_LCD_SetBackColor(UTIL_LCD_COLOR_WHITE);UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_BLACK);//UTIL_LCD_COLOR_BLACK//UTIL_LCD_COLOR_BLUE// UTIL_LCD_FillRect(0, 0, 240, 30, UTIL_LCD_COLOR_LIGHTMAGENTA);/* Display LCD messages */UTIL_LCD_DisplayStringAt(0,10, (uint8_t*)STM32L562E-DK Board, CENTER_MODE);// UTIL_LCD_SetBackColor(UTIL_LCD_COLOR_LIGHTMAGENTA);// UTIL_LCD_FillRect(0, 18, 240, 19, UTIL_LCD_COLOR_LIGHTMAGENTA);UTIL_LCD_DrawHLine(0,25,240,UTIL_LCD_COLOR_LIGHTMAGENTA);//UTIL_LCD_DrawBitmap(0, 0, (uint8_t *)gImage_

;LCD_ShowPicture(20,40,200,200,(uint32_t*)gImage_

;HAL_Delay(

;/* Infinite loop */while(

{}}

测试编译烧录后。

LCD分别显示红绿蓝刷品显示字符串及图像。

效果如下。

ps资源图片。

---------------------作者dirty123链接https://bbs.21ic.com/forum.php?modviewthreadtid3435986来源21ic.com此文章已获得原创/原创奖标签著作权归21ic所有任何人未经允许禁止转载。

想在健康的店舖裡做美容师做荡妇仓木诗织-想在健康的店舖裡做美容师做荡妇仓木诗织应用

百度百家号客服电话人工服务

123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123