#include "includes.h" unsigned char uiTmpVal; /****************************状态栏显示部分开始***********************************/ //显示信号强度 static void ShowSingle(int CSQ){ unsigned short x=SIGNAL_ICON_X; unsigned short y=2; //if(sutApp.pocPpp == 0) guiShowBmp(x,y,"Single.bmp"); //else guiShowBmp(x,y,"SingleOK.bmp"); guiShowBinMap(0,1,"signal.bin"); //11 3格 x += 7; if(CSQ<5 || CSQ==99){ GuiDrawSignalVLine(5); }else if(CSQ<11){ GuiDrawSignalVLine(4); }else if(CSQ<18){ GuiDrawSignalVLine(3); }else if(CSQ<22){ GuiDrawSignalVLine(2); }else{ GuiDrawSignalVLine(1); } } unsigned char netshowvalue=0xff; unsigned char ctecCurrentSet=0; //显示网络制式 static void Show_Net(unsigned char s_netshowvalue){ unsigned short y=0; if(s_netshowvalue==4){ if(sutApp.UserInfo.tnet==5) newGuiShowStr(19, 1, "5G",REVERSED_NO,FONT_MODE_12X12); else newGuiShowStr(19, 1, "4G",REVERSED_NO,FONT_MODE_12X12); } } static void gpsIconShow(char flash){ typedef struct{ unsigned char located:1; unsigned char auth:1; unsigned char gpsF:1; }TMP_GPS_DEF; static TMP_GPS_DEF tmpGps; unsigned short x=GPS_ICON_X,y=0; return; if(tmpGps.located==gpsInfo.gpsLocated && tmpGps.auth==gpsInfo.bbAuth && tmpGps.gpsF==gpsInfo.gpsF && flash==0) return; guiClearRect(x,y,x+GPS_ICON_WX,y+11,COLOR_STATUS_BAR); if(gpsInfo.gpsF==0){//GPS未打开时 if(gpsInfo.bbAuth==1) guiShowBmp(x,y,"GPS3.bmp");//已鉴权 }else{//GPS已打开 if(gpsInfo.bbAuth==1) guiShowBmp(x,y,"GPS1.bmp");//已鉴权 else if(gpsInfo.bbAuth==1) guiShowBmp(x,y,"GPSA.bmp");//未鉴权 if(gpsInfo.gpsLocated==1) guiShowBmp(x+10,y,"GPS2.bmp");//已定位 } tmpGps.located=gpsInfo.gpsLocated; tmpGps.auth=gpsInfo.bbAuth; tmpGps.gpsF=gpsInfo.gpsF; } static void ShowCardType(char card){ unsigned short x= CARD_ICON_X; unsigned short y=3; if(card==0) guiShowBmp(x, y, "SIM1.bmp"); else if(card==1) guiShowBmp(x, y, "SIM2.bmp"); } //显示电量 static void ShowBatttery(int bat,unsigned int exeInterval){ #if 0 static unsigned int flashCnt=0; static unsigned char flag=0; static unsigned short cnt=0; unsigned short x=BAT_ICON_X,y=2,h=y+2; if(sutApp.chargeStatus!=0){//正在充电 guiShowBmp(x, y, "CHARGE.bmp"); }else if(bat=400 4格 guiShowBmp(x,y,"VBAT1.bmp"); guiDrawVLine(h,h+5,x+4,y+1,guiGetBackColor()); guiDrawVLine(h,h+5,x+8,y+1,guiGetBackColor()); guiDrawVLine(h,h+5,x+12,y+1,guiGetBackColor()); guiDrawVLine(h,h+5,x+16,y+1,guiGetBackColor());//5.12 } sutApp.lowPwrWarn=0; #else const unsigned short batTable[13]={320,328,336,344,352,360,368,376,384,392,400,405,410}; short i; guiShowBinMap(114,1,"battery.bin"); for(i=13;i>0;i--) { if(bat >= batTable[i-1]) NewDrawVLine(129-i,2,6); } LCDFlashPainPage(104,0); #endif } //显示时间 static void ShowTime(char flash,unsigned int exeInterval){ static unsigned short nextExe=0; static unsigned char flag=0; MY_CLOCK myclock; char buf[30]; if(nextExe==0 || flash){ if(flag){ snprintf(buf, sizeof(buf), "%02d:%02d",myclock.hour, myclock. min); flag=0; }else{ snprintf(buf, sizeof(buf), "%02d %02d",myclock.hour, myclock. min); flag=1; } newGuiShowStr((GLCD_WIDTH-40)/2,1, buf,REVERSED_NO,FONT_MODE_12X12); } if(++nextExe>=(1000/exeInterval)) nextExe=0; } //显示耳机接入状态 static void ShowEarStatus(char flash){ static unsigned char lastStatus=0; if(lastStatus==sutApp.earLev && flash==0) return; if(sutApp.earLev!=0) guiShowBmp(EAR_ICON_X, 1, "ear.bmp"); else guiClearRect(EAR_ICON_X, 1, EAR_ICON_X+EAR_ICON_WX,1+12, COLOR_STATUS_BAR); lastStatus=sutApp.earLev; } //显示键盘锁状态 static void ShowKeyLocStatus(char flash){ static unsigned char lastStatus=0; if(lastStatus==sutApp.keyLock && flash==0) return; if(sutApp.keyLock!=0) guiShowBmp(LOCK_ICON_X, 1, "lock.bmp"); else guiClearRect(LOCK_ICON_X, 1, LOCK_ICON_X+LOCK_ICON_WX,12, COLOR_STATUS_BAR); lastStatus=sutApp.keyLock; } //显示状态栏 void uiShowStatusBar(char flash,unsigned int exeInterval){ static unsigned char s_netshowvalue=0xff; static unsigned char lastPPPStatus; static int siCSQ; static int siVbat; static unsigned short batFirstShow=0; static char cardType=0; char tempFlash=flash; if(sutApp.enableKey==0) return; if(sutApp.updateStatusBar!=0){ sutApp.updateStatusBar=0; tempFlash=1; newGuiClearBar(); } //显示信号 if(tempFlash || siCSQ!=sutApp.g_iCSQ || lastPPPStatus != sutApp.pocPpp){ lastPPPStatus=sutApp.pocPpp; siCSQ=sutApp.g_iCSQ; ShowSingle(sutApp.g_iCSQ); } //显示卡选项 // if(tempFlash || cardType != sutApp.simSel){ // cardType=sutApp.simSel; // ShowCardType(cardType); // } //显示2G/3G/4G if(tempFlash || s_netshowvalue!=netshowvalue){ s_netshowvalue=netshowvalue; Show_Net(s_netshowvalue); } //显示GPS是否正常及鉴权情况 //gpsInfo.gpsLocated=1; //gpsInfo.bbAuth=1; //gpsInfo.gpsF=1; // gpsIconShow(tempFlash); //电量显示 #if 0 if(batFirstShow < (1000/exeInterval)) {//开机前1秒显示一半电量 sutApp.g_iBAT=360; batFirstShow++; }else #endif if(tempFlash || siVbat!=sutApp.g_iBAT || sutApp.g_iBAT < WARN_PWR_LEVEL){ if(sutApp.g_iBAT>=0){ siVbat=sutApp.g_iBAT; ShowBatttery(sutApp.g_iBAT,exeInterval); } } //文本消息显示 //sutSms.haveUnRead=1; //ShowMessageFlag(0); //GPS显示 //时间显示 ShowTime(tempFlash,exeInterval); //显示耳机状态 // ShowEarStatus(tempFlash); //显示键盘锁状态 // ShowKeyLocStatus(tempFlash); } /****************************状态栏显示部分结束***********************************/ /****************************待机界面显示部分开始***********************************/ typedef enum{ ME_NO_LOGIN, ME_NOBODY_SPEAK, ME_IAM_SPEAK, ME_SOMEBODY_SPEAK }ME_ENUM; static void uiShowGUName(int update); static void uiShowGuaDuan(unsigned char danhu); static void uiShowGroup(const char* info); static void uiShowUser(const char* info); static void uiShowHuaQuan(const char* info); static void uiShowCallUserName(void); static void uiShowOffLineMessage(void); static void uiShowCopsInfo(void){ char info[50]; if(newPara.itemShowType==0){ switch(sutApp.copstype){ case 0:case 2:case 4:case 7://中国移动 snprintf(info, sizeof(info), "中国移动"); break; case 1:case 6:case 9://中移联通 snprintf(info, sizeof(info), "中国联通"); break; case 3:case 8:case 11://中国电信 snprintf(info, sizeof(info), "中国电信"); break; default:snprintf(info, sizeof(info), "公网集群对讲系统");break; } }else snprintf(info, sizeof(info), "公网集群对讲系统"); guiFillRect(0, UI_STATUS_ITEM_Y, GLCD_WIDTH-1, UI_CONTENT_SHOW_Y-1, guiGetForeColor());//清除第二区 guiShowCaption(0,info, UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12); } #ifdef USE_LEFT_MOVING void movingShowNames(unsigned int dlyInterval,unsigned char reset, unsigned char now,unsigned char voice){ const char *idleptr="空闲"; const char *voiceptr="本机在讲话"; const char *danhuptr="单呼模式"; char *gname=danhuptr; char *voicePri=idleptr; char *uname=NULL; static unsigned int interval=0xffffff; if(sutPocStatus.logined==0) return; //if(sutPocStatus.statusChaned!=0){ // sutPocStatus.statusChaned=0; // reset=1; //} if(++interval<500/dlyInterval && reset==0 && now==0) return;//0.5秒刷新一次 interval=0; if(sutPocStatus.danHuStatus==0){ if(sutPocStatus.LocalGroup.name[0]==0) gname=NULL; else gname=sutPocStatus.LocalGroup.name; } if(voice==0) voicePri=idleptr; else if(voice==1) voicePri=voiceptr; else voicePri=sutPocStatus.CallName; if(sutPocStatus.LocalUser.name[0]!=0) uname=sutPocStatus.LocalUser.name; mainScreenShowMoving(UI_GROUP_SHOW_Y, reset,gname,uname,voicePri); } #endif void uiShowMainInterface(char status,unsigned int exeInterval){ short Flag=ME_NO_LOGIN;//ME_ENUM static unsigned char danhu=0; static short lastFlag=-1; static unsigned short siCt=0; char info[20]; static char firstRun=0; static unsigned short dly=0; char tmpStatus=status; static int copsStatus; static unsigned int timer; static char lockStep=0; unsigned char reset=0; unsigned char moveFlash=0; static unsigned char voice=0; //提示解锁 if(sutApp.lockShow!=0){ if(lockStep==0){ lockStep=1; backLightReset(); uTimerStart(&timer, 1000); newGuiClearMainPage(); newGuiShowStr(GLCD_WIDTH/2-32,STATUS_BAR_HEIGH, "键盘已锁",REVERSED_NO,FONT_MODE_16X16); newGuiShowStr(GLCD_WIDTH/2-32+8,STATUS_BAR_HEIGH+16,"请解锁",REVERSED_NO,FONT_MODE_16X16); } }else lockStep=0; if(lockStep==1){ if(uTimerExpired(&timer)){ newGuiClearMainPage(); lastFlag=-1;//让以下刷新一下 sutApp.lockShow=0; lockStep=0; sutUIstatus.ItemRefresh=1;//如果"请插卡"有显示,会被刷掉不再显示,这里让它重新显示出来 } return; } #if 0 /*延时一下1秒后才显示后面的,如果直接登录了,就跳出延时*/ if(firstRun==0){ if((++dly>=(1*1000/exeInterval)) || sutPocStatus.logined!=0){ firstRun=1; tmpStatus=1; sutApp.enableKey=1;//延时按键操作完成 }else return; } #endif /*逻辑处理开始*/ if(tmpStatus){ newGuiClearMainPage(); danhu=sutPocStatus.danHuStatus; uiShowGuaDuan(danhu); lastFlag=-1; siCt=0; //return; } if(copsStatus != sutApp.copstype || tmpStatus){ copsStatus=sutApp.copstype; //uiShowCopsInfo(); } //更新单呼显示与否 if(sutPocStatus.danHuStatus != danhu){ danhu=sutPocStatus.danHuStatus; uiShowGuaDuan(danhu); } //以下持续调用,以便动态更新信息 if(0==sutPocStatus.logined) Flag=ME_NO_LOGIN;//未登录 else if(0==sutPocStatus.spk && 0==sutPocStatus.mic){//已登录,无人说话 Flag=ME_NOBODY_SPEAK; }else if(0!=sutPocStatus.mic) Flag=ME_IAM_SPEAK;//已登录,本机说话 else if(0!=sutPocStatus.spk) Flag=ME_SOMEBODY_SPEAK;//有人说话 switch(Flag){ case ME_NO_LOGIN://未登录 if(Flag != lastFlag){ newGuiClearMainPage(); } break; case ME_NOBODY_SPEAK://已登录,无人说话 if(Flag != lastFlag){ if(ME_NO_LOGIN==lastFlag) newGuiClearPage(0, ROW_TWO); newGuiClearPage(0, ROW_FOUR); #ifdef USE_LEFT_MOVING voice=0; moveFlash=1; #else uiShowHuaQuan("空闲"); #endif sutPocStatus.statusChaned = 1; } break; case ME_IAM_SPEAK://已登录,本机说话 if(Flag != lastFlag){ #ifdef USE_LEFT_MOVING voice=1; moveFlash=1; #else newGuiClearMainPage(); uiShowHuaQuan("本机在讲话"); #endif } break; case ME_SOMEBODY_SPEAK://已登录,有人说话 if(Flag != lastFlag){ newGuiClearPage(0, ROW_FOUR); sutPocStatus.statusChaned=1;//保证要刷新名字 #ifdef USE_LEFT_MOVING voice=2; moveFlash=1; #endif } #ifndef USE_LEFT_MOVING uiShowCallUserName(); #endif break; } if(Flag>0){//已登录 if(Flag != lastFlag && (lastFlag==-1 || ME_NO_LOGIN==lastFlag)){ #ifdef USE_LEFT_MOVING reset=1; #else uiShowGUName(1); #endif } #ifndef USE_LEFT_MOVING else uiShowGUName(0); #endif }else{//未登录 snprintf(info, sizeof(info),"正在登陆."); switch(siCt){//not finished yet case 0: strcat(info, " "); newGuiShowStr(0, STATUS_BAR_HEIGH, info, REVERSED_NO, FONT_MODE_16X16); break; case (1000/APP_SUB_DIV_TIME): strcat(info, ". "); newGuiShowStr(0, STATUS_BAR_HEIGH, info, REVERSED_NO, FONT_MODE_16X16); break; case (2000/APP_SUB_DIV_TIME): strcat(info, ".."); newGuiShowStr(0, STATUS_BAR_HEIGH, info, REVERSED_NO, FONT_MODE_16X16); break; } //显示登录状态 uiShowOffLineMessage(); } #ifdef USE_LEFT_MOVING movingShowNames(APP_SUB_DIV_TIME,reset,moveFlash,voice); #endif if(++siCt>=(3000/APP_SUB_DIV_TIME)) siCt=0; if(Flag != lastFlag) lastFlag=Flag; } static void uiShowGUName(int update){ static char scNameUser[POC_GROUP_USER_NAME_LEN]; static char scNameGroup[POC_GROUP_USER_NAME_LEN]; char name[POC_GROUP_USER_NAME_LEN]; unsigned short len; const unsigned char danHuanBuffer[9]={0xB5,0xA5,0xBA,0xF4,0xC4,0xA3,0xCA,0xBD,0}; char GroupShowUpdate=0; char UserShowUpdate=0; if(sutPocStatus.danHuStatus==0){ if(0!=strcmp(sutPocStatus.LocalGroup.name,scNameGroup) || update!=0){ memset(scNameGroup,0,sizeof(scNameGroup)); memcpy(scNameGroup,sutPocStatus.LocalGroup.name,sizeof(scNameGroup)); GroupShowUpdate=1; } }else{ if(0!=strcmp((char *)danHuanBuffer,scNameGroup) || update!=0){ memset(scNameGroup,0,sizeof(scNameGroup)); memcpy(scNameGroup, danHuanBuffer,sizeof(danHuanBuffer)); GroupShowUpdate=1; } } if(0!=strcmp(sutPocStatus.LocalUser.name,scNameUser) || update!=0){ memset(scNameUser,0,sizeof(scNameUser)); memcpy(scNameUser,sutPocStatus.LocalUser.name,sizeof(scNameUser)); UserShowUpdate=1; } if(GroupShowUpdate){ guiClearRect(0,UI_GROUP_SHOW_Y,GLCD_WIDTH-1,UI_GROUP_SHOW_Y+16+2,guiGetBackColor());//18 //刷新群组栏 if(sutPocStatus.danHuStatus==0) StrIntercept(name, scNameGroup, sizeof(name)); else snprintf(name, sizeof(name), "单呼模式"); uiShowGroup(name); sutPocStatus.statusChaned=1; } if(UserShowUpdate){ guiClearRect(0,UI_USER_SHOW_Y,GLCD_WIDTH-1,UI_GROUP_SHOW_Y+16,guiGetBackColor());//18 //刷新成员栏 StrIntercept(name, scNameUser, sizeof(name)); uiShowUser(name); } } static void uiShowGuaDuan(unsigned char danhu){ return; if(danhu==0) guiClearArea(GLCD_WIDTH-32, UI_BOTTOM_SHOW_Y, 32, 14, guiGetBackColor()); else guiShowStr(GLCD_WIDTH-32, UI_BOTTOM_SHOW_Y, "挂断", FONT_MODE_12X12, REVERSED_NO, COLOR_STATUS_BAR,guiGetBackColor()); } static void uiShowGroup(const char* info){ guiClearRect(2, UI_GROUP_SHOW_Y-2, GLCD_WIDTH-1, UI_GROUP_SHOW_Y-2+17, guiGetBackColor()); guiShowStr(2, UI_GROUP_SHOW_Y+2,"群组:", FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor()); #ifdef USE_12X12_FONT_ONLY guiShowStr(2+30, UI_GROUP_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor()); #else guiShowStr(2+30, UI_GROUP_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor()); #endif } static void uiShowUser(const char* info){ guiClearRect(2, UI_USER_SHOW_Y-2, GLCD_WIDTH-1, UI_USER_SHOW_Y-2+17, guiGetBackColor()); guiShowStr(2, UI_USER_SHOW_Y+2,"成员:", FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor()); #ifdef USE_12X12_FONT_ONLY guiShowStr(2+30, UI_USER_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor()); #else guiShowStr(2+30, UI_USER_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor()); #endif } void showGroup(void){ uiShowGroup("默认群组"); } void showUser(void){ uiShowUser("小明"); } static void uiShowHuaQuan(const char* info){ guiClearRect(2, UI_VOICE_SHOW_Y-2, GLCD_WIDTH-1, UI_VOICE_SHOW_Y-2+17, guiGetBackColor()); guiShowStr(2, UI_VOICE_SHOW_Y+2,"话权:", FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor()); #ifdef USE_12X12_FONT_ONLY guiShowStr(2+30, UI_VOICE_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor()); #else guiShowStr(2+30, UI_VOICE_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor()); #endif } static void uiShowCallUserName(void){ static char scName[POC_GROUP_USER_NAME_LEN]; char name[POC_GROUP_USER_NAME_LEN]; if(0 != strncmp(scName, sutPocStatus.CallName, POC_GROUP_USER_NAME_LEN) || sutPocStatus.statusChaned){ //当名字变更或UI切换了,刷新显示 sutPocStatus.statusChaned=0; memcpy(scName, sutPocStatus.CallName, POC_GROUP_USER_NAME_LEN); uiShowHuaQuan(scName); } } static void uiShowOffLineMessage(void){ static unsigned char laReason; char info[50],update=0; unsigned short y; if(sutUIstatus.Status != UIS_STANDBY) return; if(sutPocStatus.PocLineOffReason==laReason && sutUIstatus.ItemRefresh==0) return; sutUIstatus.ItemRefresh=0; laReason=sutPocStatus.PocLineOffReason; if(sutApp.cardStatus==0){ snprintf(info, sizeof(info), "请插卡"); update=1; }else{ switch(sutPocStatus.PocLineOffReason){ case 1:snprintf(info, sizeof(info), "无网络连接");break; case 2:snprintf(info, sizeof(info), "无法连接");break; case 3:snprintf(info, sizeof(info), "没有服务");break; case 4:snprintf(info, sizeof(info), "账号信息错误");break; } if(sutPocStatus.PocLineOffReason!=0) update=1; } if(update!=0){ newGuiClearMainPage(); newGuiShowStr(0, STATUS_BAR_HEIGH+16, info, REVERSED_NO, FONT_MODE_16X16); } } /****************************待机界面显示部分结束***********************************/ /****************************主菜单显示部分开始*************************************/ #include "Palace.h" void uiShowMenuMain(char update){ static const char *apcMenuMain[]={ "群组选择", "成员选择", "文本信息", "系统设置", "定位设置", "终端信息", "" }; if(update) dotListBoxInit(apcMenuMain,"主菜单",-1,-1,0); } void MenuMainResponse(void){ unsigned short handle; unsigned short key; key=dotListBoxResponse(); if(MKEY_VALUE_MENU==key){ handle=dotListGetHandle(); switch(handle){ case 0: uISetNextStatus(UIS_MENU_GROUP_SEL); break; case 1: uISetNextStatus(UIS_MENU_USER_SEL); break; case 2: uISetNextStatus(UIS_MENU_MAIL_SEL); break; case 3: uISetNextStatus(UIS_MENU_SYS_SEL); break; case 4: uISetNextStatus(UIS_MENU_LOCATION_SEL); break; case 5: uISetNextStatus(UIS_MENU_INFO_SEL); break; } uiPushStack(handle); } else if(MKEY_VALUE_ESC==key){ uISetNextStatus(UIS_STANDBY); } } /****************************主菜单显示部分结束*************************************/ /*****************************群组选择/成员选择部分开始*********************************/ bool uiSwitchLock=false; bool isUiSwitchReady(void){return uiSwitchLock;} static char GUListBoxInited=0; static char SelMachine=0; static void ReFlashItemGU(char type); static void UserAssistAdd(void); void numGUFlash(int index, int total){ char info[10]; int x; snprintf(info, sizeof(info), "%d", total); x=GLCD_WIDTH-strlen(info)*12; guiClearRect(78, UI_STATUS_ITEM_Y, GLCD_WIDTH-1, UI_STATUS_ITEM_Y+12, guiGetForeColor()); guiShowStr(x, UI_STATUS_ITEM_Y+1, info, FONT_MODE_12X12, REVERSED_NO, guiGetBackColor(), guiGetForeColor()); } bool setHandleToZero=true; void uiShowGUSel(char StatusUpdate,unsigned int exeInterval,char type){ static char machine; static unsigned int timer; unsigned short timeout; char temp; if(StatusUpdate) machine=0; switch(machine){ case 0: newGuiClearMainPage(); if(sutPocStatus.logined == 0){//not login newGuiShowMessageBox("请先登录", ROW_TWO); uTimerStart(&timer, 1000); machine=1; }else{ newGuiShowMessageBox("请等候", ROW_TWO); uiSwitchLock=true; if(type==0) appSleepCtl(ASLEEP_GGROUP, 1);//要获取群组信息,不让休眠,记得超时或获取成功或获取失败后需要释放 else appSleepCtl(ASLEEP_GUSER, 1); UiassistStart(0); machine=2; setHandleToZero=true; } break; case 1: if(uTimerExpired(&timer)){ uISetNextStatus(UIS_STANDBY); } break; case 2: temp=getAssistResult(); if(temp){//??è?íê3é ReFlashItemGU(type); machine=3; //获取成功后退出释放休眠 if(type==0) appSleepCtl(ASLEEP_GGROUP, 0); else appSleepCtl(ASLEEP_GUSER, 0); uiSwitchLock=false; } break; } if(machine != 3) return; UserAssistAdd(); dotLeftMoveSelectedItem(); } void GroupSelResponse(){ unsigned int key; char buf[50]; int i; key=getKeyValue(); switch(SelMachine){ case 0: if(dotListGetHandle()==0 && MKEY_VALUE_UP==key){ UiassistStart(1); SelMachine=1; }else if(((dotListGetHandle()+1) == dotListGetItemNum()) && (MKEY_VALUE_DOWN==key)){ setHandleToZero=true; UiassistStart(2); SelMachine=2; } key=dotListBoxResponse(); if(MKEY_VALUE_ESC==key){ uiAssist.status=0; if(getStackStruct()->FastUiChange)uISetNextStatus(UIS_STANDBY); else uISetNextStatus(UIS_MENU_MAIN); appSleepCtl(ASLEEP_GGROUP, 0);//按键退出后释放休眠 GUListBoxInited=0; uiSwitchLock=false; }else if(MKEY_VALUE_MENU==key){ if(0 == sutPocStatus.ListCurOnlineNum) break; /////////////////////////////////////// UiassistEnd(0); sutApp.groupTTSEnable=1; snprintf(buf, sizeof(buf),"AT+POC=090000%08x\r\n",sutPocStatus.AllGroups[dotListGetHandle()].ID); msgAtSend(buf); MSG_INFO(1,buf); snprintf(buf, sizeof(buf),"进入:%s",sutPocStatus.AllGroups[dotListGetHandle()].name); MSG_INFO(1,buf); uISetNextStatus(UIS_STANDBY); SelMachine=0; } break; } } void UserSelResponse(){ char buf[50]; unsigned int key; key=getKeyValue(); switch(SelMachine){ case 0: if(GUListBoxInited==0) break;//还未初始化listbox时,不执行按键响应 if(dotListGetHandle()==0 && MKEY_VALUE_UP==key){ UiassistStart(1); SelMachine=1; }else if((dotListGetHandle()+1) == dotListGetItemNum() && (MKEY_VALUE_DOWN==key)){ setHandleToZero=true; UiassistStart(2); SelMachine=2; } key=dotListBoxResponse(); if(MKEY_VALUE_ESC==key){ uiAssist.status=0; if(getStackStruct()->FastUiChange)uISetNextStatus(UIS_STANDBY); else uISetNextStatus(UIS_MENU_MAIN); appSleepCtl(ASLEEP_GUSER, 0);//按键退出后释放休眠 GUListBoxInited=0; uiSwitchLock=false; }else if(MKEY_VALUE_MENU==key){ if(0 == sutPocStatus.ListCurOnlineNum) break; UiassistEnd(0); snprintf(buf, sizeof(buf),"AT+POC=0A0000%08x\r\n",sutPocStatus.AllUsers[dotListGetHandle()].ID); msgAtSend(buf); MSG_INFO(1, buf); snprintf(buf, sizeof(buf),"呼叫:%s",sutPocStatus.AllUsers[dotListGetHandle()].name); MSG_INFO(1, buf); uISetNextStatus(UIS_STANDBY); SelMachine=0; } break; } } static void UserAssistAdd(void){ switch(SelMachine){ case 1: if(getAssistResult()){ if(sutUIstatus.Status==UIS_MENU_GROUP_SEL)ReFlashItemGU(0); else ReFlashItemGU(1); SelMachine=0; } break; case 2: if(getAssistResult()){ if(sutUIstatus.Status==UIS_MENU_GROUP_SEL)ReFlashItemGU(0); else ReFlashItemGU(1); SelMachine=0; } break; } } static void ReFlashItemGU(char type){ int i; static char *GUName[POC_ALL_GROUPS_NUM+1]; static const char *NullGU=""; unsigned int showHandle; for(i=0;i<=POC_ALL_GROUPS_NUM;i++) GUName[i]=NullGU; for(i=0;i=GPS_TABLE_NUM) uiTmpVal=0; }else if(type==2){ if(uiTmpVal>0) uiTmpVal--; else uiTmpVal=GPS_TABLE_NUM-1; }else return; gpsTimeValue=getGPSTimeValue(uiTmpVal); if(gpsTimeValue==0) snprintf(buf, sizeof(buf), "关闭"); else snprintf(buf, sizeof(buf), "间隔:%d秒",gpsTimeValue); newGuiClearPage(0, ROW_THREE); newGuiShowStr(0, 32, buf,REVERSED_NO,FONT_MODE_16X16); } static locationXYFlash(char flash){ char buf[50]; unsigned short y=UI_CONTENT_SHOW_Y+2; if(gpsInfo.update==0 && flash==0) return; gpsInfo.update=0; guiClearRect(0, y,GLCD_WIDTH-1, y+12+5+12,guiGetBackColor()); snprintf(buf, sizeof(buf), "纬度 S:%d.%05d",gpsInfo.Lat/1000000,gpsInfo.Lat%1000000); guiShowStr(30,y, buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor()); y+=12+5; snprintf(buf, sizeof(buf), "经度 W:%d.%05d",gpsInfo.Long/1000000,gpsInfo.Long%1000000); guiShowStr(30,y, buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor()); } /*****************************定位设置部分结束*********************************/ /*******************************终端信息开始**********************************/ unsigned char sysInfoType; static void sysInfoFlash(void){ int len; char info[60]; unsigned char i=STATUS_BAR_HEIGH; newGuiClearMainPage(); if(sysInfoType==0){ snprintf(info, sizeof(info), "PSN:%s", sutApp.UserInfo.psn); newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16); i+= 16; snprintf(info, sizeof(info), "AVER:%s", OHPOC_VERSION); newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16); i+= 16; snprintf(info, sizeof(info), "IVER:%d", CUSTOMER_CODE); newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16); }else if(sysInfoType==1){ snprintf(info, sizeof(info), "PLAT:%s", OHPOC_POC_PLATFORM); newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16); i+= 16; snprintf(info, sizeof(info), "VPOC:%s",sutApp.pocVersion); newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16); }else if(sysInfoType==2){ snprintf(info, sizeof(info), "VMOD:%s", sutApp.modemVer); len=strlen(info); if(len>16){ i+= 16; newGuiShowStr(0, i, info+16,REVERSED_NO,FONT_MODE_16X16); i-= 16; info[16]=0; } newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16); }else if(sysInfoType==3){ snprintf(info, sizeof(info), "IMEI:%s", ohpocGetIMEI()); len=strlen(info); if(len>16){ i+= 16; newGuiShowStr(0, i, info+16,REVERSED_NO,FONT_MODE_16X16); i-= 16; info[16]=0; } newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16); }else if(sysInfoType==4){ snprintf(info, sizeof(info), "P%s",showPIP); newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16); i+= 16; snprintf(info, sizeof(info), "G%s",showGIP); newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16); i+= 16; snprintf(info, sizeof(info), "%d",newPara.gpsPort); newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16); } } void uiShowInformation(char update){ if(update){ sysInfoType=0; sysInfoFlash(); } } void uiShowInformationResponse(void){ unsigned short key=getKeyValue(); if(MKEY_VALUE_ESC==key) uISetNextStatus(sutUIstatus.LastStatus); else if(MKEY_VALUE_DOWN==key){ if(++sysInfoType>3) sysInfoType=0; sysInfoFlash(); }else if(MKEY_VALUE_UP==key){ if(sysInfoType==0) sysInfoType=3; else sysInfoType--; sysInfoFlash(); }else if(MKEY_VALUE_CB_IP==key){ sysInfoType=4; sysInfoFlash(); } } /*****************************终端信息结束**********************************/ static const char *commonIcon2[]={ "APN.bmp", "APN1.bmp", "" }; /*****************************LCD设置开始**********************************/ static void lcdTimeFlash(char type){ char buf[50]; unsigned short x=4,y=56,value; if(type==1){ if(++uiTmpVal>=5) uiTmpVal=0; }else if(type==2){ if(uiTmpVal>0) uiTmpVal--; else uiTmpVal=4; }else if(type!=0) return; value=newPara.lcdParaList[uiTmpVal]; if(value==0) snprintf(buf, sizeof(buf), "常亮"); else snprintf(buf, sizeof(buf), "%3d 秒", value); newGuiClearPage(0, ROW_FOUR); newGuiShowStr(0, 48, buf,REVERSED_NO,FONT_MODE_16X16); if(uiTmpVal==newPara.lcdParaDefaultIndex) guiShowBinMap(GLCD_WIDTH-15,48,"APN1.bin"); } void uiShowLcdSel(char StatusUpdate){ if(StatusUpdate){ newGuiClearMainPage(); newGuiShowStr(0, 16, "LCD设置",REVERSED_NO,FONT_MODE_16X16); newGuiShowStr(0, 32, "背光时长",REVERSED_NO,FONT_MODE_16X16); uiTmpVal=newPara.lcdParaDefaultIndex; lcdTimeFlash(0); } } void uiShowLcdSelResponse(void){ unsigned short key=getKeyValue(); if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL); else if(MKEY_VALUE_DOWN==key)lcdTimeFlash(1); else if(MKEY_VALUE_UP==key) lcdTimeFlash(2); else if(MKEY_VALUE_MENU==key){ getStackStruct()->ok_back=1; if(uiTmpVal != newPara.lcdParaDefaultIndex){ newPara.lcdParaDefaultIndex=uiTmpVal; MSG_INFO(1, "LCD TimeUpdate"); backLightReset(); sysIniSave(); } uISetNextStatus(UIS_MENU_SYS_SEL); } } /*****************************LCD设置结束**********************************/ /*****************************网络设置开始**********************************/ const unsigned char netModeSetTable[3]={1,2,4};//设置制式:AUTH,2G,4G /*输入制式源始值,返回索引值对应值*/ unsigned char getNetModeIndex(unsigned char netModeValue){ unsigned char i; for(i=0;i=sizeof(netModeSetTable)) return 0xff; else return netModeSetTable[netModeIndex]; } /*输入制式索引值,发送对应该命令给模块*/ void netModeSetCmd(unsigned char netMode){ char buf[30]; snprintf(buf, sizeof(buf), "AT+CTEC=%d,%d\r\n",ctecCurrentSet, netMode); msgAtSend(buf); } #define NET_MODE_NUM 3 void uiShowNetSel(char StatusUpdate){ static const char *netMode[NET_MODE_NUM+1]={ "AUTO", "2G", "4G", "" }; char Features[NET_MODE_NUM]; unsigned char i; if(StatusUpdate){ guiClearAll(guiGetBackColor()); guiShowCaption(0,"网络设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12); uiMenuShowBottomLine(); for(i=0;iok_back=1; if(sutListBox.handle*2 != newPara.netMode){ newPara.netMode=sutListBox.handle*2; MSG_INFO(1, "netMode update:%d", newPara.netMode); sysIniSave(); netModeSetCmd(newPara.netMode); } uISetNextStatus(UIS_MENU_SYS_SEL); } } /*****************************网络设置结束**********************************/ /*****************************卡选择设置开始**********************************/ #define SIM_MODE_NUM 2 void uiShowSimSel(char StatusUpdate){ static const char *simMode[SIM_MODE_NUM+1]={ "卡1", "卡2", "" }; char Features[SIM_MODE_NUM]; unsigned char i; if(StatusUpdate){ guiClearAll(guiGetBackColor()); guiShowCaption(0,"SIM设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12); uiMenuShowBottomLine(); for(i=0;iFastUiChange)uISetNextStatus(UIS_STANDBY); else uISetNextStatus(UIS_MENU_SYS_SEL); }else if(MKEY_VALUE_MENU==key){ getStackStruct()->ok_back=1; if(sutListBox.handle != sutApp.simSel){ snprintf(buf, sizeof(buf), "AT+SIMCROSS=%d\r\n",sutListBox.handle); msgAtSend(buf); guiShowMessageBox("请重启设备"); msgAtSend("AT+TRB\r\n"); LSAPI_OSI_ThreadSleep(100); CTL_POWER_HOLD(false); for(;;){ MSG_INFO(1, "card changed, wait user reboot"); CTL_POWER_HOLD(false); LSAPI_OSI_ThreadSleep(1000); } } uISetNextStatus(UIS_MENU_SYS_SEL); } } /*****************************卡选择设置结束**********************************/ /*****************************功耗设置开始**********************************/ typedef enum{ PMODE_DEFAULT_LOW, PMODE_SUPER_LOW, PMODE_NORMAL }PWR_ENUMDEF; //低功耗模式 #define MODE_LOW_PWR_NONE_4G 5 #define MODE_LOW_PWR_IS_4G 25 //超长待机模式 #define MODE_LONG_LOW_PWR_NONE_4G 5 #define MODE_LONG_LOW_PWR_IS_4G 55 //常规模式 #define MODE_NORMAL__NONE_4G 5 #define MODE_NORMAL__IS_4G 5 //终端放弃设置模式,由服务器决定使用什么 #define MODE_AUTO____NONE_4G 0 #define MODE_AUTO____IS_4G 0 //默认功耗模式 #define MODE_PWR_DEFAULT_NONE_4G MODE_LOW_PWR_NONE_4G #define MODE_PWR_DEFAULT_IS_4G MODE_LOW_PWR_IS_4G static void pwrModeSetCmd(unsigned char pwrMode){ unsigned char seg1,seg2; char buf[30]; if(pwrMode==PMODE_DEFAULT_LOW){ seg1=MODE_PWR_DEFAULT_NONE_4G; seg2=MODE_PWR_DEFAULT_IS_4G; }else if(pwrMode==PMODE_SUPER_LOW){ seg1=MODE_LONG_LOW_PWR_NONE_4G; seg2=MODE_LONG_LOW_PWR_IS_4G; }else if(pwrMode==PMODE_NORMAL){ seg1=MODE_NORMAL__NONE_4G; seg2=MODE_NORMAL__IS_4G; }else return; snprintf(buf, sizeof(buf), "AT+UDP=%d,%d\r\n",seg1,seg2); msgAtSend(buf); } void pwrModeAckHandler(unsigned char seg1, unsigned char seg2){ if(seg1==MODE_PWR_DEFAULT_NONE_4G && seg2==MODE_PWR_DEFAULT_IS_4G && newPara.pwrMode != PMODE_DEFAULT_LOW){ goto SAVE_PWR_MODE; }else if(seg1==MODE_LONG_LOW_PWR_NONE_4G && seg2==MODE_LONG_LOW_PWR_IS_4G && newPara.pwrMode != PMODE_SUPER_LOW){ goto SAVE_PWR_MODE; }else if(seg1==MODE_NORMAL__NONE_4G && seg2==MODE_NORMAL__IS_4G && newPara.pwrMode != PMODE_NORMAL){ goto SAVE_PWR_MODE; }else if(seg2!=MODE_LOW_PWR_IS_4G&&seg2!=MODE_LONG_LOW_PWR_IS_4G&& seg2!=MODE_NORMAL__IS_4G){ //Seg2 3个模式都不满足则切换为默认模式 newPara.pwrMode = PMODE_DEFAULT_LOW; goto SAVE_PWR_MODE; } return; SAVE_PWR_MODE: sysIniSave(); pwrModeSetCmd(newPara.pwrMode); } #define PWR_MODE_NUM 3 void pwrModeFlash(char type,unsigned char defaultVal){ if(type==1){ if(++uiTmpVal>=3) uiTmpVal=0; }else if(type==2){ if(uiTmpVal==0) uiTmpVal=2; else uiTmpVal--; }else if(type != 0)return; newGuiClearPage(0, ROW_FOUR); switch(uiTmpVal){ case 0:newGuiShowStr(0, 48, "低功耗模式",REVERSED_NO,FONT_MODE_16X16); break; case 1:newGuiShowStr(0, 48, "超长待机模式",REVERSED_NO,FONT_MODE_16X16); break; case 2:newGuiShowStr(0, 48, "常规模式",REVERSED_NO,FONT_MODE_16X16); break; } if(uiTmpVal==defaultVal) guiShowBinMap(GLCD_WIDTH-15,48,"APN1.bin"); } void uiShowPwrSel(char StatusUpdate){ if(StatusUpdate){ newGuiClearMainPage(); newGuiShowStr(0, 16, "功耗设置",REVERSED_NO,FONT_MODE_16X16); newGuiShowStr(0, 32, "类别:",REVERSED_NO,FONT_MODE_16X16); uiTmpVal=newPara.pwrMode; pwrModeFlash(0,newPara.pwrMode); } } void uiShowPwrSelResponse(void){ unsigned short key=getKeyValue(); if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL); else if(MKEY_VALUE_MENU==key){ getStackStruct()->ok_back=1; if(uiTmpVal != newPara.pwrMode){ newPara.pwrMode=uiTmpVal; MSG_INFO(1, "pwrMode update:%d", newPara.pwrMode); sysIniSave(); pwrModeSetCmd(newPara.pwrMode); } uISetNextStatus(UIS_MENU_SYS_SEL); }else if(MKEY_VALUE_DOWN==key) pwrModeFlash(1,newPara.pwrMode); } /*****************************功耗设置结束**********************************/ /*****************************服务器设置输入密码开始**********************************/ unsigned char keybuf[6]; unsigned char keyflash=0; void KeyNumFlash(void){ static char status=0; char info[6]; static unsigned int timer; if(++timer<(500/APP_SUB_DIV_TIME) && keyflash==0) return; timer=0; if(status==0) status=1; else status=0; if(keyflash==1) status=0; else if(keyflash==2) status=1; keyflash=0; sprintf(info, "%c%c%c%c%c%c",keybuf[0],keybuf[1],keybuf[2],keybuf[3],keybuf[4],keybuf[5]); if(status) info[uiTmpVal]='*'; newGuiShowStr(0, 48, info,REVERSED_NO,FONT_MODE_16X16); } void uiShowServerPassSel(char StatusUpdate){ if(StatusUpdate){ newGuiClearMainPage(); newGuiShowStr(0, 16, "密码验证",REVERSED_NO,FONT_MODE_16X16); newGuiShowStr(0, 32, "P2移动",REVERSED_NO,FONT_MODE_16X16); memset(keybuf, '0', sizeof(keybuf)); uiTmpVal=0; } KeyNumFlash(); } void uiShowServerSelPassResponse(void){ unsigned short key=getKeyValue(); if(MKEY_VALUE_F1==key){ if(++keybuf[uiTmpVal]>'9') keybuf[uiTmpVal]='0'; keyflash=1; }else if(MKEY_VALUE_F2==key){ if(++uiTmpVal>=sizeof(keybuf)) uiTmpVal=0; keyflash=2; }else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY); else if(MKEY_VALUE_MENU==key){ if(memcmp(keybuf, getMenuKey(), 6)==0) uISetNextStatus(UIS_MENU_SYS_SERVER); else{ newGuiShowStr(0, 48, "密码错误!!!",REVERSED_NO,FONT_MODE_16X16); LSAPI_OSI_ThreadSleep(1000); getStackStruct()->ok_back=1; uISetNextStatus(UIS_MENU_SYS_FACTORY); } } } /*****************************服务器设置输入密码结束**********************************/ /*****************************服务器设置开始**********************************/ void serverFlash(unsigned char defaultVal){ newGuiClearPage(0, ROW_FOUR); switch(uiTmpVal){ case 0:newGuiShowStr(0, 48, "杭州服务器",REVERSED_NO,FONT_MODE_16X16);break; case 1:newGuiShowStr(0, 48, "山东服务器",REVERSED_NO,FONT_MODE_16X16);break; case 2:newGuiShowStr(0, 48, "IP分发服务器",REVERSED_NO,FONT_MODE_16X16);break; case 3:newGuiShowStr(0, 48, "集群服务器",REVERSED_NO,FONT_MODE_16X16);break; case 4:newGuiShowStr(0, 48, "自定义服务器",REVERSED_NO,FONT_MODE_16X16);break; } if(uiTmpVal==defaultVal) guiShowBinMap(GLCD_WIDTH-15,48,"APN1.bin"); } void uiShowServerSel(char StatusUpdate){ if(StatusUpdate){ newGuiClearMainPage(); newGuiShowStr(0, 16, "服务器列表",REVERSED_NO,FONT_MODE_16X16); newGuiShowStr(0, 32, "类别",REVERSED_NO,FONT_MODE_16X16); uiTmpVal=newPara.serList.defaultuse; serverFlash(newPara.serList.defaultuse); } } void uiShowServerSelResponse(void){ // unsigned char tempSer; // char buf[50],buf1[100]; // unsigned short key=ListBoxResponse(&sutListBox); // // if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL); // else if(MKEY_VALUE_MENU==key){ // tempSer=uiTmpVal; // if(tempSer != newPara.serList.defaultuse){ // newPara.serList.defaultuse=tempSer; // sysIniSave(); // getGIPAddr(); // snprintf(buf, sizeof(buf), "ip=%s;domain=%s;",getPIPAddr(),getDOMAINAddr()); // AscStrTurnHexStr(buf,buf1); // msgAtSend("AT+POC=010000"); // msgAtSend(buf1); // msgAtSend("\r\n"); // LSAPI_OSI_ThreadSleep(100); // msgAtSend("AT+POC=040000\r\n"); // } // uISetNextStatus(UIS_STANDBY ); // }else if(MKEY_VALUE_DOWN==key){ // if(++uiTmpVal>=5) uiTmpVal=0; // serverFlash(newPara.serList.defaultuse); // } } /*****************************服务器设置结束**********************************/ /*****************************版本设置开始**********************************/ unsigned char fotaStep; unsigned int fotaTick; void fotaStepSet(unsigned char newStep){ fotaStep=newStep; } void fotaMsgShow(char *msg){ #if 1 newGuiClearPage(0, ROW_THREE); newGuiShowStr(0, 32, msg,REVERSED_NO,FONT_MODE_16X16); #else #ifdef USE_12X12_FONT_ONLY int len=guiGetStrXLen((char *)msg,FONT_MODE_12X12); #else int len=guiGetStrXLen((char *)msg,FONT_MODE_16X16); #endif guiClearRect(0, 60, GLCD_WIDTH-1, 60+16,guiGetBackColor()); #ifdef USE_12X12_FONT_ONLY guiShowStr((GLCD_WIDTH-len)/2,60+2, msg,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor()); #else guiShowStr((GLCD_WIDTH-len)/2,60, msg,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor()); #endif #endif } void fotaMsgShow2(char *msg1, char *msg2){ #if 1 newGuiClearPage(0, ROW_THREE); newGuiShowStr(0, 32, msg1,REVERSED_NO,FONT_MODE_16X16); newGuiClearPage(0, ROW_FOUR); newGuiShowStr(0, 48, msg2,REVERSED_NO,FONT_MODE_16X16); #else guiClearRect(0, 45, GLCD_WIDTH-1, 45+16+2+16,guiGetBackColor()); int len=guiGetStrXLen((char *)msg1,FONT_MODE_16X16); guiShowStr((GLCD_WIDTH-len)/2,45, msg1,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor()); len=guiGetStrXLen((char *)msg2,FONT_MODE_16X16); guiShowStr((GLCD_WIDTH-len)/2,45+16+2, msg2,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor()); #endif } void uiShowVersionSel(char StatusUpdate){ char buf[50]; if(StatusUpdate){ sutApp.fotaVersion[0]=0; newGuiClearMainPage(); newGuiShowStr(0, 16, "版本更新",REVERSED_NO,FONT_MODE_16X16); msgAtSend("AT+FOTA?\r\n"); fotaStep=0; sutApp.fotaStatus=0; fotaMsgShow("正在检测版本."); uTimerStart(&fotaTick, 2000); } switch(fotaStep){ case 0: if(sutApp.fotaStatus==1){ fotaMsgShow("无更新版本"); fotaStep=4; break; }else if(sutApp.fotaStatus==2){ fotaMsgShow("是否更新到:"); snprintf(buf, sizeof(buf), "%s",sutApp.fotaVersion); fotaMsgShow(buf); fotaStep=1; break; } if(uTimerExpired(&fotaTick)){ fotaMsgShow("检测超时"); fotaStep=4; } break; case 1://等待用户确定 break; case 2://用户确定后等待结果 if(sutApp.fotaStatus==3){ fotaMsgShow("升级失败"); fotaStep=4; break; }else if(sutApp.fotaStatus==4){ sutApp.fotaStatus=0;//否则会一直刷新本消息 fotaMsgShow("正在下载"); break; }else if(sutApp.fotaStatus==5){ fotaMsgShow("下载成功"); fotaStep=3; break; } if(uTimerExpired(&fotaTick)){ fotaMsgShow("超时退出"); fotaStep=4; } break; case 3://升级成功,等待重启 LSAPI_OSI_ThreadSleep(1000); fotaStep=6; fotaMsgShow2("确定将关机,再","开机需约60秒"); //msgAtSend("AT+POC=050000\r\n");//停止POC后复位 //MSG_INFO(1, "Stop poc"); //LSAPI_OSI_ThreadSleep(2000); //msgAtSend("AT+TRB\r\n"); //MSG_INFO(1, "Reset system!!!"); //while(1){LSAPI_OSI_ThreadSleep(1000);} break; case 4://延时显示2秒后退出 uTimerStart(&fotaTick, 2000); fotaStep=5; break; case 5://退出升级流程 if(uTimerExpired(&fotaTick)){ getStackStruct()->ok_back=1; uISetNextStatus(UIS_MENU_SYS_FACTORY); } break; case 6://无更新版本 sutApp.timeOutCnt=0;//不让界面返回待机界面 break; } } void uiShowVersionSelResponse(void){ unsigned char key=getKeyValue(); if(fotaStep!=1 && fotaStep!=6) return; if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY); else if(MKEY_VALUE_MENU==key){ if(fotaStep==1){ fotaMsgShow("请勿断电!"); fotaStep=2; msgAtSend("AT+FOTA=1\r\n"); uTimerStart(&fotaTick, 10000); }else if(fotaStep==6){ paControl(false);//防止一直滴音 MSG_INFO(1, "Reset system!!!"); msgAtSend("AT+POC=050000\r\n"); msgAtSend("AT+TRB\r\n"); while(1){LSAPI_OSI_ThreadSleep(1000);} } } } /*****************************版本设置结束**********************************/ /*****************************工程设置开始*********************************/ void uiShowFactory(char flash){ static const char *apcPtr[]={ "服务器设置", "版本升级", "CSQ查看", "耳机MIC增益", // "耳机SPK增益", "字库更新", "" }; if(flash) dotListBoxInit(apcPtr,"工程设置",-1,-1,0); } void uiShowFactoryResponse(void){ unsigned short key; unsigned char handle; key=dotListBoxResponse(); if(MKEY_VALUE_MENU==key){ handle=dotListGetHandle(); switch(handle){ case 0://服务器设置 uISetNextStatus(UIS_MENU_SYS_SERVERPASS); break; case 1://版本升级 uISetNextStatus(UIS_MENU_SYS_VERSION); break; case 2://CSQ查看 uISetNextStatus(UIS_MENU_SYS_CSQ); break; case 3://设置mic增益 uISetNextStatus(UIS_MENU_SYS_MIC); break; //case 4://耳机SPK增益 // uISetNextStatus(UIS_MENU_SYS_SPK); // break; case 4://字库更新 uISetNextStatus(UIS_MENU_SYS_FONT); break; } if(handle<=4) uiPushStack(handle); }else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL); } /*****************************工程设置结束***********************************/ /*****************************提示音设置开始********************************/ static void switchFlash(unsigned char defaultVal){ char info[10]; if(uiTmpVal==0) snprintf(info, sizeof(info), "关闭"); else snprintf(info, sizeof(info), "打开"); newGuiClearPage(0, ROW_FOUR); newGuiShowStr(0,48,info,REVERSED_NO,FONT_MODE_16X16); if(uiTmpVal==defaultVal) guiShowBinMap(GLCD_WIDTH-15,48,"APN1.bin"); } void uiShowNoteSel(char StatusUpdate){ if(StatusUpdate){ newGuiClearMainPage(); newGuiShowStr(0, 16, "提示音设置",REVERSED_NO,FONT_MODE_16X16); newGuiShowStr(0, 32, "类别:",REVERSED_NO,FONT_MODE_16X16); uiTmpVal=newPara.KeySound; switchFlash(newPara.KeySound); } } void uiShowNoteSelResponse(void){ unsigned short key=getKeyValue(); if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL); else if(MKEY_VALUE_MENU==key){ getStackStruct()->ok_back=1; if(newPara.KeySound != uiTmpVal){ newPara.KeySound=uiTmpVal; #ifndef ENABLE_PWM_BEEP if(uiTmpVal==0) msgAtSend("AT+TONES=0\r\n"); else msgAtSend("AT+TONES=1\r\n"); #endif sysIniSave(); } uISetNextStatus(UIS_MENU_SYS_SEL); }else if(MKEY_VALUE_DOWN || MKEY_VALUE_UP){ if(uiTmpVal==0) uiTmpVal=1; else uiTmpVal=0; switchFlash(newPara.KeySound); } } /*****************************提示音设置结束********************************/ /*****************************关机界面提示开始**********************************/ void uiShowShutDown(char update){ if(update){ lcdBackLightApi(1); guiClearAll(guiGetBackColor()); guiShowCaption(0,"关机",UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12); guiShowMessageBox("确定关机?"); uiMenuShowBottomLine(); uiMenuShowBottomIndacitor("确定", "取消"); } } void uiShowShutDownResponse(void){ unsigned short key=getKeyValue(); if(MKEY_VALUE_ESC==key){ if(sutApp.waitEscReleased==0) uISetNextStatus(UIS_STANDBY); }else if(MKEY_VALUE_MENU==key){ MSG_INFO(1, "Power is off!"); appSleepCtl(ASLEEP_PWR, 1); } } /*****************************关机界面提示结束**********************************/ /*****************************CSQ查看开始********************************/ void CSQShow(unsigned int exeInterval,char StatusUpdate){ char info[30]; static int g_iCSQ=-1,cnt=1000; int y=UI_CONTENT_SHOW_Y+(GLCD_HEIGHT-UI_CONTENT_SHOW_Y)/2-12; if(g_iCSQ!=sutApp.g_iCSQ || StatusUpdate){ g_iCSQ=sutApp.g_iCSQ; snprintf(info, sizeof(info), "CSQ:%d", g_iCSQ); newGuiClearPage(0, ROW_THREE); newGuiShowStr(0, 32, info,REVERSED_NO,FONT_MODE_16X16); } if(++cnt<(1500/exeInterval)) return; cnt=0; msgAtSend("AT+CSQ\r\n"); } void uiShowCsqSel(char StatusUpdate,unsigned int exeInterval){ if(StatusUpdate){ newGuiClearMainPage(); newGuiShowStr(0, 16, "CSQ查看",REVERSED_NO,FONT_MODE_16X16); } CSQShow(exeInterval,StatusUpdate); } void uiShowCsqSelResponse(void){ unsigned short key=getKeyValue(); if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY); } /*****************************CSQ查看结束********************************/ /*******************************MIC/SPK查看************************************/ void MicSpkShow(unsigned char defaultVal){ char info[30]; unsigned short x,y,len; snprintf(info, sizeof(info), "%d",uiTmpVal+1); newGuiClearPage(0, ROW_THREE); newGuiShowStr(0, 32, info,REVERSED_NO,FONT_MODE_16X16); if(uiTmpVal==newPara.micGain) guiShowBinMap(GLCD_WIDTH-15,32,"APN1.bin"); } void uiShowMicSel(char StatusUpdate){ if(StatusUpdate){ newGuiClearMainPage(); newGuiShowStr(0, 16, "耳机MIC增益",REVERSED_NO,FONT_MODE_16X16); uiTmpVal=newPara.micGain; MicSpkShow(newPara.micGain); } } void uiShowMicSelResponse(void){ unsigned short key=getKeyValue(); if(MKEY_VALUE_DOWN==key){ if(uiTmpVal==0) uiTmpVal=MIC_GAIN_NUM-1; else uiTmpVal--; MicSpkShow(newPara.micGain); }else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY); else if(MKEY_VALUE_MENU==key){ if(uiTmpVal!= newPara.micGain){ newPara.micGain=uiTmpVal; sysIniSave(); if(sutApp.earLev!=0) VolMicUpdate(); } getStackStruct()->ok_back=1; uISetNextStatus(UIS_MENU_SYS_FACTORY); } } void uiShowSpkSel(char StatusUpdate){ if(StatusUpdate){ newGuiClearMainPage(); newGuiShowStr(0, 16, "耳机SPK增益",REVERSED_NO,FONT_MODE_16X16); uiTmpVal=newPara.spkGain; MicSpkShow(newPara.spkGain); } } void uiShowSpkSelResponse(void){ unsigned short key=getKeyValue(); if(MKEY_VALUE_DOWN==key){ if(uiTmpVal==0) uiTmpVal=SPK_GAIN_NUM-1; else uiTmpVal--; MicSpkShow(newPara.spkGain); }else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY); else if(MKEY_VALUE_MENU==key){ if(uiTmpVal!= newPara.spkGain){ newPara.spkGain=uiTmpVal; sysIniSave(); if(sutApp.earLev!=0) VolSpkUpdate(); } getStackStruct()->ok_back=1; uISetNextStatus(UIS_MENU_SYS_FACTORY); } } /******************************MIC/SPK查看结束*********************************/ /******************************fota更新生辟字库**********************************/ #include "lsapi_http.h" #define FONT_16_FILE HZK_16_NEW_FILE #define FONT_16_MD5 "HZK16_Ext_md5.txt" #define FONT_12_FILE HZK_12_NEW_FILE #define FONT_12_MD5 "HZK12_Ext_md5.txt" LSAPI_OSI_Thread_t *fontThread=NULL; short fontLoadStatus; bool fontResult; HttpInfoSet httpFont; //return:false, not finished, true, done //status:1:busy //status:-1:get 16 file failed //status:-2:16 file len err //status:-3:16 file format err //status:-4:16 ok, get 12 file failed //status:-5:16 ok, get 12 file len err //status:-6:16 ok, get 12 file fotmat err //status:0 16,12 ok bool httpFontGetStatus(short *status){//获取更新结果接口 if(fontResult==true) *status=fontLoadStatus; return fontResult; } static void fontEntry(void *param); bool httpFontGetStart(void){//开启更新接口 fontResult=false; if(NULL != fontThread) return true; fontLoadStatus=-1; fontThread=LSAPI_OSI_ThreadCreate("lteEntry", fontEntry,NULL,LSAPI_OSI_PRIORITY_NORMAL,1024*10,4); if(NULL==fontThread) return false; } void fontSaveData(unsigned char *data, unsigned int len){ int fd; char filename[30]; if(data[0]==12){ extFontFileCtl(data[0],false); snprintf(filename,sizeof(filename), "%s",FONT_12_FILE); }else if(data[0]==16){ extFontFileCtl(data[0],false); snprintf(filename,sizeof(filename), "%s",FONT_16_FILE); } else return; fd=LSAPI_FS_Open(filename, LSAPI_FS_O_RDWR | LSAPI_FS_O_CREAT | LSAPI_FS_O_TRUNC,0x0); if(fd<0){ extFontFileCtl(data[0],true); return; } LSAPI_FS_Write(fd, data, len); LSAPI_FS_Close(fd); extFontFileCtl(data[0],true); } bool checkFileMd5(char type, unsigned char *md5, unsigned int len){ int fd; char filename[30]; unsigned char rmd5[32]; if(type==0)snprintf(filename,sizeof(filename), "%s",FONT_16_MD5); else if(type==1)snprintf(filename,sizeof(filename), "%s",FONT_12_MD5); else return false; fd=LSAPI_FS_Open(filename, LSAPI_FS_O_RDONLY,0); if(fd<0){ MSG_WARN(1, "'%s' open failed to read", filename); return false; } LSAPI_FS_Read(fd, rmd5, sizeof(rmd5)); LSAPI_FS_Close(fd); if(0==memcmp(rmd5, md5, len)) return true; else return false; } void fontSaveMd5(char type, unsigned char *md5, unsigned int len){ int fd; char filename[30]; if(type==0)snprintf(filename,sizeof(filename), "%s",FONT_16_MD5); else if(type==1)snprintf(filename,sizeof(filename), "%s",FONT_12_MD5); else return; fd=LSAPI_FS_Open(filename, LSAPI_FS_O_RDWR | LSAPI_FS_O_CREAT | LSAPI_FS_O_TRUNC,0); if(fd<0){ MSG_WARN(1, "'%s' open failed to save", filename); return; } LSAPI_FS_Write(fd, md5, len); LSAPI_FS_Close(fd); } static void fontEntry(void *param){ bool font12_noneed_update=true; bool font16_noneed_update=true; char type=0; unsigned int md5_len; unsigned char rmd5[32]; bool needClear=true; //get 16 md5 MSG_INFO(1,"try get 16 md5"); memset(&httpFont, 0, sizeof(httpFont));httpFont.cid=1; snprintf(httpFont.url, sizeof(httpFont.url),"http://120.77.66.129/higos/extFonts/%s",FONT_16_MD5); if(LSAPI_HTTP_GET(&httpFont)){ fontLoadStatus=-2; goto FONT_END; } //ana 16 md5 if(httpFont.recvlen!=32){ fontLoadStatus=-3; goto FONT_END; } md5_len=httpFont.recvlen; memcpy(rmd5, httpFont.RecvData, md5_len); LSAPI_HTTP_ParaClear(&httpFont); font16_noneed_update=checkFileMd5(type, rmd5, md5_len); if(false==font16_noneed_update){ MSG_INFO(1,"try get 16 file"); //get 16 first memset(&httpFont, 0, sizeof(httpFont));httpFont.cid=1; snprintf(httpFont.url, sizeof(httpFont.url),"http://120.77.66.129/higos/extFonts/%s",FONT_16_FILE); if(LSAPI_HTTP_GET(&httpFont)){//尝试获取差分包 fontLoadStatus=-4; goto FONT_END; } if(httpFont.recvlen<35){//1+[2+32].... fontLoadStatus=-5; goto FONT_END; }else if(httpFont.RecvData[0]!=16 || (httpFont.recvlen-1)%34){ fontLoadStatus=-6; goto FONT_END; } fontSaveData(httpFont.RecvData, httpFont.recvlen); fontSaveMd5(type, rmd5, md5_len); LSAPI_HTTP_ParaClear(&httpFont); } type=1; //get 12 md5 MSG_INFO(1,"try get 12 md5"); memset(&httpFont, 0, sizeof(httpFont));httpFont.cid=1; snprintf(httpFont.url, sizeof(httpFont.url),"http://120.77.66.129/higos/extFonts/%s",FONT_12_MD5); if(LSAPI_HTTP_GET(&httpFont)){ fontLoadStatus=-7; goto FONT_END; } //ana 12 md5 if(httpFont.recvlen!=32){ fontLoadStatus=-8; goto FONT_END; } md5_len=httpFont.recvlen; memcpy(rmd5, httpFont.RecvData, md5_len); LSAPI_HTTP_ParaClear(&httpFont); font12_noneed_update=checkFileMd5(type, rmd5, md5_len); if(false==font12_noneed_update){ MSG_INFO(1,"try get 12 file"); //get 12 then memset(&httpFont, 0, sizeof(httpFont));httpFont.cid=1; snprintf(httpFont.url, sizeof(httpFont.url),"http://120.77.66.129/higos/extFonts/%s",FONT_12_FILE); if(LSAPI_HTTP_GET(&httpFont)){//尝试获取差分包 fontLoadStatus=-9; goto FONT_END; } if(httpFont.recvlen<27){//1+[2+24].... fontLoadStatus=-10; goto FONT_END; }else if(httpFont.RecvData[0]!=12 || (httpFont.recvlen-1)%26){ fontLoadStatus=-11; goto FONT_END; } fontSaveData(httpFont.RecvData, httpFont.recvlen); fontSaveMd5(type, rmd5, md5_len); LSAPI_HTTP_ParaClear(&httpFont); needClear=false; }else needClear=false; if(font12_noneed_update==true && font16_noneed_update==true) fontLoadStatus=0; else fontLoadStatus=1; FONT_END: fontThread=NULL; fontResult=true; if(needClear==true) LSAPI_HTTP_ParaClear(&httpFont); LSAPI_OSI_ThreadExit(); } //6、UI接口界面(供参考) char fontUpdateStatus=0; void uiShowFontUpdate(char StatusUpdate){ static unsigned int timer; short status; if(StatusUpdate){ newGuiClearMainPage(); newGuiShowStr(0, 16, "字库更新",REVERSED_NO,FONT_MODE_16X16); newGuiShowStr(0, 32, "确定更新?",REVERSED_NO,FONT_MODE_16X16); fontUpdateStatus=0; } if(fontUpdateStatus==1){ if(true==httpFontGetStatus(&status)){ if(status==1){ newGuiShowStr(0, 32, "更新成功",REVERSED_NO,FONT_MODE_16X16); uTimerStart(&timer, 2000); }else if(status==0){ newGuiShowStr(0, 32, "无需更新",REVERSED_NO,FONT_MODE_16X16); uTimerStart(&timer, 2000); }else{ newGuiShowStr(0, 32, "更新失败",REVERSED_NO,FONT_MODE_16X16); uTimerStart(&timer, 2000); } fontUpdateStatus=2; } }else if(fontUpdateStatus==2){ if(uTimerExpired(&timer)){ getStackStruct()->ok_back=1; uISetNextStatus(UIS_MENU_SYS_FACTORY); } } } void uiShowFontUpdateResponse(){ unsigned short key=getKeyValue(); if(fontUpdateStatus!=0) return; if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY); else if(MKEY_VALUE_MENU==key){ httpFontGetStart(); fontUpdateStatus=1; newGuiShowStr(0, 32, "正在更新.",REVERSED_NO,FONT_MODE_16X16); } } /******************************fota更新生辟字库结束***********************************/ #ifdef USE_LEFT_MOVING /***************************主界面滚动显示**********************************/ #define MOVING_ITME_NUM 3 //显示三条项目 #define MAX_ROW_BYTE (20+1+2) //最多显示20个字节,10个中文 #define MAX_SHOW_BYTE 11 //最多一次性显示10个字节 void leftMoveStr(char *name, unsigned short len){ char temp[3]; unsigned char move=1; unsigned short i; if(name[0] > 0x80) move=2; for(i=0;i0x80){ if(i+2>cpsize){//装不下了,停止 break; } des[i]=src[i]; des[i+1]=src[i+1]; i++; }else des[i]=src[i]; } des[i]=0; } void showbufdata(char type, unsigned char *data, int len){ char info[100],buf[3]; int i; sprintf(info, "D[%d]%c:",len,type); for(i=0;iMAX_SHOW_BYTE) needMove=1; else needMove=0; if(*sum != tsum || reset){ newGuiClearPage(0,showPage); newGuiShowStr(showX, showY, &indicators[i][0], REVERSED_NO, FONT_MODE_16X16); } showX += 40; if(needMove==0){ if(*sum != tsum || reset){//内容发生了变化 //只显示一次即可 snprintf(showPtr, MAX_ROW_BYTE, "%s", ptr); newGuiClearPage(showX,showPage); newGuiShowStr(showX, showY, showPtr, REVERSED_NO, FONT_MODE_16X16); } }else{//做移动处理 if(*sum != tsum) memcpy(showPtr, ptr, MAX_ROW_BYTE); else leftMoveStr(showPtr, strlen(showPtr)); getRealShow(showMax, showPtr,MAX_SHOW_BYTE); newGuiClearPage(showX,showPage); newGuiShowStr(showX, showY, showMax, REVERSED_NO, FONT_MODE_16X16); } *sum=tsum; } } #endif /*****************************提示音设置开始********************************/ #define LOCK_MODE_NUM 2 void lockFlash(unsigned char defaultVal){ char info[20]; newGuiClearPage(0, ROW_FOUR); if(uiTmpVal==0) snprintf(info, sizeof(info), "锁按键"); else snprintf(info,sizeof(info), "锁按键+PTT"); newGuiShowStr(0, 48, info,REVERSED_NO,FONT_MODE_16X16); if(uiTmpVal==defaultVal) guiShowBinMap(GLCD_WIDTH-15,48,"APN1.bin"); } void uiShowLockUpdate(char StatusUpdate){ if(StatusUpdate){ newGuiClearMainPage(); newGuiShowStr(0, 16, "键锁设置",REVERSED_NO,FONT_MODE_16X16); newGuiShowStr(0, 32, "类别:",REVERSED_NO,FONT_MODE_16X16); uiTmpVal=newPara.lockType; lockFlash(newPara.lockType); } } void uiShowLockUpdateResponse(void){ unsigned short key=getKeyValue(); if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL); else if(MKEY_VALUE_MENU==key){ getStackStruct()->ok_back=1; if(newPara.lockType != uiTmpVal){ newPara.lockType=uiTmpVal; sysIniSave(); } uISetNextStatus(UIS_MENU_SYS_SEL); }else if(MKEY_VALUE_DOWN==key){ if(uiTmpVal==0) uiTmpVal=1; else uiTmpVal=0; lockFlash(newPara.lockType); } } /*****************************提示音设置结束********************************/