📄 lcd1.c
字号:
else
{
for(Cursor_X=X0;Cursor_X<=X1;Cursor_X++)
{
Cursor_Y=(int)((double)(Cursor_X-X0)*k+(double)Y0);
Lcd_Point(Cursor_X,Cursor_Y);
}
}
}
else
{
k=((double)X1-(double)X0)/((double)Y1-(double)Y0);
if (Y0>Y1)
{
for(Cursor_Y=Y1;Cursor_Y<=Y0;Cursor_Y++)
{
Cursor_X=(int)((double)(Cursor_Y-Y1)*k+(double)X1);
Lcd_Point(Cursor_X,Cursor_Y);
}
}
else
{
for(Cursor_Y=Y0;Cursor_Y<=Y1;Cursor_Y++)
{
Cursor_X=(int)((double)(Cursor_Y-Y0)*k+(double)X0);
Lcd_Point(Cursor_X,Cursor_Y);
}
}
}
}
/*==============================================*/
/************************************************/
/* */
/* Lcd_Cctw: 写点阵字符子程序 */
/* */
/* Row: 行坐标<0-29(240/8-1)> */
/* Column: 列坐标<0-39(320/8-1)> */
/* (Dot1,Dot2): 点阵格式 */
/* (eg:8x8,8x16,16x16,16x32,...) */
/* Data_Add: 点阵数据首址 */
/* Flag: 反显标志 */
/* Flag=Normal 正常显示 */
/* Flag=Abnormal 反白显示 */
/* */
/************************************************/
void Lcd_Cctw(unsigned int Row,unsigned int Column,unsigned int Dot1,unsigned int Dot2,pointer *Data_Add,unsigned int Flag)
{
unsigned int Cursor_X,Cursor_Y;
unsigned int Counter1,Counter2;
Cursor_X=((Row<<3)*Lcd_AP+Column+0x4000)&0x00ff;
Cursor_Y=(((Row<<3)*Lcd_AP+Column+0x4000)&0xff00)>>8;
Lcd_wc=CSRDIR_DW; wait();
for(Counter2=0;Counter2<(Dot1>>3);Counter2++)
{
Lcd_wc=CSRW; wait();
Lcd_wd=Cursor_X; wait();
Lcd_wd=Cursor_Y; wait();
Lcd_wc=MWRITE; wait();
for(Counter1=0;Counter1<Dot2;Counter1++)
{
if(Flag==Abnormal)
{
Lcd_wd=~(*(Data_Add++));
wait();
}
else
{
Lcd_wd=*(Data_Add++);
wait();
}
}
Cursor_X++;
}
}
/*==============================================*/
/************************************************/
/* */
/* Lcd_Character: 显示8x8点阵Ascii码 */
/* */
/* Row: 行坐标<0-29(240/8-1)> */
/* Column: 列坐标<0-39(320/8-1)> */
/* Character: Ascii码 */
/* */
/************************************************/
void Lcd_Character(unsigned int Row,unsigned int Column,unsigned int Character)
{
unsigned int Cursor_X,Cursor_Y;
Cursor_X=(Row*Lcd_AP+Column+0x0000)&0x00ff;
Cursor_Y=((Row*Lcd_AP+Column+0x0000)&0xff00)>>8;
Lcd_wc=CSRDIR_RG; wait();
Lcd_wc=CSRW; wait();
Lcd_wd=Cursor_X; wait();
Lcd_wd=Cursor_Y; wait();
Lcd_wc=MWRITE; wait();
Lcd_wd=Character; wait();
}
/*==============================================*/
/************************************************/
/* */
/* Lcd_Ascii: 显示8x16点阵Ascii码 */
/* */
/* Row: 行坐标<0-29(240/8-1)> */
/* Column: 列坐标<0-39(320/8-1)> */
/* Character: Ascii码 */
/* Flag: 反显标志 */
/* Flag=Normal 正常显示 */
/* Flag=Abnormal 反白显示 */
/* */
/************************************************/
void Lcd_Ascii(unsigned int Row,unsigned int Column,unsigned int Character,unsigned int Flag)
{
pointer *Data_Add;
Data_Add=Ascii+((Character-0x20)<<4);
Lcd_Cctw(Row,Column,8,16,Data_Add,Flag);
}
/*==============================================*/
/************************************************/
/* */
/* Lcd_Out_Bmp: 显示位图子程序 */
/* Dot_X: x坐标(0-319) */
/* Dot_Y: y坐标(0-239) */
/* (Dot1,Dot2): 位图点阵格式 */
/* Data_Add: 位图数据首地址 */
/* Flag: 反显标志 */
/* Flag=Normal 正常显示 */
/* Flag=Abnormal 反白显示 */
/* */
/************************************************/
void Lcd_Out_Bmp(unsigned int Dot_X,unsigned int Dot_Y,unsigned int Dot1,unsigned int Dot2,pointer *Data_Add,unsigned int Flag)
{
unsigned int Cursor_X,Cursor_Y;
unsigned int Counter1,Counter2;
Cursor_X=(Dot_Y*Lcd_AP+(Dot_X>>3)+0x4000)&0x00ff;
Cursor_Y=((Dot_Y*Lcd_AP+(Dot_X>>3)+0x4000)&0xff00)>>8;
Lcd_wc=CSRDIR_RG; wait();
for(Counter2=0;Counter2<Dot2;Counter2++)
{
Lcd_wc=CSRW; wait();
Lcd_wd=Cursor_X; wait();
Lcd_wd=Cursor_Y; wait();
Lcd_wc=MWRITE; wait();
for(Counter1=0;Counter1<(Dot1>>3);Counter1++)
{
if(Flag==Abnormal)
{
Lcd_wd=~(*(Data_Add++));
wait();
}
else
{
Lcd_wd=*(Data_Add++);
wait();
}
}
Cursor_Y=Cursor_Y+((Cursor_X+Lcd_AP)>>8);
Cursor_X=(Cursor_X+Lcd_AP)&0x00ff;
}
}
/*==============================================*/
/************************************************/
/* */
/* Lcd_Real: 显示实型数子程序 */
/* (8x8点阵) */
/* Row: 行坐标<0-29(240/8-1)> */
/* Column: 列坐标<0-39(320/8-1)> */
/* Real_Data: 实型数 */
/* Dot_Bit: 显示有效位数 */
/* */
/************************************************/
void Lcd_Real(unsigned int Row,unsigned int Column,double Real_Data,unsigned int Dot_Bit)
{
int Dis_Data[20];
int Counter=1;
int Dot_Flag=0;
if (Real_Data<0)
{
Dis_Data[0]='-';
Real_Data=fabs(Real_Data);
}
else Dis_Data[0]=' ';
while (Real_Data>=10.0)
{
Real_Data=Real_Data/10.0;
Dot_Flag++;
Counter=1;
}
while (Real_Data<1)
{
Real_Data=Real_Data*10.0;
Dis_Data[1]='0';
Dis_Data[2]='.';
Counter=3-Dot_Flag;
Dis_Data[Counter]='0';
Dot_Flag--;
}
for (Counter=Counter;Counter<=(Dot_Bit+1);Counter++)
{
Dis_Data[Counter]=(int)Real_Data+0x30;
Real_Data=(Real_Data-(Dis_Data[Counter]-0x30))*10.0;
if (Dot_Flag==0)
{
Counter=Counter+1;
Dis_Data[Counter]='.';
}
Dot_Flag--;
}
for (Counter=0;Counter<Dot_Bit+2;Counter++)
Lcd_Character(Row,Column++,Dis_Data[Counter]);
}
/*==============================================*/
/************************************************/
/* */
/* Lcd_Exp: 科学计数法显示实型数 */
/* 子程序(8x8点阵) */
/* Row: 行坐标<0-29(240/8-1)> */
/* Column: 列坐标<0-39(320/8-1)> */
/* Real_Data: 实型数 */
/* Dot_Bit: 显示有效位数 */
/* */
/************************************************/
void Lcd_Exp(unsigned int Row,unsigned int Column,double Real_Data,unsigned int Dot_Bit)
{
int Dis_Data[20];
int Counter=1;
int Dot_Flag=0;
if (Real_Data<0)
{
Dis_Data[0]='-';
Real_Data=fabs(Real_Data);
}
else Dis_Data[0]=' ';
while (Real_Data>=10.0)
{
Real_Data=Real_Data/10.0;
Dot_Flag++;
}
while (Real_Data<1)
{
Real_Data=Real_Data*10.0;
Dot_Flag--;
}
for (Counter=1;Counter<=(Dot_Bit+1);Counter++)
{
Dis_Data[Counter]=(int)Real_Data+0x30;
Real_Data=(Real_Data-(Dis_Data[Counter]-0x30))*10.0;
if (Counter==1)
{
Counter=Counter+1;
Dis_Data[Counter]='.';
}
}
Dis_Data[Counter]='e';
if (Dot_Flag<0)
{
Dot_Flag=-1*Dot_Flag;
Dis_Data[Counter+1]='-';
Dis_Data[Counter+2]=Dot_Flag/10+0x30;
Dis_Data[Counter+3]=Dot_Flag-(Dot_Flag/10*10)+0x30;
}
else if (Dot_Flag>0)
{
Dis_Data[Counter+1]='+';
Dis_Data[Counter+2]=Dot_Flag/10+0x30;
Dis_Data[Counter+3]=Dot_Flag-(Dot_Flag/10*10)+0x30;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -