野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11212|回复: 3

关于 11-LTDC—液晶显示英文例程 LCD_Clear 函数问题

[复制链接]
发表于 2016-6-2 10:35:43 | 显示全部楼层 |阅读模式
/**
* @brief  Clears the hole LCD.
* @param  Color: the color of the background.
* @retval None
*/

void LCD_Clear(uint16_t Color)
{

DMA2D_InitTypeDef      DMA2D_InitStruct;

uint16_t Red_Value = 0, Green_Value = 0, Blue_Value = 0;

Red_Value = (0xF800 & CurrentTextColor) >> 11;
Blue_Value = 0x001F & CurrentTextColor;
Green_Value = (0x07E0 & CurrentTextColor) >> 5;


/* configure DMA2D */
DMA2D_DeInit();
DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M;
DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565;
DMA2D_InitStruct.DMA2D_OutputGreen = Green_Value;
DMA2D_InitStruct.DMA2D_OutputBlue = Blue_Value;
DMA2D_InitStruct.DMA2D_OutputRed = Red_Value;
DMA2D_InitStruct.DMA2D_OutputAlpha = (Color&0x8000) ? 0xFF:0x00;                //设置透明度
DMA2D_InitStruct.DMA2D_OutputMemoryAdd = CurrentFrameBuffer;
DMA2D_InitStruct.DMA2D_OutputOffset = 0;
DMA2D_InitStruct.DMA2D_NumberOfLine = LCD_PIXEL_HEIGHT;
DMA2D_InitStruct.DMA2D_PixelPerLine = LCD_PIXEL_WIDTH;
DMA2D_Init(&DMA2D_InitStruct);

/* Start Transfer */
DMA2D_StartTransfer();

/* Wait for CTC Flag activation */
while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET)
{
}

LCD_SetTextColor(CurrentTextColor);  
}

这个函数中,为什么最后要用一个 LCD_SetTextColor(CurrentTextColor)呢?
DMA2D_StartTransfer()这句不是已经把背景颜色写好了吗?

回复

使用道具 举报

 楼主| 发表于 2016-6-2 10:53:16 | 显示全部楼层
/**
* @brief  Config and Sets the color Keying.
* @param  RGBValue: Specifies the Color reference.
* @retval None
*/
void LCD_SetColorKeying(uint32_t RGBValue)
{
LTDC_ColorKeying_InitTypeDef   LTDC_colorkeying_InitStruct;

/* configure the color Keying */
LTDC_colorkeying_InitStruct.LTDC_ColorKeyBlue = 0x0000FF & RGBValue;
LTDC_colorkeying_InitStruct.LTDC_ColorKeyGreen = (0x00FF00 & RGBValue) >> 8;
LTDC_colorkeying_InitStruct.LTDC_ColorKeyRed = (0xFF0000 & RGBValue) >> 16;

if (CurrentLayer == LCD_BACKGROUND_LAYER)
{
   /* Enable the color Keying for Layer1 */
   LTDC_ColorKeyingConfig(LTDC_Layer1, &LTDC_colorkeying_InitStruct, ENABLE);
   LTDC_ReloadConfig(LTDC_IMReload);
}
else
{
   /* Enable the color Keying for Layer2 */
   LTDC_ColorKeyingConfig(LTDC_Layer2, &LTDC_colorkeying_InitStruct, ENABLE);
   LTDC_ReloadConfig(LTDC_IMReload);
}
}

这个函数是什么意思,主要是干什么的?

回复 支持 反对

使用道具 举报

发表于 2016-6-3 08:57:04 | 显示全部楼层
这函数写错了,
把这些改了:
Red_Value = (0xF800 & CurrentTextColor) >> 11;
Blue_Value = 0x001F & CurrentTextColor;
Green_Value = (0x07E0 & CurrentTextColor) >> 5;

currentTextColor 改成 Color
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-6-4 13:05:33 | 显示全部楼层
谢谢,好,我回去试试
回复 支持 反对

使用道具 举报

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

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-6-14 17:02 , Processed in 0.028916 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表