📄 ch452_lcd.c~
字号:
********************************************************************/
void Draw_Pic_Clear(void)
{
uchar i, j, temp_x, temp_y;
W_1byte(0,0,0x34); //8BIT控制界面,扩充指令集,,绘图显示OFF
temp_x = 0x80;
temp_y = 0x80;
for(i=0;i<32;i++ )
{
W_1byte(0,0,temp_y++);//设置绘图区的Y地址坐标
W_1byte(0,0,temp_x);//设置绘图区的X地址坐标
for(j=0;j<16;j++)
{
W_1byte(0,1,0x00);
}
}
temp_x = 0x88;
temp_y = 0x80;
j = 0;
for(;i<64;i++ )
{
W_1byte(0,0,temp_y++);//设置绘图区的Y地址坐标
W_1byte(0,0,temp_x);//设置绘图区的X地址坐标
for(j=0;j<16;j++)
{
W_1byte(0,1,0x00);
}
}
W_1byte(0,0,0x36);//8BIT控制界面,扩充指令集,,绘图显示OFF
}
/********************************************************************
函 数 名:Draw_Pic_Logo
入口参数:*Draw
出口参数:无
建立日期:2007年8月18日
修改日期:
函数作用:显示启动画面
说 明:
********************************************************************/
void Draw_Pic_Logo(flash uchar *Draw)
{
uchar i, j, temp_x, temp_y;
W_1byte(0,0,0x34); //8BIT控制界面,扩充指令集,,绘图显示OFF
temp_x = 0x80;
temp_y = 0x80;
for(i=0;i<32;i++ )
{
W_1byte(0,0,temp_y++);//设置绘图区的Y地址坐标
W_1byte(0,0,temp_x);//设置绘图区的X地址坐标
for(j=0;j<16;j++)
{
W_1byte(0,1,*Draw);
Draw++;
}
}
W_1byte(0,0,0x36);//8BIT控制界面,扩充指令集,,绘图显示OFF
}
/********************************************************************
函 数 名:Draw_Pic_LogoBar
入口参数:无
出口参数:无
建立日期:2007年8月18日
修改日期:
函数作用:显示进度条
说 明:
********************************************************************/
void Draw_Pic_LogoBar(void)
{
uchar j, temp_x, temp_y;
W_1byte(0,0,0x36); //8BIT控制界面,扩充指令集,,绘图显示OFF
temp_x = 0x88;
temp_y = 0x90;
W_1byte(0,0,temp_y);//设置绘图区的Y地址坐标
W_1byte(0,0,temp_x);//设置绘图区的X地址坐标
for(j=0;j<16;j++)
{
W_1byte(0,1,0xFF);
Delay(20);
}
W_1byte(0,0,0x36);//8BIT控制界面,扩充指令集,,绘图显示OFF
}
/********************************************************************
函 数 print_root_page
入口参数:无
出口参数:无
建立日期:2007年8月16日
修改日期:
函数作用:在LCD上显示主菜单
说 明:
********************************************************************/
void print_root_page(void)
{
LCD_Clear();//清屏
LCD_set_xy(0,1);
LCD_Display(menu);
LCD_set_xy(1,0);
LCD_Display(menu1);
LCD_set_xy(1,4);
LCD_Display(menu2);
LCD_set_xy(2,0);
LCD_Display(menu3);
LCD_set_xy(2,4);
LCD_Display(menu4);
LCD_set_xy(3,0);
LCD_Display(menu5);
LCD_set_xy(3,4);
LCD_Display(menu6);
menu_statu=100;
}
/********************************************************************
函 数 print_sub1_page
入口参数:无
出口参数:无
建立日期:2007年8月16日
修改日期:
函数作用:在LCD上显示主菜单1的子菜单
说 明:
********************************************************************/
void print_sub1_page(void)
{
LCD_Clear();//清屏
LCD_set_xy(0,1);
LCD_Display(menu10);
LCD_set_xy(1,0);
LCD_Display(menu11);
LCD_set_xy(2,0);
LCD_Display(menu12);
}
void print_sub2_page(void)
{
LCD_Clear();//清屏
LCD_set_xy(0,1);
LCD_Display(menu20);
LCD_set_xy(1,0);
LCD_Display(menu21);
LCD_set_xy(2,0);
LCD_Display(menu22);
LCD_set_xy(3,0);
LCD_Display(menu23);
}
void print_sub3_page(void)
{
LCD_Clear();//清屏
LCD_set_xy(0,1);
LCD_Display(menu30);
LCD_set_xy(1,0);
LCD_Display(menu31);
}
void print_sub4_page(void)
{
LCD_Clear();//清屏
LCD_set_xy(0,1);
LCD_Display(menu40);
LCD_set_xy(1,0);
LCD_Display(menu41);
}
void print_sub1_1_page(void)
{
LCD_Clear();//清屏
//输入坐标值使能
input_position=1;
count=0;
/*
LCD_Clear();//清屏
LCD_set_xy(1,0);
LCD_Display(label_x_position);
LCD_set_xy(2,0);
LCD_Display(label_y_position);
for(;i<999;i++)
{
showXY(i);
Delay(10);
}
*/
}
void print_sub1_2_page(void)
{
LCD_Clear();//清屏
//输入坐标值使能
input_banjing=1;
count=0;
}
void print_sub4_1_page(uint X,uint Y)
{
LCD_set_xy(2,0);
LCD_Display(label_y_position);
LCD_set_xy(1,0);
LCD_Display(label_x_position);
showXY(X,Y);
Delay(100);
}
/********************************************************************
函 数 名:showXY
入口参数:position_x,uint position_y
出口参数:无
建立日期:2007年8月15日
修改日期:
函数作用:显示position_x,uint position_y,即当前画笔的位置
说 明:
********************************************************************/
void showXY(uint position_x,uint position_y)
{
uchar bai=0,shi=0,ge=0;
bai=position_x/100;
position_x=position_x%100;
shi=position_x/10;
position_x=position_x%10;
ge=position_x;
LCD_set_xy(1,4);
W_1byte(0,1,temp[bai]);
LCD_set_xy(1,5);
W_1byte(0,1,temp[shi]);
LCD_set_xy(1,6);
W_1byte(0,1,temp[ge]);
bai=0,shi=0,ge=0;
bai=position_y/100;
position_x=position_y%100;
shi=position_y/10;
position_x=position_y%10;
ge=position_y;
LCD_set_xy(2,4);
W_1byte(0,1,temp[bai]);
LCD_set_xy(2,5);
W_1byte(0,1,temp[shi]);
LCD_set_xy(2,6);
W_1byte(0,1,temp[ge]);
}
/********************************************************************
函 数 名:input
入口参数:无
出口参数:无
建立日期:2007年8月19日
修改日期:
函数作用:输入数据
说 明:
********************************************************************/
void input(void)
{
//输入坐标数据
if(input_position==1)
{
if(count==6)
{
W_1byte(0,1,temp[postion]);
W_1byte(0,0,0x0C); //关光标
temp_y_position=temp_y_position+postion;
}
if(count==5)
{
W_1byte(0,1,temp[postion]);
LCD_set_xy(2,6);
count++;
temp_y_position=temp_y_position+postion*10;
}
if(count==4)
{
W_1byte(0,1,temp[postion]);
LCD_set_xy(2,5);
count++;
temp_y_position=postion*100;
}
if(count==3)
{
W_1byte(0,1,temp[postion]);
LCD_set_xy(2,4);
count++;
temp_x_position=temp_x_position+postion;
}
if(count==2)
{
W_1byte(0,1,temp[postion]);
LCD_set_xy(1,6);
count++;
temp_x_position=temp_x_position+postion*10;
}
if(count==1)
{
W_1byte(0,1,temp[postion]);
LCD_set_xy(1,5);
count++;
temp_x_position=postion*100;
}
if(count==0)
{
LCD_set_xy(1,0);
LCD_Display(label_x_position);
LCD_set_xy(2,0);
LCD_Display(label_y_position);
LCD_set_xy(1,4);
W_1byte(0,0,0x0E); //开光标
count++;
}
}
//输入半径数据
if(input_banjing==1)
{
if(count==3)
{
W_1byte(0,1,temp[postion]);
W_1byte(0,0,0x0C); //关光标
temp_banjing=temp_banjing+postion;
}
if(count==2)
{
W_1byte(0,1,temp[postion]);
LCD_set_xy(1,6);
count++;
temp_banjing=temp_banjing+postion*10;
}
if(count==1)
{
W_1byte(0,1,temp[postion]);
LCD_set_xy(1,5);
count++;
temp_banjing=postion*100;
}
if(count==0)
{
LCD_set_xy(1,0);
LCD_Display(label_banjing);
LCD_set_xy(1,4);
W_1byte(0,0,0x0E); //开光标
count++;
}
}
}
/********************************************************************
函 数 名:save
入口参数:无
出口参数:无
建立日期:2007年8月19日
修改日期:
函数作用:保存设定值
说 明:
********************************************************************/
void save(void)
{
if(menu_statu==111)
{
x_position=temp_x_position;
y_position=temp_y_position;
temp_x_position=0;
temp_y_position=0;
LCD_Clear();//清屏
W_1byte(0,0,0x0C); //关光标
LCD_set_xy(1,2);
LCD_Display(OK);
Delay(100);
LCD_Clear();//清屏
print_root_page();
input_position=0;
}
if(menu_statu==112)
{
banjing=temp_banjing;
temp_banjing=0;
LCD_Clear();//清屏
W_1byte(0,0,0x0C); //关光标
LCD_set_xy(1,2);
LCD_Display(OK);
Delay(100);
LCD_Clear();//清屏
print_root_page();
input_banjing=0;
}
}
/********************************************************************
函 数 名:Delay
入口参数:ms
出口参数:无
建立日期:2007年8月15日
修改日期:
函数作用:毫秒级的延时程序,当晶振为12Mhz时,xtal=12;
说 明:
********************************************************************/
void Delay(uint ms)
{
uint i;
while(ms--)
{
for(i=1;i<(uint)(xtal*143-2);i++)
;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -