小学生
最后登录1970-1-1
在线时间 小时
注册时间2021-7-7
|
能够读到ID,但是我往LCD画个矩形图,图形能够显示出来,但是内部填充的颜色除了白色和黑色,使用其余颜色就会一直闪烁!!!新人小白,求各位大神指教!
LCD.C
void LCD_WriteReg(uint16_t cmd,uint16_t date)
{
*(__IO uint16_t*)(LCD_DATE_Addr)=date;
*(__IO uint16_t*)(LCD_CMD_Addr)=cmd;
}
//写数据
void LCD_Write_Date(uint16_t date)
{
__IO uint16_t *p=(__IO uint16_t*)(LCD_DATE_Addr);
*p=date;
}
//写指令
void LCD_WR_REG(uint16_t cmd)
{
__IO uint16_t *p=(__IO uint16_t*)(LCD_CMD_Addr);
*p=cmd;
}
//读数据Y
uint16_t LCD_Read_Date(void)
{
__IO uint16_t *p=(__IO uint16_t*)(LCD_DATE_Addr);
return *p;
}
//读指令
uint16_t LCD_Read_CMD(void)
{
__IO uint16_t *p=(__IO uint16_t*)(LCD_CMD_Addr);
return *p;
}
//开背光
void LCD_BackLight(uint8_t state)
{
if(state==1)
GPIO_SetBits(GPIOB,GPIO_Pin_15);
else
GPIO_ResetBits(GPIOB,GPIO_Pin_15);
}
//读取id
uint16_t LCD_GET_ID(void)
{
u16 id=0;
LCD_WR_REG(0XDA00);
id=LCD_Read_Date();
LCD_WR_REG(0XDB00);
id=LCD_Read_Date();
id<<=8;
LCD_WR_REG(0XDc00);
id|=LCD_Read_Date();
if(id==0x8000)id=0x5510;
return id;
}
//画矩形
void LCD_Draw_Rect(uint16_t x0,uint16_t x1,uint16_t y0,uint16_t y1,uint16_t color)
{
u16 i=0;
LCD_WR_REG(0x2a00);
LCD_Write_Date((x0>>8)&0xff);
LCD_WR_REG(0x2a01);
LCD_Write_Date(x0&0xff);
LCD_WR_REG(0x2a02);
LCD_Write_Date((x1>>8)&0xff);
LCD_WR_REG(0x2a03);
LCD_Write_Date(x1&0xff);
LCD_WR_REG(0x2b00);
LCD_Write_Date((y0>>8)&0xff);
LCD_WR_REG(0x2b01);
LCD_Write_Date(y0&0xff);
LCD_WR_REG(0x2b02);
LCD_Write_Date((y1>>8)&0xff);
LCD_WR_REG(0x2b03);
LCD_Write_Date(y1&0xff);
LCD_WR_REG(0x2c00);
for(i=0;i<((x1-x0+1)*(y1-y0+1));i++)
{
LCD_Write_Date(color);
}
}
main.c
int main(void)
{
delay_init(168);
LCD_Init();
LCD_REG_Config();
LCD_BackLight(1);
uart_init(115200); //3õê¼»ˉ′®¿ú2¨ìØÂêÎa115200
while(1)
{
LCD_Draw_Rect(0,496,0,800,RED);
}
}
|
|