|
|
|
|
#include "lcd.h"
|
|
|
|
|
#include "stdlib.h"
|
|
|
|
|
#include "font.h"
|
|
|
|
|
#include "usart.h"
|
|
|
|
|
#include "delay.h"
|
|
|
|
|
|
|
|
|
|
//LCD<EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD>ͱ<EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
u16 POINT_COLOR=0x0000; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
u16 BACK_COLOR=0xFFFF; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//Ĭ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
_lcd_dev lcddev;
|
|
|
|
|
|
|
|
|
|
//д<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//data:<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
void LCD_WR_REG(u16 data)
|
|
|
|
|
{
|
|
|
|
|
LCD_RS_CLR;//д<EFBFBD><EFBFBD>ַ
|
|
|
|
|
LCD_CS_CLR;
|
|
|
|
|
DATAOUT(data);
|
|
|
|
|
LCD_WR_CLR;
|
|
|
|
|
LCD_WR_SET;
|
|
|
|
|
LCD_CS_SET;
|
|
|
|
|
}
|
|
|
|
|
//д<EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD_WR_DATAX<EFB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LR;
|
|
|
|
|
if(lcddev.id==0X8989)delay_us(2);//FOR 8989,<EFBFBD><EFBFBD>ʱ2us
|
|
|
|
|
t=DATAIN;
|
|
|
|
|
LCD_RD_SET;
|
|
|
|
|
LCD_CS_SET;
|
|
|
|
|
|
|
|
|
|
GPIOB->CRL=0X33333333; //PB0-7 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIOB->CRH=0X33333333; //PB8-15 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIOB->ODR=0XFFFF; //ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
//д<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//LCD_Reg:<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//LCD_RegValue:Ҫд<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
void LCD_WriteReg(u16 LCD_Reg,u16 LCD_RegValue)
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(LCD_Reg);
|
|
|
|
|
LCD_WR_DATA(LCD_RegValue);
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//LCD_Reg:<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
u16 LCD_ReadReg(u16 LCD_Reg)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c)
|
|
|
|
|
{
|
|
|
|
|
u16 r,g,b,rgb;
|
|
|
|
|
b=(c>>0)&0x1f;
|
|
|
|
|
g=(c>>5)&0x3f;
|
|
|
|
|
r=(c>>11)&0x1f;
|
|
|
|
|
rgb=(b<<11)+(g<<5)+(r<<0);
|
|
|
|
|
return(rgb);
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD>mdk -O1ʱ<EFBFBD><EFBFBD><EFBFBD>Ż<EFBFBD>ʱ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<EFBFBD><EFBFBD>ʱi
|
|
|
|
|
void opt_delay(u8 i)
|
|
|
|
|
{
|
|
|
|
|
while(i--);
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫֵ
|
|
|
|
|
//x,y:<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ:<EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
u16 LCD_ReadPoint(u16 x,u16 y)
|
|
|
|
|
{
|
|
|
|
|
u16 r,g,b;
|
|
|
|
|
if(x>=lcddev.width||y>=lcddev.height)return 0; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD>Χ,ֱ<EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
LCD_SetCursor(x,y);
|
|
|
|
|
if(lcddev.id==0X9341||lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X1963)LCD_WR_REG(0X2E);//9341/6804/3510/1963 <EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD>GRAMָ<EFBFBD><EFBFBD>
|
|
|
|
|
else if(lcddev.id==0X5510)LCD_WR_REG(0X2E00); //5510 <EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD>GRAMָ<EFBFBD><EFBFBD>
|
|
|
|
|
else LCD_WR_REG(0X22); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>IC<EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD>GRAMָ<EFBFBD><EFBFBD>
|
|
|
|
|
GPIOB->CRL=0X88888888; //PB0-7 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIOB->CRH=0X88888888; //PB8-15 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIOB->ODR=0XFFFF; //ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
LCD_RS_SET;
|
|
|
|
|
LCD_CS_CLR;
|
|
|
|
|
//<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>GRAMʱ,<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>Ϊ<EFBFBD>ٶ<EFBFBD>)
|
|
|
|
|
LCD_RD_CLR;
|
|
|
|
|
opt_delay(2); //<EFBFBD><EFBFBD>ʱ
|
|
|
|
|
r=DATAIN; //ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
LCD_RD_SET;
|
|
|
|
|
if(lcddev.id==0X1963)
|
|
|
|
|
{
|
|
|
|
|
LCD_CS_SET;
|
|
|
|
|
GPIOB->CRL=0X33333333; //PB0-7 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIOB->CRH=0X33333333; //PB8-15 <EFBFBD><EFBFBD><EFBFB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ζ<EFBFBD>ȡ<EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵֵ
|
|
|
|
|
}
|
|
|
|
|
LCD_CS_SET;
|
|
|
|
|
GPIOB->CRL=0X33333333; //PB0-7 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIOB->CRH=0X33333333; //PB8-15 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIOB->ODR=0XFFFF; //ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if(lcddev.id==0X9325||lcddev.id==0X4535||lcddev.id==0X4531||lcddev.id==0X8989||lcddev.id==0XB505)return r; //<EFBFBD>⼸<EFBFBD><EFBFBD>ICֱ<EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫֵ
|
|
|
|
|
else if(lcddev.id==0X9341||lcddev.id==0X5310||lcddev.id==0X5510)return (((r>>11)<<11)|((g>>10)<<5)|(b>>11));//ILI9341/NT35310/NT35510<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ʽת<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
|
|
|
|
else return LCD_BGR2RGB(r); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>IC
|
|
|
|
|
}
|
|
|
|
|
//LCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
void LCD_DisplayOn(void)
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.id==0X9341||lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X1963)LCD_WR_REG(0X29); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
else if(lcddev.id==0X5510)LCD_WR_REG(0X2900); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
else LCD_WriteReg(0X07,0x0173); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
}
|
|
|
|
|
//LCD<EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
void LCD_DisplayOff(void)
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.id==0X9341||lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X1963)LCD_WR_REG(0X28); //<EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
else if(lcddev.id==0X5510)LCD_WR_REG(0X2800); //<EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
else LCD_WriteReg(0X07,0x0);//<EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
//Xpos:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//Ypos:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void LCD_SetCursor(u16 Xpos, u16 Ypos)
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.id==0X9341||lcddev.id==0X5310)
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);
|
|
|
|
|
LCD_WR_DATA(Xpos>>8);LCD_WR_DATA(Xpos&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);
|
|
|
|
|
LCD_WR_DATA(Ypos>>8);LCD_WR_DATA(Ypos&0XFF);
|
|
|
|
|
}else if(lcddev.id==0X6804)
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.dir==1)Xpos=lcddev.width-1-Xpos;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);
|
|
|
|
|
LCD_WR_DATA(Xpos>>8);LCD_WR_DATA(Xpos&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);
|
|
|
|
|
LCD_WR_DATA(Ypos>>8);LCD_WR_DATA(Ypos&0XFF);
|
|
|
|
|
}else if(lcddev.id==0X1963)
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.dir==0)//x<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>任
|
|
|
|
|
{
|
|
|
|
|
Xpos=lcddev.width-1-Xpos;
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);
|
|
|
|
|
LCD_WR_DATA(0);LCD_WR_DATA(0);
|
|
|
|
|
LCD_WR_DATA(Xpos>>8);LCD_WR_DATA(Xpos&0XFF);
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);
|
|
|
|
|
LCD_WR_DATA(Xpos>>8);LCD_WR_DATA(Xpos&0XFF);
|
|
|
|
|
LCD_WR_DATA((lcddev.width-1)>>8);LCD_WR_DATA((lcddev.width-1)&0XFF);
|
|
|
|
|
}
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);
|
|
|
|
|
LCD_WR_DATA(Ypos>>8);LCD_WR_DATA(Ypos&0XFF);
|
|
|
|
|
LCD_WR_DATA((lcddev.height-1)>>8);LCD_WR_DATA((lcddev.height-1)&0XFF);
|
|
|
|
|
|
|
|
|
|
}else if(lcddev.id==0X5510)
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(Xpos>>8);
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(Xpos&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(Ypos>>8);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(Ypos&0XFF);
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.dir==1)Xpos=lcddev.width-1-Xpos;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>תx,y<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WriteReg(lcddev.setxcmd, Xpos);
|
|
|
|
|
LCD_WriteReg(lcddev.setycmd, Ypos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD<EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>ɨ<EFBFBD>跽<EFBFBD><EFBFBD>
|
|
|
|
|
//ע<EFBFBD><EFBFBD>:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>Ӱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>9341/6804<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪL2R_U2D<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɨ<EFBFBD>跽ʽ,<EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|
|
|
|
//dir:0~7,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>8<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD>嶨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>lcd.h)
|
|
|
|
|
//9320/9325/9328/4531/4535/1505/b505/5408/9341/5310/5510/1963<EFBFBD><EFBFBD>IC<EFBFBD>Ѿ<EFBFBD>ʵ<EFBFBD>ʲ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void LCD_Scan_Dir(u8 dir)
|
|
|
|
|
{
|
|
|
|
|
u16 regval=0;
|
|
|
|
|
u16 dirreg=0;
|
|
|
|
|
u16 temp;
|
|
|
|
|
if((lcddev.dir==1&&lcddev.id!=0X6804&&lcddev.id!=0X1963)||(lcddev.dir==0&&lcddev.id==0X1963))//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>6804<EFBFBD><EFBFBD>1963<EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ɨ<EFBFBD>跽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ1963<EFBFBD>ı䷽<EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
switch(dir)//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
case 0:dir=6;break;
|
|
|
|
|
case 1:dir=7;break;
|
|
|
|
|
case 2:dir=4;break;
|
|
|
|
|
case 3:dir=5;break;
|
|
|
|
|
case 4:dir=1;break;
|
|
|
|
|
case 5:dir=0;break;
|
|
|
|
|
case 6:dir=3;break;
|
|
|
|
|
case 7:dir=2;break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(lcddev.id==0x9341||lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X5510||lcddev.id==0X1963)//9341/6804/5310/5510/1963,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
switch(dir)
|
|
|
|
|
{
|
|
|
|
|
case L2R_U2D://<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(0<<7)|(0<<6)|(0<<5);
|
|
|
|
|
break;
|
|
|
|
|
case L2R_D2U://<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(1<<7)|(0<<6)|(0<<5);
|
|
|
|
|
break;
|
|
|
|
|
case R2L_U2D://<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(0<<7)|(1<<6)|(0<<5);
|
|
|
|
|
break;
|
|
|
|
|
case R2L_D2U://<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(1<<7)|(1<<6)|(0<<5);
|
|
|
|
|
break;
|
|
|
|
|
case U2D_L2R://<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(0<<7)|(0<<6)|(1<<5);
|
|
|
|
|
break;
|
|
|
|
|
case U2D_R2L://<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(0<<7)|(1<<6)|(1<<5);
|
|
|
|
|
break;
|
|
|
|
|
case D2U_L2R://<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(1<<7)|(0<<6)|(1<<5);
|
|
|
|
|
break;
|
|
|
|
|
case D2U_R2L://<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(1<<7)|(1<<6)|(1<<5);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if(lcddev.id==0X5510)dirreg=0X3600;
|
|
|
|
|
else dirreg=0X36;
|
|
|
|
|
if((lcddev.id!=0X5310)&&(lcddev.id!=0X5510)&&(lcddev.id!=0X1963))regval|=0X08;//5310/5510/1963<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪBGR
|
|
|
|
|
if(lcddev.id==0X6804)regval|=0x02;//6804<EFBFBD><EFBFBD>BIT6<EFBFBD><EFBFBD>9341<EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WriteReg(dirreg,regval);
|
|
|
|
|
if(lcddev.id!=0X1963)//1963<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>괦<EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(regval&0X20)
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.width<lcddev.height)//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>X,Y
|
|
|
|
|
{
|
|
|
|
|
temp=lcddev.width;
|
|
|
|
|
lcddev.width=lcddev.height;
|
|
|
|
|
lcddev.height=temp;
|
|
|
|
|
}
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.width>lcddev.height)//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>X,Y
|
|
|
|
|
{
|
|
|
|
|
temp=lcddev.width;
|
|
|
|
|
lcddev.width=lcddev.height;
|
|
|
|
|
lcddev.height=temp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(lcddev.id==0X5510)
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(0);
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(0);
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd+2);LCD_WR_DATA((lcddev.width-1)>>8);
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd+3);LCD_WR_DATA((lcddev.width-1)&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(0);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(0);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd+2);LCD_WR_DATA((lcddev.height-1)>>8);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd+3);LCD_WR_DATA((lcddev.height-1)&0XFF);
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);
|
|
|
|
|
LCD_WR_DATA(0);LCD_WR_DATA(0);
|
|
|
|
|
LCD_WR_DATA((lcddev.width-1)>>8);LCD_WR_DATA((lcddev.width-1)&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);
|
|
|
|
|
LCD_WR_DATA(0);LCD_WR_DATA(0);
|
|
|
|
|
LCD_WR_DATA((lcddev.height-1)>>8);LCD_WR_DATA((lcddev.height-1)&0XFF);
|
|
|
|
|
}
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
switch(dir)
|
|
|
|
|
{
|
|
|
|
|
case L2R_U2D://<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(1<<5)|(1<<4)|(0<<3);
|
|
|
|
|
break;
|
|
|
|
|
case L2R_D2U://<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(0<<5)|(1<<4)|(0<<3);
|
|
|
|
|
break;
|
|
|
|
|
case R2L_U2D://<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(1<<5)|(0<<4)|(0<<3);
|
|
|
|
|
break;
|
|
|
|
|
case R2L_D2U://<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(0<<5)|(0<<4)|(0<<3);
|
|
|
|
|
break;
|
|
|
|
|
case U2D_L2R://<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(1<<5)|(1<<4)|(1<<3);
|
|
|
|
|
break;
|
|
|
|
|
case U2D_R2L://<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(1<<5)|(0<<4)|(1<<3);
|
|
|
|
|
break;
|
|
|
|
|
case D2U_L2R://<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(0<<5)|(1<<4)|(1<<3);
|
|
|
|
|
break;
|
|
|
|
|
case D2U_R2L://<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
regval|=(0<<5)|(0<<4)|(1<<3);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
dirreg=0X03;
|
|
|
|
|
regval|=1<<12;
|
|
|
|
|
LCD_WriteReg(dirreg,regval);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//x,y:<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//POINT_COLOR:<EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
void LCD_DrawPoint(u16 x,u16 y)
|
|
|
|
|
{
|
|
|
|
|
LCD_SetCursor(x,y); //<EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WriteRAM_Prepare(); //<EFBFBD><EFBFBD>ʼд<EFBFBD><EFBFBD>GRAM
|
|
|
|
|
LCD_WR_DATA(POINT_COLOR);
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//x,y:<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//color:<EFBFBD><EFBFBD>ɫ
|
|
|
|
|
void LCD_Fast_DrawPoint(u16 x,u16 y,u16 color)
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.id==0X9341||lcddev.id==0X5310)
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);
|
|
|
|
|
LCD_WR_DATA(x>>8);LCD_WR_DATA(x&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);
|
|
|
|
|
LCD_WR_DATA(y>>8);LCD_WR_DATA(y&0XFF);
|
|
|
|
|
}else if(lcddev.id==0X5510)
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(x>>8);
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(x&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(y>>8);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(y&0XFF);
|
|
|
|
|
}else if(lcddev.id==0X1963)
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.dir==0)x=lcddev.width-1-x;
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);
|
|
|
|
|
LCD_WR_DATA(x>>8);LCD_WR_DATA(x&0XFF);
|
|
|
|
|
LCD_WR_DATA(x>>8);LCD_WR_DATA(x&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);
|
|
|
|
|
LCD_WR_DATA(y>>8);LCD_WR_DATA(y&0XFF);
|
|
|
|
|
LCD_WR_DATA(y>>8);LCD_WR_DATA(y&0XFF);
|
|
|
|
|
}else if(lcddev.id==0X6804)
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.dir==1)x=lcddev.width-1-x;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);
|
|
|
|
|
LCD_WR_DATA(x>>8);LCD_WR_DATA(x&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);
|
|
|
|
|
LCD_WR_DATA(y>>8);LCD_WR_DATA(y&0XFF);
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.dir==1)x=lcddev.width-1-x;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>תx,y<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WriteReg(lcddev.setxcmd,x);
|
|
|
|
|
LCD_WriteReg(lcddev.setycmd,y);
|
|
|
|
|
}
|
|
|
|
|
LCD_RS_CLR;
|
|
|
|
|
LCD_CS_CLR;
|
|
|
|
|
DATAOUT(lcddev.wramcmd);//дָ<EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WR_CLR;
|
|
|
|
|
LCD_WR_SET;
|
|
|
|
|
LCD_CS_SET;
|
|
|
|
|
LCD_WR_DATA(color); //д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
//SSD1963 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//pwm:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>,0~100.Խ<EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD>.
|
|
|
|
|
void LCD_SSD_BackLightSet(u8 pwm)
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(0xBE); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>PWM<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WR_DATA(0x05); //1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>PWMƵ<EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WR_DATA(pwm*2.55);//2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>PWMռ<EFBFBD>ձ<EFBFBD>
|
|
|
|
|
LCD_WR_DATA(0x01); //3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>C
|
|
|
|
|
LCD_WR_DATA(0xFF); //4<EFBFBD><EFBFBD><EFBFBD><EFBFBD>D
|
|
|
|
|
LCD_WR_DATA(0x00); //5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>E
|
|
|
|
|
LCD_WR_DATA(0x00); //6<EFBFBD><EFBFBD><EFBFBD><EFBFBD>F
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LCD<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//dir:0,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void LCD_Display_Dir(u8 dir)
|
|
|
|
|
{
|
|
|
|
|
if(dir==0) //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
lcddev.dir=0; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
lcddev.width=240;
|
|
|
|
|
lcddev.height=320;
|
|
|
|
|
if(lcddev.id==0X9341||lcddev.id==0X6804||lcddev.id==0X5310)
|
|
|
|
|
{
|
|
|
|
|
lcddev.wramcmd=0X2C;
|
|
|
|
|
lcddev.setxcmd=0X2A;
|
|
|
|
|
lcddev.setycmd=0X2B;
|
|
|
|
|
if(lcddev.id==0X6804||lcddev.id==0X5310)
|
|
|
|
|
{
|
|
|
|
|
lcddev.width=320;
|
|
|
|
|
lcddev.height=480;
|
|
|
|
|
}
|
|
|
|
|
}else if(lcddev.id==0x5510)
|
|
|
|
|
{
|
|
|
|
|
lcddev.wramcmd=0X2C00;
|
|
|
|
|
lcddev.setxcmd=0X2A00;
|
|
|
|
|
lcddev.setycmd=0X2B00;
|
|
|
|
|
lcddev.width=480;
|
|
|
|
|
lcddev.height=800;
|
|
|
|
|
}else if(lcddev.id==0X1963)
|
|
|
|
|
{
|
|
|
|
|
lcddev.wramcmd=0X2C; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>GRAM<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
lcddev.setxcmd=0X2B; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>дX<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
lcddev.setycmd=0X2A; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>дY<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
lcddev.width=480; //<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD>480
|
|
|
|
|
lcddev.height=800; //<EFBFBD><EFBFBD><EFBFBD>ø߶<EFBFBD>800
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
lcddev.wramcmd=0X22;
|
|
|
|
|
lcddev.setxcmd=0X20;
|
|
|
|
|
lcddev.setycmd=0X21;
|
|
|
|
|
}
|
|
|
|
|
}else //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
lcddev.dir=1; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
lcddev.width=320;
|
|
|
|
|
lcddev.height=240;
|
|
|
|
|
if(lcddev.id==0X9341||lcddev.id==0X5310)
|
|
|
|
|
{
|
|
|
|
|
lcddev.wramcmd=0X2C;
|
|
|
|
|
lcddev.setxcmd=0X2A;
|
|
|
|
|
lcddev.setycmd=0X2B;
|
|
|
|
|
}else if(lcddev.id==0X6804)
|
|
|
|
|
{
|
|
|
|
|
lcddev.wramcmd=0X2C;
|
|
|
|
|
lcddev.setxcmd=0X2B;
|
|
|
|
|
lcddev.setycmd=0X2A;
|
|
|
|
|
}else if(lcddev.id==0x5510)
|
|
|
|
|
{
|
|
|
|
|
lcddev.wramcmd=0X2C00;
|
|
|
|
|
lcddev.setxcmd=0X2A00;
|
|
|
|
|
lcddev.setycmd=0X2B00;
|
|
|
|
|
lcddev.width=800;
|
|
|
|
|
lcddev.height=480;
|
|
|
|
|
}else if(lcddev.id==0X1963)
|
|
|
|
|
{
|
|
|
|
|
lcddev.wramcmd=0X2C; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>GRAM<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
lcddev.setxcmd=0X2A; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>дX<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
lcddev.setycmd=0X2B; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>дY<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
lcddev.width=800; //<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD>800
|
|
|
|
|
lcddev.height=480; //<EFBFBD><EFBFBD><EFBFBD>ø߶<EFBFBD>480
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
lcddev.wramcmd=0X22;
|
|
|
|
|
lcddev.setxcmd=0X21;
|
|
|
|
|
lcddev.setycmd=0X20;
|
|
|
|
|
}
|
|
|
|
|
if(lcddev.id==0X6804||lcddev.id==0X5310)
|
|
|
|
|
{
|
|
|
|
|
lcddev.width=480;
|
|
|
|
|
lcddev.height=320;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LCD_Scan_Dir(DFT_SCAN_DIR); //Ĭ<EFBFBD><EFBFBD>ɨ<EFBFBD>跽<EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>굽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD>(sx,sy).
|
|
|
|
|
//sx,sy:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD>)
|
|
|
|
|
//width,height:<EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><EFBFBD>Ⱥ߶<EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0!!
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С:width*height.
|
|
|
|
|
void LCD_Set_Window(u16 sx,u16 sy,u16 width,u16 height)
|
|
|
|
|
{
|
|
|
|
|
u8 hsareg,heareg,vsareg,veareg;
|
|
|
|
|
u16 hsaval,heaval,vsaval,veaval;
|
|
|
|
|
u16 twidth,theight;
|
|
|
|
|
twidth=sx+width-1;
|
|
|
|
|
theight=sy+height-1;
|
|
|
|
|
if(lcddev.id==0X9341||lcddev.id==0X5310||lcddev.id==0X6804||(lcddev.dir==1&&lcddev.id==0X1963))
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);
|
|
|
|
|
LCD_WR_DATA(sx>>8);
|
|
|
|
|
LCD_WR_DATA(sx&0XFF);
|
|
|
|
|
LCD_WR_DATA(twidth>>8);
|
|
|
|
|
LCD_WR_DATA(twidth&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);
|
|
|
|
|
LCD_WR_DATA(sy>>8);
|
|
|
|
|
LCD_WR_DATA(sy&0XFF);
|
|
|
|
|
LCD_WR_DATA(theight>>8);
|
|
|
|
|
LCD_WR_DATA(theight&0XFF);
|
|
|
|
|
}else if(lcddev.id==0X1963)//1963<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
sx=lcddev.width-width-sx;
|
|
|
|
|
height=sy+height-1;
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);
|
|
|
|
|
LCD_WR_DATA(sx>>8);
|
|
|
|
|
LCD_WR_DATA(sx&0XFF);
|
|
|
|
|
LCD_WR_DATA((sx+width-1)>>8);
|
|
|
|
|
LCD_WR_DATA((sx+width-1)&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);
|
|
|
|
|
LCD_WR_DATA(sy>>8);
|
|
|
|
|
LCD_WR_DATA(sy&0XFF);
|
|
|
|
|
LCD_WR_DATA(height>>8);
|
|
|
|
|
LCD_WR_DATA(height&0XFF);
|
|
|
|
|
}else if(lcddev.id==0X5510)
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd);LCD_WR_DATA(sx>>8);
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd+1);LCD_WR_DATA(sx&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd+2);LCD_WR_DATA(twidth>>8);
|
|
|
|
|
LCD_WR_REG(lcddev.setxcmd+3);LCD_WR_DATA(twidth&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd);LCD_WR_DATA(sy>>8);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd+1);LCD_WR_DATA(sy&0XFF);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd+2);LCD_WR_DATA(theight>>8);
|
|
|
|
|
LCD_WR_REG(lcddev.setycmd+3);LCD_WR_DATA(theight&0XFF);
|
|
|
|
|
}else //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IC
|
|
|
|
|
{
|
|
|
|
|
if(lcddev.dir==1)//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
hsaval=sy;
|
|
|
|
|
heaval=theight;
|
|
|
|
|
vsaval=lcddev.width-twidth-1;
|
|
|
|
|
veaval=lcddev.width-sx-1;
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
hsaval=sx;
|
|
|
|
|
heaval=twidth;
|
|
|
|
|
vsaval=sy;
|
|
|
|
|
veaval=theight;
|
|
|
|
|
}
|
|
|
|
|
hsareg=0X50;heareg=0X51;//ˮƽ<EFBFBD><EFBFBD><EFBFBD>ڼĴ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
vsareg=0X52;veareg=0X53;//<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>ڼĴ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD>üĴ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
LCD_WriteReg(hsareg,hsaval);
|
|
|
|
|
LCD_WriteReg(heareg,heaval);
|
|
|
|
|
LCD_WriteReg(vsareg,vsaval);
|
|
|
|
|
LCD_WriteReg(veareg,veaval);
|
|
|
|
|
LCD_SetCursor(sx,sy); //<EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>lcd
|
|
|
|
|
//<EFBFBD>ó<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Գ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ALIENTEK<EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD>LCDҺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>ýϴ<EFBFBD>flash,<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ɾ<EFBFBD><EFBFBD>δ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>LCD<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.<EFBFBD>Խ<EFBFBD>ʡ<EFBFBD>ռ<EFBFBD>.
|
|
|
|
|
void LCD_Init(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO, ENABLE); //ʹ<EFBFBD><EFBFBD>PORTB,Cʱ<EFBFBD>Ӻ<EFBFBD>AFIOʱ<EFBFBD><EFBFBD>
|
|
|
|
|
// GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>SWD<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>JTAG
|
|
|
|
|
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable , ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10|GPIO_Pin_9|GPIO_Pin_8|GPIO_Pin_7|GPIO_Pin_6; ///PORTC6~10<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_Init(GPIOC, &GPIO_InitStructure); //GPIOC
|
|
|
|
|
|
|
|
|
|
GPIO_SetBits(GPIOC,GPIO_Pin_10|GPIO_Pin_9|GPIO_Pin_8|GPIO_Pin_7|GPIO_Pin_6);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; // PORTB<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOB, &GPIO_InitStructure); //GPIOB
|
|
|
|
|
|
|
|
|
|
GPIO_SetBits(GPIOB,GPIO_Pin_All);
|
|
|
|
|
|
|
|
|
|
delay_ms(50); // delay 50 ms
|
|
|
|
|
LCD_WriteReg(0x0000,0x0001);
|
|
|
|
|
delay_ms(50); // delay 50 ms
|
|
|
|
|
lcddev.id = LCD_ReadReg(0x0000);
|
|
|
|
|
if(lcddev.id<0XFF||lcddev.id==0XFFFF||lcddev.id==0X9300)//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>lcddev.id==0X9300<EFBFBD>жϣ<EFBFBD><EFBFBD><EFBFBD>Ϊ9341<EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>»ᱻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>9300
|
|
|
|
|
{
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>9341 ID<EFBFBD>Ķ<EFBFBD>ȡ
|
|
|
|
|
LCD_WR_REG(0XD3);
|
|
|
|
|
LCD_RD_DATA(); //dummy read
|
|
|
|
|
LCD_RD_DATA(); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X00
|
|
|
|
|
lcddev.id=LCD_RD_DATA(); //<EFBFBD><EFBFBD>ȡ93
|
|
|
|
|
lcddev.id<<=8;
|
|
|
|
|
lcddev.id|=LCD_RD_DATA(); //<EFBFBD><EFBFBD>ȡ41
|
|
|
|
|
if(lcddev.id!=0X9341) //<EFBFBD><EFBFBD>9341,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD>6804
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(0XBF);
|
|
|
|
|
LCD_RD_DATA(); //dummy read
|
|
|
|
|
LCD_RD_DATA(); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X01
|
|
|
|
|
LCD_RD_DATA(); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0XD0
|
|
|
|
|
lcddev.id=LCD_RD_DATA();//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X68
|
|
|
|
|
lcddev.id<<=8;
|
|
|
|
|
lcddev.id|=LCD_RD_DATA();//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X04
|
|
|
|
|
if(lcddev.id!=0X6804) //Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>6804,<EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD>NT35310
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(0XD4);
|
|
|
|
|
LCD_RD_DATA(); //dummy read
|
|
|
|
|
LCD_RD_DATA(); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X01
|
|
|
|
|
lcddev.id=LCD_RD_DATA(); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X53
|
|
|
|
|
lcddev.id<<=8;
|
|
|
|
|
lcddev.id|=LCD_RD_DATA(); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X10
|
|
|
|
|
if(lcddev.id!=0X5310) //Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>NT35310,<EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD>NT35510
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(0XDA00);
|
|
|
|
|
LCD_RD_DATA(); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X00
|
|
|
|
|
LCD_WR_REG(0XDB00);
|
|
|
|
|
lcddev.id=LCD_RD_DATA();//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X80
|
|
|
|
|
lcddev.id<<=8;
|
|
|
|
|
LCD_WR_REG(0XDC00);
|
|
|
|
|
lcddev.id|=LCD_RD_DATA();//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X00
|
|
|
|
|
if(lcddev.id==0x8000)lcddev.id=0x5510;//NT35510<EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ID<EFBFBD><EFBFBD>8000H,Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ5510
|
|
|
|
|
if(lcddev.id!=0X5510) //Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>NT5510,<EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD>SSD1963
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(0XA1);
|
|
|
|
|
lcddev.id=LCD_RD_DATA();
|
|
|
|
|
lcddev.id=LCD_RD_DATA(); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X57
|
|
|
|
|
lcddev.id<<=8;
|
|
|
|
|
lcddev.id|=LCD_RD_DATA(); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0X61
|
|
|
|
|
if(lcddev.id==0X5761)lcddev.id=0X1963;//SSD1963<EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ID<EFBFBD><EFBFBD>5761H,Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ1963
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// printf(" LCD ID:%x\r\n",lcddev.id); //<EFBFBD><EFBFBD>ӡLCD ID
|
|
|
|
|
if(lcddev.id==0X9341) //9341<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
LCD_WR_REG(0xCF);
|
|
|
|
|
LCD_WR_DATAX(0x00);
|
|
|
|
|
LCD_WR_DATAX(0xC1);
|
|
|
|
|
LCD_WR_DATAX(0X30);
|
|
|
|
|
LCD_WR_REG(0xED);
|
|
|
|
|
LCD_WR_DATAX(0x64);
|
|
|
|
|
LCD_WR_DATAX(0x03);
|
|
|
|
|
LCD_WR_DATAX(0X12);
|
|
|
|
|
LCD_WR_DATAX(0X81);
|
|
|
|
|
LCD_WR_REG(0xE8);
|
|
|
|
|
LCD_WR_DATAX(0x85);
|
|
|
|
|
LCD_WR_DATAX(0x10);
|
|
|
|
|
LCD_WR_DATAX(0x7A);
|
|
|
|
|
LCD_WR_REG(0xCB);
|
|
|
|
|
LCD_WR_DATAX(0x39);
|
|
|
|
|
LCD_WR_DATAX(0x2C);
|
|
|
|
|
LCD_WR_DATAX(0x00);
|
|
|
|
|
LCD_WR_DATAX(0x34);
|
|
|
|
|
LCD_WR_DATAX(0x02);
|
|
|
|
|
LCD_WR_REG(0xF7);
|
|
|
|
|
LCD_WR_DATAX(0x20);
|
|
|
|
|
LCD_WR_REG(0xEA);
|
|
|
|
|
LCD_WR_DATAX(0x00);
|
|
|
|
|
LCD_WR_DATAX(0x00);
|
|
|
|
|
LCD_WR_REG(0xC0); //Power control
|
|
|
|
|
LCD_WR_DATAX(0x1B); //VRH[5:0]
|
|
|
|
|
LCD_WR_REG(0xC1); //Power control
|
|
|
|
|
LCD_WR_DATAX(0x01); //SAP[2:0];BT[3:0]
|
|
|
|
|
LCD_WR_REG(0xC5); //VCM control
|
|
|
|
|
LCD_WR_DATAX(0x30); //3F
|
|
|
|
|
LCD_WR_DATAX(0x30); //3C
|
|
|
|
|
LCD_WR_REG(0xC7); //VCM control2
|
|
|
|
|
LCD_WR_DATAX(0XB7);
|
|
|
|
|
LCD_WR_REG(0x36); // Memory Access Control
|
|
|
|
|
LCD_WR_DATAX(0x48);
|
|
|
|
|
LCD_WR_REG(0x3A);
|
|
|
|
|
LCD_WR_DATAX(0x55);
|
|
|
|
|
LCD_WR_REG(0xB1);
|
|
|
|
|
LCD_WR_DATAX(0x00);
|
|
|
|
|
LCD_WR_DATAX(0x1A);
|
|
|
|
|
LCD_WR_REG(0xB6); // Display Function Control
|
|
|
|
|
LCD_WR_DATAX(0x0A);
|
|
|
|
|
LCD_WR_DATAX(0xA2);
|
|
|
|
|
LCD_WR_REG(0xF2); // 3Gamma Function Disable
|
|
|
|
|
LCD_WR_DATAX(0x00);
|
|
|
|
|
LCD_WR_REG(0x26); //Gamma curve selected
|
|
|
|
|
LCD_WR_DATAX(0x01);
|
|
|
|
|
LCD_WR_REG(0xE0); //Set Gamma
|
|
|
|
|
LCD_WR_DATAX(0x0F);
|
|
|
|
|
LCD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0x00);
|
|
|
|
|
LCD_WR_DATAX(0x00);
|
|
|
|
|
LCD_WR_DATAX(0xef);
|
|
|
|
|
LCD_WR_REG(0x11); //Exit Sleep
|
|
|
|
|
delay_ms(120);
|
|
|
|
|
LCD_WR_REG(0x29); //display on
|
|
|
|
|
}
|
|
|
|
|
LCD_Display_Dir(0); //Ĭ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
LCD_LED=1; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
LCD_Clear(WHITE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//color:Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
void LCD_Clear(u16 color)
|
|
|
|
|
{
|
|
|
|
|
u32 index=0;
|
|
|
|
|
u32 totalpoint=lcddev.width;
|
|
|
|
|
totalpoint*=lcddev.height; //<EFBFBD>õ<EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if((lcddev.id==0X6804)&&(lcddev.dir==1))//6804<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
lcddev.dir=0;
|
|
|
|
|
lcddev.setxcmd=0X2A;
|
|
|
|
|
lcddev.setycmd=0X2B;
|
|
|
|
|
LCD_SetCursor(0x00,0x0000); //<EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
lcddev.dir=1;
|
|
|
|
|
lcddev.setxcmd=0X2B;
|
|
|
|
|
lcddev.setycmd=0X2A;
|
|
|
|
|
}else LCD_SetCursor(0x00,0x0000); //<EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WriteRAM_Prepare(); //<EFBFBD><EFBFBD>ʼд<EFBFBD><EFBFBD>GRAM
|
|
|
|
|
for(index=0;index<totalpoint;index++)LCD_WR_DATA(color);
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С:(xend-xsta+1)*(yend-ysta+1)
|
|
|
|
|
//xsta
|
|
|
|
|
//color:Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
void LCD_Fill(u16 sx,u16 sy,u16 ex,u16 ey,u16 color)
|
|
|
|
|
{
|
|
|
|
|
u16 i,j;
|
|
|
|
|
u16 xlen=0;
|
|
|
|
|
u16 temp;
|
|
|
|
|
if((lcddev.id==0X6804)&&(lcddev.dir==1)) //6804<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
temp=sx;
|
|
|
|
|
sx=sy;
|
|
|
|
|
sy=lcddev.width-ex-1;
|
|
|
|
|
ex=ey;
|
|
|
|
|
ey=lcddev.width-temp-1;
|
|
|
|
|
lcddev.dir=0;
|
|
|
|
|
lcddev.setxcmd=0X2A;
|
|
|
|
|
lcddev.setycmd=0X2B;
|
|
|
|
|
LCD_Fill(sx,sy,ex,ey,color);
|
|
|
|
|
lcddev.dir=1;
|
|
|
|
|
lcddev.setxcmd=0X2B;
|
|
|
|
|
lcddev.setycmd=0X2A;
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
xlen=ex-sx+1;
|
|
|
|
|
for(i=sy;i<=ey;i++)
|
|
|
|
|
{
|
|
|
|
|
LCD_SetCursor(sx,i); //<EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WriteRAM_Prepare(); //<EFBFBD><EFBFBD>ʼд<EFBFBD><EFBFBD>GRAM
|
|
|
|
|
for(j=0;j<xlen;j++)LCD_WR_DATA(color); //<EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD>
|
|
|
|
|
//(sx,sy),(ex,ey):<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ζԽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>СΪ:(ex-sx+1)*(ey-sy+1)
|
|
|
|
|
//color:Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
void LCD_Color_Fill(u16 sx,u16 sy,u16 ex,u16 ey,u16 *color)
|
|
|
|
|
{
|
|
|
|
|
u16 height,width;
|
|
|
|
|
u16 i,j;
|
|
|
|
|
width=ex-sx+1; //<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
height=ey-sy+1; //<EFBFBD>߶<EFBFBD>
|
|
|
|
|
for(i=0;i<height;i++)
|
|
|
|
|
{
|
|
|
|
|
LCD_SetCursor(sx,sy+i); //<EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
LCD_WriteRAM_Prepare(); //<EFBFBD><EFBFBD>ʼд<EFBFBD><EFBFBD>GRAM
|
|
|
|
|
for(j=0;j<width;j++)LCD_WR_DATA(color[i*width+j]);//д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//x1,y1:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//x2,y2:<EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2)
|
|
|
|
|
{
|
|
|
|
|
u16 t;
|
|
|
|
|
int xerr=0,yerr=0,delta_x,delta_y,distance;
|
|
|
|
|
int incx,incy,uRow,uCol;
|
|
|
|
|
delta_x=x2-x1; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
delta_y=y2-y1;
|
|
|
|
|
uRow=x1;
|
|
|
|
|
uCol=y1;
|
|
|
|
|
if(delta_x>0)incx=1; //<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
else if(delta_x==0)incx=0;//<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>
|
|
|
|
|
else {incx=-1;delta_x=-delta_x;}
|
|
|
|
|
if(delta_y>0)incy=1;
|
|
|
|
|
else if(delta_y==0)incy=0;//ˮƽ<EFBFBD><EFBFBD>
|
|
|
|
|
else{incy=-1;delta_y=-delta_y;}
|
|
|
|
|
if( delta_x>delta_y)distance=delta_x; //ѡȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
else distance=delta_y;
|
|
|
|
|
for(t=0;t<=distance+1;t++ )//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
LCD_DrawPoint(uRow,uCol);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
xerr+=delta_x ;
|
|
|
|
|
yerr+=delta_y ;
|
|
|
|
|
if(xerr>distance)
|
|
|
|
|
{
|
|
|
|
|
xerr-=distance;
|
|
|
|
|
uRow+=incx;
|
|
|
|
|
}
|
|
|
|
|
if(yerr>distance)
|
|
|
|
|
{
|
|
|
|
|
yerr-=distance;
|
|
|
|
|
uCol+=incy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//(x1,y1),(x2,y2):<EFBFBD><EFBFBD><EFBFBD>εĶԽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2)
|
|
|
|
|
{
|
|
|
|
|
LCD_DrawLine(x1,y1,x2,y1);
|
|
|
|
|
LCD_DrawLine(x1,y1,x1,y2);
|
|
|
|
|
LCD_DrawLine(x1,y2,x2,y2);
|
|
|
|
|
LCD_DrawLine(x2,y1,x2,y2);
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>λ<EFBFBD>û<EFBFBD>һ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD>Բ
|
|
|
|
|
//(x,y):<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
|
|
|
|
|
//r :<EFBFBD>뾶
|
|
|
|
|
void LCD_Draw_Circle(u16 x0,u16 y0,u8 r)
|
|
|
|
|
{
|
|
|
|
|
int a,b;
|
|
|
|
|
int di;
|
|
|
|
|
a=0;b=r;
|
|
|
|
|
di=3-(r<<1); //<EFBFBD>ж<EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>õı<EFBFBD>־
|
|
|
|
|
while(a<=b)
|
|
|
|
|
{
|
|
|
|
|
LCD_DrawPoint(x0+a,y0-b); //5
|
|
|
|
|
LCD_DrawPoint(x0+b,y0-a); //0
|
|
|
|
|
LCD_DrawPoint(x0+b,y0+a); //4
|
|
|
|
|
LCD_DrawPoint(x0+a,y0+b); //6
|
|
|
|
|
LCD_DrawPoint(x0-a,y0+b); //1
|
|
|
|
|
LCD_DrawPoint(x0-b,y0+a);
|
|
|
|
|
LCD_DrawPoint(x0-a,y0-b); //2
|
|
|
|
|
LCD_DrawPoint(x0-b,y0-a); //7
|
|
|
|
|
a++;
|
|
|
|
|
//ʹ<EFBFBD><EFBFBD>Bresenham<EFBFBD>㷨<EFBFBD><EFBFBD>Բ
|
|
|
|
|
if(di<0)di +=4*a+6;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
di+=10+4*(a-b);
|
|
|
|
|
b--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD>ָ<EFBFBD><EF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FBD><EFBFBD>ֿ⣩
|
|
|
|
|
for(t=0;t<csize;t++)
|
|
|
|
|
{
|
|
|
|
|
if(size==12)temp=asc2_1206[num][t]; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1206<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
else if(size==16)temp=asc2_1608[num][t]; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1608<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
else if(size==24)temp=asc2_2412[num][t]; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2412<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
else return; //û<EFBFBD>е<EFBFBD><EFBFBD>ֿ<EFBFBD>
|
|
|
|
|
for(t1=0;t1<8;t1++)
|
|
|
|
|
{
|
|
|
|
|
if(temp&0x80)LCD_Fast_DrawPoint(x,y,POINT_COLOR);
|
|
|
|
|
else if(mode==0)LCD_Fast_DrawPoint(x,y,BACK_COLOR);
|
|
|
|
|
temp<<=1;
|
|
|
|
|
y++;
|
|
|
|
|
if(y>=lcddev.height)return; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if((y-y0)==size)
|
|
|
|
|
{
|
|
|
|
|
y=y0;
|
|
|
|
|
x++;
|
|
|
|
|
if(x>=lcddev.width)return; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//m^n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ:m^n<EFBFBD>η<EFBFBD>.
|
|
|
|
|
u32 LCD_Pow(u8 m,u8 n)
|
|
|
|
|
{
|
|
|
|
|
u32 result=1;
|
|
|
|
|
while(n--)result*=m;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD>λΪ0,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
//x,y :<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//len :<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
//size:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
//color:<EFBFBD><EFBFBD>ɫ
|
|
|
|
|
//num:<EFBFBD><EFBFBD>ֵ(0~4294967295);
|
|
|
|
|
void LCD_ShowNum(u16 x,u16 y,u32 num,u8 len,u8 size)
|
|
|
|
|
{
|
|
|
|
|
u8 t,temp;
|
|
|
|
|
u8 enshow=0;
|
|
|
|
|
for(t=0;t<len;t++)
|
|
|
|
|
{
|
|
|
|
|
temp=(num/LCD_Pow(10,len-t-1))%10;
|
|
|
|
|
if(enshow==0&&t<(len-1))
|
|
|
|
|
{
|
|
|
|
|
if(temp==0)
|
|
|
|
|
{
|
|
|
|
|
LCD_ShowChar(x+(size/2)*t,y,' ',size,0);
|
|
|
|
|
continue;
|
|
|
|
|
}else enshow=1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
LCD_ShowChar(x+(size/2)*t,y,temp+'0',size,0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD>λΪ0,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
//x,y:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//num:<EFBFBD><EFBFBD>ֵ(0~999999999);
|
|
|
|
|
//len:<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>)
|
|
|
|
|
//size:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
//mode:
|
|
|
|
|
//[7]:0,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;1,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0.
|
|
|
|
|
//[6:1]:<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//[0]:0,<EFBFBD>ǵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ;1,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ.
|
|
|
|
|
void LCD_ShowxNum(u16 x,u16 y,u32 num,u8 len,u8 size,u8 mode)
|
|
|
|
|
{
|
|
|
|
|
u8 t,temp;
|
|
|
|
|
u8 enshow=0;
|
|
|
|
|
for(t=0;t<len;t++)
|
|
|
|
|
{
|
|
|
|
|
temp=(num/LCD_Pow(10,len-t-1))%10;
|
|
|
|
|
if(enshow==0&&t<(len-1))
|
|
|
|
|
{
|
|
|
|
|
if(temp==0)
|
|
|
|
|
{
|
|
|
|
|
if(mode&0X80)LCD_ShowChar(x+(size/2)*t,y,'0',size,mode&0X01);
|
|
|
|
|
else LCD_ShowChar(x+(size/2)*t,y,' ',size,mode&0X01);
|
|
|
|
|
continue;
|
|
|
|
|
}else enshow=1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
LCD_ShowChar(x+(size/2)*t,y,temp+'0',size,mode&0X01);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<EFBFBD><EFBFBD>ʾ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//x,y:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//width,height:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
//size:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
//*p:<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ
|
|
|
|
|
void LCD_ShowString(u16 x,u16 y,u16 width,u16 height,u8 size,u8 *p)
|
|
|
|
|
{
|
|
|
|
|
u8 x0=x;
|
|
|
|
|
width+=x;
|
|
|
|
|
height+=y;
|
|
|
|
|
while((*p<='~')&&(*p>=' '))//<EFBFBD>ж<EFBFBD><EFBFBD>Dz<EFBFBD><EFBFBD>ǷǷ<EFBFBD><EFBFBD>ַ<EFBFBD>!
|
|
|
|
|
{
|
|
|
|
|
if(x>=width){x=x0;y+=size;}
|
|
|
|
|
if(y>=height)break;//<EFBFBD>˳<EFBFBD>
|
|
|
|
|
LCD_ShowChar(x,y,*p,size,0);
|
|
|
|
|
x+=size/2;
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|