单片机 界面人机互动 guiC.docx
- 文档编号:23550017
- 上传时间:2023-05-18
- 格式:DOCX
- 页数:17
- 大小:16.85KB
单片机 界面人机互动 guiC.docx
《单片机 界面人机互动 guiC.docx》由会员分享,可在线阅读,更多相关《单片机 界面人机互动 guiC.docx(17页珍藏版)》请在冰豆网上搜索。
单片机界面人机互动guiC
#include"include.h"
#include"control.h"
GuiSignTypedefGuiSign;
GuiDataTypedefGuiData;
INT8Utemp_i;
/*
*********************************************************************************************************
*GUI
*Description:
GUI可随意添加页面必须配合button_control()联合使用该GUI可随意移植
*
*Arguments:
GuiSign、GuiData
*
*Note(s):
最后修改13-6-6
*操作人:
HW
*********************************************************************************************************
*/
voidGUI(void)
{
INT32Utemp;
if(GuiSign.EN==0)
{
if(GuiSign.S1==0)
{
LCD_Print(24,0,"河北联合大学");
LCD_Print(36,2,"智能车队");
LCD_P8x16Str(8,4,"time:
");
LCD_P8x16Str(8,6,"sudu:
");
temp=OSTimeGet();
temp=temp/1000;
OLED_Data(64,5,temp);
OLED_Data(64,7,speed_pwm);
}
if(GuiSign.S1==1)
{
switch(GuiSign.S2)
{
case0:
LCD_Print(50,0,"菜单");
LCD_Print(8,2,"启停>");
LCD_Print(8,4,"设置");
LCD_Print(8,6,"测试");
break;
case1:
LCD_Print(50,0,"菜单");
LCD_Print(8,2,"启停>>开始");
LCD_Print(8,4,"设置");
LCD_Print(8,6,"测试");
OSTimeDlyHMSM(0,0,GuiData.GUI_SJ,0);
start_flag=0;
GuiData.GUI_LASTIME=OSTimeGet();
#ifAPP_MATCH>0u
OSTaskResume(APP_TASK1_PRIO);
#endif
if(GuiData.GUI_CS>0)
{
OSTimeDlyHMSM(0,0,GuiData.GUI_CS,0);
start_flag=1;
GuiSign.S1=0;
LCD_CLS();
}
else{GuiSign.S1=0;LCD_CLS();}//GuiSign.EN=3;
break;
case2:
LCD_Print(50,0,"菜单");
LCD_Print(8,2,"启停>>停止");
LCD_Print(8,4,"设置");
LCD_Print(8,6,"测试");
start_flag=1;
break;
default:
printf(APP_LOGIN);
break;
}
}
if(GuiSign.S1==2)
{
switch(GuiSign.S2)
{
case0:
LCD_Print(50,0,"菜单");
LCD_Print(8,2,"启停");
LCD_Print(8,4,"设置>");
LCD_Print(8,6,"测试");
break;
case1:
LCD_Print(8,0,"菜单>P值");OLED_Data(90,1,GuiData.GUI_P);
LCD_Print(8,2,"启停D值");OLED_Data(90,3,GuiData.GUI_D);
LCD_Print(8,4,"设置>大弯");OLED_Data(90,5,GuiData.GUI_DW);
LCD_Print(8,6,"测试小弯");OLED_Data(90,7,GuiData.GUI_XW);
break;
case2:
LCD_Print(8,0,"菜单P值");OLED_Data(90,1,GuiData.GUI_P);
LCD_Print(8,2,"启停>D值");OLED_Data(90,3,GuiData.GUI_D);
LCD_Print(8,4,"设置>大弯");OLED_Data(90,5,GuiData.GUI_DW);
LCD_Print(8,6,"测试小弯");OLED_Data(90,7,GuiData.GUI_XW);
break;
case3:
LCD_Print(8,0,"菜单P值");OLED_Data(90,1,GuiData.GUI_P);
LCD_Print(8,2,"启停D值");OLED_Data(90,3,GuiData.GUI_D);
LCD_Print(8,4,"设置>>大弯");OLED_Data(90,5,GuiData.GUI_DW);
LCD_Print(8,6,"测试小弯");OLED_Data(90,7,GuiData.GUI_XW);
break;
case4:
LCD_Print(8,0,"菜单P值");OLED_Data(90,1,GuiData.GUI_P);
LCD_Print(8,2,"启停D值");OLED_Data(90,3,GuiData.GUI_D);
LCD_Print(8,4,"设置>大弯");OLED_Data(90,5,GuiData.GUI_DW);
LCD_Print(8,6,"测试>小弯");OLED_Data(90,7,GuiData.GUI_XW);
break;
case5:
LCD_Print(8,0,"菜单D值");OLED_Data(90,1,GuiData.GUI_D);
LCD_Print(8,2,"启停大弯");OLED_Data(90,3,GuiData.GUI_DW);
LCD_Print(8,4,"设置>小弯");OLED_Data(90,5,GuiData.GUI_XW);
LCD_Print(8,6,"测试>直道");OLED_Data(90,7,GuiData.GUI_ZD);
break;
case6:
LCD_Print(8,0,"菜单大弯");OLED_Data(90,1,GuiData.GUI_DW);
LCD_Print(8,2,"启停小弯");OLED_Data(90,3,GuiData.GUI_XW);
LCD_Print(8,4,"设置>直道");OLED_Data(90,5,GuiData.GUI_ZD);
LCD_Print(8,6,"测试>中值");OLED_Data(90,7,GuiData.GUI_ZZ);
break;
case7:
LCD_Print(8,0,"菜单小弯");OLED_Data(90,1,GuiData.GUI_XW);
LCD_Print(8,2,"启停直道");OLED_Data(90,3,GuiData.GUI_ZD);
LCD_Print(8,4,"设置>中值");OLED_Data(90,5,GuiData.GUI_ZZ);
LCD_Print(8,6,"测试>开始时间");OLED_Data(108,7,GuiData.GUI_SJ);
break;
case8:
LCD_Print(8,0,"菜单直道");OLED_Data(90,1,GuiData.GUI_ZD);
LCD_Print(8,2,"启停中值");OLED_Data(90,3,GuiData.GUI_ZZ);
LCD_Print(8,4,"设置>开始时间");OLED_Data(107,5,GuiData.GUI_SJ);
if(GuiData.GUI_JC==0){LCD_Print(8,6,"测试>启跑检测Y");}
else{LCD_Print(8,6,"测试>启跑检测N");}
break;
default:
printf(APP_LOGIN);
break;
}
}
if(GuiSign.S1==3)
{
switch(GuiSign.S2)
{
case0:
LCD_Print(50,0,"菜单");
LCD_Print(8,2,"启停");
LCD_Print(8,4,"设置");
LCD_Print(8,6,"测试>");
break;
case1:
LCD_Print(50,0,"菜单");
LCD_Print(8,2,"启停");
LCD_Print(8,4,"设置>软件");
LCD_Print(8,6,"测试>传感");
break;
case2:
LCD_Print(50,0,"菜单");
LCD_Print(8,2,"启停");
LCD_Print(8,4,"设置软件");
LCD_Print(8,6,"测试>>传感");
break;
default:
printf(APP_LOGIN);
break;
}
}
}
else
{
if(GuiSign.EN==1){LCD_Print(24,3,"测试时间s");OLED_Data(82,4,GuiData.GUI_CS);}
elseif(GuiSign.EN==2)
{
LCD_P8x16Str(0,0,"ad0:
");OLED_Data(30,1,temp_.AD0);LCD_P8x16Str(64,0,"mc:
");OLED_Data(88,1,MC_Count);
LCD_P8x16Str(0,2,"ad1:
");OLED_Data(30,3,temp_.AD1);LCD_P8x16Str(64,2,"l1:
");OLED_Data(96,3,data_.L12);
LCD_P8x16Str(0,4,"ad2:
");OLED_Data(30,5,temp_.AD2);LCD_P8x16Str(64,4,"jd:
");OLED_Data(96,5,data_.J12);
LCD_P8x16Str(0,6,"ad3:
");OLED_Data(30,7,temp_.AD3);LCD_P8x16Str(64,6,"ou:
");OLED_Data(88,7,AngleData.Export-AngleData.MID);
OSTimeDlyHMSM(0,0,1,0);
LCD_CLS();
}
elseif(GuiSign.EN==3)
{
LCD_Print(36,2,"启-->停");
LCD_P8x16Str(8,4,"time:
s");
LCD_P8x16Str(8,6,"sudu:
");
temp=GuiData.GUI_TIME;
temp=temp/1000;
OLED_Data(64,5,temp);
OLED_Data(64,7,speed_pwm);
}
}
}
/*
*********************************************************************************************************
*button_control
*Description:
button_control可随意添加功能必须配合GUI()联合使用
*
*Arguments:
GuiSign、GuiData
*
*Note(s):
最后修改13-6-6
*********************************************************************************************************
*/
voidbutton_control(INT8Ubutton)
{
switch(button)
{
case1:
printf("button:
1\n");
if(GuiSign.S1==0){}
elseif(GuiSign.S1==1)
{
}
elseif(GuiSign.S1==2)
{
if(GuiSign.S2>0)GuiSign.S2Down=~GuiSign.S2Down;
}
elseif(GuiSign.S1==3)
{
if(GuiSign.S2==1)
{
GuiSign.S3Down=~GuiSign.S3Down;
if(GuiSign.S3Down>0){GuiSign.EN=1;LCD_CLS();}
else{GuiSign.EN=0;LCD_CLS();}
}
elseif(GuiSign.S2==2)
{
GuiSign.S3Down=~GuiSign.S3Down;
if(GuiSign.S3Down>0){GuiSign.EN=2;LCD_CLS();}
else{GuiSign.EN=0;LCD_CLS();}
}
}
break;
case2:
printf("button:
2\n");
if(GuiSign.S2Down==0)
{
if(GuiSign.EN==0)
{
GuiSign.S1=GuiSign.S1-1;
GuiSign.S2=0;
if(GuiSign.S1<0){GuiSign.S1=3;}
LCD_CLS();//清屏
}
}
break;
case3:
printf("button:
3\n");
if(GuiSign.S2Down==0)
{
if(GuiSign.EN==0)
{
GuiSign.S1=GuiSign.S1+1;
GuiSign.S2=0;
if(GuiSign.S1>3)GuiSign.S1=0;
LCD_CLS();//清屏
}
}
break;
case4:
printf("button:
4\n");
if(GuiSign.EN==0)
{
if(GuiSign.S2Down==0)
{
GuiSign.S2=GuiSign.S2-1;
GuiSign.S3=0;
if(GuiSign.S1==2){if(GuiSign.S2<=0)GuiSign.S2=8;}
else{if(GuiSign.S2<=0)GuiSign.S2=2;}
LCD_CLS();
}
else
{//此处可添加界面2新功能
GuiSign.S3=GuiSign.S3+1;
if(GuiSign.S2==1){GuiData.GUI_P=GuiData.GUI_P+0.1;AngleData.Kp=GuiData.GUI_P;}
elseif(GuiSign.S2==2){GuiData.GUI_D=GuiData.GUI_D+1;AngleData.Kd=GuiData.GUI_D;}
elseif(GuiSign.S2==3){GuiData.GUI_DW=GuiData.GUI_DW+50;}
elseif(GuiSign.S2==4){GuiData.GUI_XW=GuiData.GUI_XW+50;}
elseif(GuiSign.S2==5){GuiData.GUI_ZD=GuiData.GUI_ZD+50;}
elseif(GuiSign.S2==6){GuiData.GUI_ZZ=GuiData.GUI_ZZ+10;AngleData.MID=GuiData.GUI_ZZ;}
elseif(GuiSign.S2==7){GuiData.GUI_SJ=GuiData.GUI_SJ+1;}
elseif(GuiSign.S2==8){GuiData.GUI_JC=(GuiData.GUI_JC+1)%2;}
}
}
elseif(GuiSign.EN==1){GuiData.GUI_CS=GuiData.GUI_CS+1;}
elseif(GuiSign.EN==2){}
break;
case5:
printf("button:
5\n");
if(GuiSign.EN==0)
{
if(GuiSign.S2Down==0)
{
GuiSign.S2=GuiSign.S2+1;
GuiSign.S3=0;
if(GuiSign.S1==2){if(GuiSign.S2>8)GuiSign.S2=1;}
else{if(GuiSign.S2>2)GuiSign.S2=1;}
LCD_CLS();
}
else
{
GuiSign.S3=GuiSign.S3-1;
if(GuiSign.S2==1){GuiData.GUI_P=GuiData.GUI_P-0.1;AngleData.Kp=GuiData.GUI_P;}
elseif(GuiSign.S2==2){GuiData.GUI_D=GuiData.GUI_D-1;AngleData.Kd=GuiData.GUI_D;}
elseif(GuiSign.S2==3){GuiData.GUI_DW=GuiData.GUI_DW-50;}
elseif(GuiSign.S2==4){GuiData.GUI_XW=GuiData.GUI_XW-50;}
elseif(GuiSign.S2==5){GuiData.GUI_ZD=GuiData.GUI_ZD-50;}
elseif(GuiSign.S2==6){GuiData.GUI_ZZ=GuiData.GUI_ZZ-10;AngleData.MID=GuiData.GUI_ZZ;}
elseif(GuiSign.S2==7){GuiData.GUI_SJ=GuiData.GUI_SJ-1;}
elseif(GuiSign.S2==8){GuiData.GUI_JC=(GuiData.GUI_JC+1)%2;}
}
}
elseif(GuiSign.EN==1){GuiData.GUI_CS=GuiData.GUI_CS-1;}
elseif(GuiSign.EN==2){}
break;
case6:
gpio_set(PORTA,29,HIGH);
printf("button:
6\n");
break;
case7:
gpio_set(PORTA,29,HIGH);
printf("button:
7\n");
break;
default:
printf(APP_LOGIN);
break;
}
}
/*
*********************************************************************************************************
*LCD_Data
*Description:
GUI
*
*Arguments:
none
*
*Note(s):
最后修改13-6-5
*********************************************************************************************************
*/
voidOLED_Data(INT8Ux,INT8Uy,floatoleddata)
{
INT16Udata1[]={'0','\0'},data2[]={'0','\0'},data3[]={'0','\0'},data4[]={'0','\0'},data5[]={'-','\0'},data6[]={'.','\0'};
floatoled_temp;
INT32Sdata;
oled_temp=oleddata*10;
data=(INT32S)oleddata;
if(data<0){data=-data;LCD_P6x8Str(x-8,y,(uint8*)data5);}
if(data>=10000){data=data/10;}
if(data>=1000)
{
data1[0]=48+data/1000;
data2[0]=48+data%1000/100;
data3[0]=48+data%1000%100/10;
data4[0]=48+data%10;
LCD_P6x8Str(x,y,(uint8*)data1);
LCD_P6x8Str(x+8,y,(uint8*)data2);
LCD_P6x8Str(x+16,y,(uint8*)data3)
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 单片机 界面人机互动 guiC 界面 人机 互动
![提示](https://static.bdocx.com/images/bang_tan.gif)