📄 lcd.c
字号:
/*void LCD_PutHZ(unsigned char x,unsigned char y,char *ptr)
{
LCD_Goto(x,y);
LCD_WriteData(*ptr);
ptr++;
LCD_WriteData(*ptr);
}
*/
/**************************************************************************
------向LCD指定位置写字符串子程序------------------------------------------
***************************************************************************
说明:入口参数:坐标,坐标,待写字符口串
出口参数:成功与否
***************************************************************************/
void LCD_Printf(unsigned char x,unsigned char y,char *ptr)
{unsigned char i;
LCD_Goto(x,y);
_nop_();
for(i=0;*(ptr+i)!=0;i++)
LCD_WriteData(*(ptr+i));
}
//********************************************************************
//向lcd中连续写入半角字符,主要用于十进制数值的字符显示
//入口参数:x坐标,y坐标,半角(数字字符)
//*********************************************************************
/*void LCD_PutData(unsigned char x,unsigned char y, char *ch)
{static char chh[2];
if (cc==0)
{LCD_Goto(x,y);
LCD_WriteData(*ch);
chh[0]=*ch;
cc=1;
}
else
{chh[1]=*ch;
cc=0;
LCD_Goto(x,y);
LCD_WriteData(*chh);
LCD_WriteData(*(chh+1));
}
} */
//***********************************************
//显示十进制数字
//入口参数:坐标,坐标,显示的数据
//由于定义的数据的限制,十进制数据长度最长为9位
//****************************
/*void LCD_PutDec(unsigned char x,unsigned char y, unsigned long decdata)
{unsigned char dat[Declenth];
unsigned char i,j;
for(i=0;i<Declenth;i++)
{dat[i]=decdata%10;
decdata=decdata/10;
}
for(i=Declenth;i>0;i--)
{if(dat[i-1]>0){j=i;break;}
}
for(i=Declenth;i>j;i--){LCD_PutData(x,(Declenth-i)/2+y,character+11);Delay1ms(1);
}
for(i=j;i>0;i--)
{LCD_PutData(x,(Declenth-i)/2+y,character+dat[i-1]);Delay1ms(1);
}
cc=0;
} */
//*****************************************************************
//显示浮点型的十进制数值
//入口参数:坐标,坐标,数值
//整数和小数部分的长度在lcd.h文件中定义 ,由于定义的数据的限制,小数和整数的长度最长为9位
//N=(unsigned long)floatdata;floatdata赋予小数部分的值再将小数点移至右边;Dp=(unsigned long)floatdata;
//******************************************
/*void LCD_PutFloat(unsigned char x,unsigned char y, float floatdata)
{unsigned char datN[FloatNlenth];
unsigned char datDp[FloatDplenth];
unsigned char datNDp[FloatLenth];
unsigned char i,j;
unsigned long N;
unsigned long Dp;
N=(unsigned long)floatdata;
floatdata=floatdata-N; //取出小数部分
for(i=0;i<FloatNlenth;i++) //取出整数部分按由高到低的顺序存入datN[0]到datN[FloatNlenth-1]
{datN[FloatNlenth-i-1]=N%10;N=N/10;}
for(i=0;i<FloatDplenth;i++) //将小数数部分按由高到低的顺序存入datDp[0]到datDp[FloatDplenth-1]
{floatdata=10*floatdata;}
Dp=(unsigned long)floatdata; //Dp最多为9位
for(i=0;i<FloatDplenth;i++){datDp[FloatDplenth-i-1]=Dp%10;Dp=Dp/10;}
for(i=0;i<FloatNlenth;i++){datNDp[i]=datN[i];}//按整数 小数点 小数 的连接顺序存入datNDp数组中
datNDp[i]=10; i=i+1;
for(;i<FloatNlenth+FloatDplenth+1;i++)
{j=i-FloatNlenth-1;
datNDp[i]=datDp[j];
}
//在指定位置依次显示数字
j=0;
for(i=0;i<FloatNlenth-1;i++){if(datNDp[i]>0){j=i;break;}}
if(j>0)
{for(i=0;i<j;i++){datNDp[i]=11;}}
for(i=1;i<FloatLenth+1;i++){LCD_PutData(x,(i-1)/2+y,character+datNDp[i-1]);Delay1ms(1);}
cc=0;//cc=0初始化函数 LCD_PutData;
}
*/
/**************************************************************************
------图形文本方式变换子程序-----------------------------------------------
***************************************************************************
说明:入口参数:液晶显示方式0:文本;1:图形
出口参数:无
***************************************************************************/
/*void LCD_ChangMode(unsigned char mode)
{
switch(mode)
{
case 0:
{
FUNCTION_BASIC();
LCD_DISP_ON();
break;
}
case 1:
{
LCD_CURSOR_OFF();
FUNCTION_EXTEND();
LCD_GRAPH_CLEAR();
LCD_GRAPH_ON();
break;
}
default:
break;
}
}
*/
/************************************************************************
-------图形方式下坐标变换子程序------------------------------------------
*************************************************************************
说明:入口参数:坐标,坐标
出口参数:是否成功
************************************************************************/
/*unsigned char LCD_CoorShift(unsigned char x,unsigned char y)
{
x=x-1;y=y-1;
x=x>>4;
if(x<0||x>8) return ERR;
if(y>=0&&y<32)
{
LCD_WriteCommand(0x80+y);
LCD_WriteCommand(0x80+x);
}
else
{
LCD_WriteCommand(0x80+y-32);
LCD_WriteCommand(0x80+x+8);
}
}
code unsigned short Position[]={0x8000,0x4000,0x2000,0x1000,
0x0800,0x0400,0x0200,0x0100,
0x0080,0x0040,0x0020,0x0010,
0x0008,0x0004,0x0002,0x0001
}; */
/************************************************************************
-------图形方式下画点子程序------------------------------------------
*************************************************************************
说明:入口参数:坐标,坐标
出口参数:无
************************************************************************/
/*void LCD_PutPiex(unsigned char x,unsigned char y)
{unsigned short temp;
unsigned char temp_H,temp_L;
LCD_CoorShift(x,y);
x=x-1;
x=x%16;
temp=Position[x];
temp_L=temp&0x00ff;
temp_H=(temp>>8)&0x00ff;
// temp_H|=LCD_ReadData();
// temp_L|=LCD_ReadData();
LCD_WriteData(temp_H);
LCD_WriteData(temp_L);
}
*/
/************************************************************************
-------图形方式下打印BMP图画子程序------------------------------------------
*************************************************************************
说明:入口参数:图画的点数组指针
出口参数:无
************************************************************************/
/*void LCD_PutBMP(unsigned char *ptr)
{unsigned char i,j;
for(i=0;i<0x20;i++)
{for(j=0;j<8;j++)
{
LCD_WriteCommand(0x80+i);
LCD_WriteCommand(0x80+j);
LCD_WriteData(*ptr);
ptr++;
LCD_WriteData(*ptr);
ptr++;
}
}
for(i=0;i<0x20;i++)
{for(j=0;j<8;j++)
{
LCD_WriteCommand(0x80+i);
LCD_WriteCommand(0x80+j+8);
LCD_WriteData(*ptr++);
LCD_WriteData(*ptr++);
}
}
} */
/************************************************************************
-------图形方式下WINDOWS窗口子程序---------------------------------------
*************************************************************************
说明:入口参数:TITLE OF THE WINDOWS
出口参数:无
************************************************************************/
/*void WindowsFront(unsigned char *ptr)
{
LCD_CLEAR();
Delay1ms(100);
LCD_ChangMode(1);
LCD_PutBMP(WindowsFronts);
Delay1ms(100);
LCD_ChangMode(0);
LCD_CURSOR_OFF();
LCD_Printf(1,1,ptr);
} */
/***********************************************************************
------变量值显示函数-------------------------
说明:将变量的值显示到指定的位置
入口参数:显示起始位置,要显示的变量
出口参数:无
***********************************************************************/
/*void LCD_Put_Varib(unsigned char x,unsigned char y, float variable)
{
unsigned char i;
unsigned char dispbuf[7]={0};
LCD_Goto ( (x-1), y );
if(variable<0)
{
variable=-variable;// print "-"
LCD_WriteData(45);
}
LCD_Goto(x,y);
dispbuf[0]=variable/10000; // divide the data into bit;
dispbuf[1]=(variable-dispbuf[0]*10000)/1000;
dispbuf[2]=(variable-dispbuf[0]*10000-dispbuf[1]*1000)/100;
dispbuf[3]=(variable-dispbuf[0]*10000-dispbuf[1]*1000-dispbuf[2]*100)/10;
dispbuf[4]=variable-dispbuf[0]*10000-dispbuf[1]*1000-dispbuf[2]*100-dispbuf[3]*10;
dispbuf[5]=(variable-dispbuf[0]*10000-dispbuf[1]*1000-dispbuf[2]*100-dispbuf[3]*10-dispbuf[4])/0.1;
dispbuf[6]=(variable-dispbuf[0]*10000-dispbuf[1]*1000-dispbuf[2]*100-dispbuf[3]*10-dispbuf[4]-dispbuf[5]*0.1)/0.01;
for(i=0;i<6;i++) // 找出第一个不是0的位数;
{
if(dispbuf[i]==0)
continue;
else
break;
}
for(;i<7;i++)
{
if(dispbuf[i]!=0)
{
dispbuf[i]=tbl[ dispbuf[i] ];
LCD_Goto(x, (y+i ));
LCD_WriteData(dispbuf[i]);
}
}
} */
/***************************************************/
//---------------清屏子函数--------------------------
//入口参数:无
//出口参数:无
/***************************************************/
void LCD_Clear (void)
{
LCD_CLEAR();
Delay1ms(200);
}
/***************************************************/
//---------------关闭光标函数--------------------------
//入口参数:无
//出口参数:无
/***************************************************/
void LCD_CursorOff(void)
{
LCD_CURSOR_OFF();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -