uiBlock.c 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663
  1. #include "includes.h"
  2. /****************************状态栏显示部分开始***********************************/
  3. #define MIN_PWR_LEVEL 315 //低于此电压后不工作
  4. #define WARN_PWR_LEVEL 325 //提示请充电电压
  5. static const char *NullPtr="";
  6. //显示信号强度
  7. static void ShowSingle(int CSQ){
  8. unsigned short x=SIGNAL_ICON_X;
  9. unsigned short y=2;
  10. if(sutApp.pocPpp == 0) guiShowBmp(x,y,"Single.bmp");
  11. else guiShowBmp(x,y,"SingleOK.bmp");
  12. //11 3格
  13. x += 7;
  14. if(CSQ<1 || CSQ==99){
  15. guiClearRect(x,y+1,x+10,y+9,COLOR_STATUS_BAR);
  16. }else if(CSQ<8){
  17. guiDrawVLine(x+2,y+8,x,y,guiGetBackColor());
  18. guiClearRect(x+2,y+1,x+10,y+9,COLOR_STATUS_BAR);
  19. }else if(CSQ<16){
  20. guiDrawVLine(x+2,y+8,x,y,guiGetBackColor());
  21. guiDrawVLine(x,y+8,x+3,y,guiGetBackColor());
  22. guiClearRect(x+6,y+1,x+10,y+9,COLOR_STATUS_BAR);
  23. }else if(CSQ<22){
  24. guiDrawVLine(x+2,y+8,x,y,guiGetBackColor());
  25. guiDrawVLine(x,y+8,x+3,y,guiGetBackColor());
  26. guiDrawVLine(x-2,y+8,x+6,y,guiGetBackColor());
  27. guiClearRect(x+9,y+1,x+10,y+9,COLOR_STATUS_BAR);
  28. }else{
  29. guiDrawVLine(x+2,y+8,x,y,guiGetBackColor());
  30. guiDrawVLine(x,y+8,x+3,y,guiGetBackColor());
  31. guiDrawVLine(x-2,y+8,x+6,y,guiGetBackColor());
  32. guiDrawVLine(x-4,y+8,x+9,y,guiGetBackColor());
  33. }
  34. #if 0
  35. if(CSQ<1 || CSQ==99){
  36. guiClearRect(7,3,21,11,COLOR_STATUS_BAR);
  37. }else if(CSQ<8){
  38. guiDrawVLine(9,10,7,2,guiGetBackColor());
  39. guiClearRect(9,3,21,11,COLOR_STATUS_BAR);
  40. }else if(CSQ<16){
  41. guiDrawVLine(9,10,7,2,guiGetBackColor());
  42. guiDrawVLine(7,10,10,2,guiGetBackColor());
  43. guiClearRect(13,3,21,11,COLOR_STATUS_BAR);
  44. }else if(CSQ<22){
  45. guiDrawVLine(9,10,7,2,guiGetBackColor());
  46. guiDrawVLine(7,10,10,2,guiGetBackColor());
  47. guiDrawVLine(5,10,13,2,guiGetBackColor());
  48. guiClearRect(16,3,21,11,COLOR_STATUS_BAR);
  49. }else{
  50. guiDrawVLine(9,10,7,2,guiGetBackColor());
  51. guiDrawVLine(7,10,10,2,guiGetBackColor());
  52. guiDrawVLine(5,10,13,2,guiGetBackColor());
  53. guiDrawVLine(3,10,16,2,guiGetBackColor());
  54. }
  55. #endif
  56. }
  57. unsigned char netshowvalue=0xff;
  58. //显示网络制式
  59. static void Show_Net(unsigned char s_netshowvalue){
  60. unsigned short y=0;
  61. if(s_netshowvalue==0){
  62. guiShowStr(NET_ICON_X, y+1,"2G", FONT_MODE_12X12, REVERSED_NO,guiGetBackColor(),COLOR_STATUS_BAR);
  63. }else if(s_netshowvalue==4){
  64. guiShowStr(NET_ICON_X, y+1,"4G", FONT_MODE_12X12, REVERSED_NO,guiGetBackColor(),COLOR_STATUS_BAR);
  65. }else guiClearRect(NET_ICON_X,y,NET_ICON_X+NET_ICON_WX,y+11,COLOR_STATUS_BAR);
  66. }
  67. static void gpsIconShow(char flash){
  68. typedef struct{
  69. unsigned char located:1;
  70. unsigned char auth:1;
  71. unsigned char gpsF:1;
  72. }TMP_GPS_DEF;
  73. static TMP_GPS_DEF tmpGps;
  74. unsigned short x=GPS_ICON_X,y=0;
  75. if(tmpGps.located==gpsInfo.gpsLocated && tmpGps.auth==gpsInfo.bbAuth && tmpGps.gpsF==gpsInfo.gpsF && flash==0) return;
  76. guiClearRect(x,y,x+GPS_ICON_WX,y+11,COLOR_STATUS_BAR);
  77. if(gpsInfo.gpsF==0){//GPS未打开时
  78. if(gpsInfo.bbAuth==1) guiShowBmp(x,y,"GPS3.bmp");//已鉴权
  79. }else{//GPS已打开
  80. if(gpsInfo.bbAuth==1) guiShowBmp(x,y,"GPS1.bmp");//已鉴权
  81. else if(gpsInfo.bbAuth==1) guiShowBmp(x,y,"GPSA.bmp");//未鉴权
  82. if(gpsInfo.gpsLocated==1) guiShowBmp(x+10,y,"GPS2.bmp");//已定位
  83. }
  84. tmpGps.located=gpsInfo.gpsLocated;
  85. tmpGps.auth=gpsInfo.bbAuth;
  86. tmpGps.gpsF=gpsInfo.gpsF;
  87. }
  88. //显示电量
  89. static void ShowBatttery(int bat,unsigned int exeInterval){
  90. static unsigned int flashCnt=0;
  91. static unsigned char flag=0;
  92. static unsigned short cnt=0;
  93. unsigned short x=BAT_ICON_X,y=2,h=y+2;
  94. if(bat<WARN_PWR_LEVEL){//请充电
  95. if(++cnt<(800/exeInterval)) return;
  96. cnt=0;
  97. if(flag==0){
  98. guiShowBmp(x,y,"VBAT1.bmp");
  99. flag=1;
  100. }else{
  101. flag=0;
  102. guiClearRect(x,y-2,x+21,y-2+1+11,COLOR_STATUS_BAR);
  103. }
  104. }else if(bat<355){//340<x<=355 1格
  105. guiShowBmp(x,y,"VBAT1.bmp");//3
  106. guiDrawVLine(h,h+5,x+16,y+1,guiGetBackColor());
  107. }
  108. else if(bat<375){//355<x<=375 2格
  109. guiShowBmp(x,y,"VBAT1.bmp");
  110. guiDrawVLine(h,h+5,x+12,y+1,guiGetBackColor());
  111. guiDrawVLine(h,h+5,x+16,y+1,guiGetBackColor());//5.12
  112. }
  113. else if(bat<400){//375<x<=400 3格
  114. guiShowBmp(x,y,"VBAT1.bmp");
  115. guiDrawVLine(h,h+5,x+8,y+1,guiGetBackColor());
  116. guiDrawVLine(h,h+5,x+12,y+1,guiGetBackColor());
  117. guiDrawVLine(h,h+5,x+16,y+1,guiGetBackColor());//5.12
  118. }
  119. else{//>=400 4格
  120. guiShowBmp(x,y,"VBAT1.bmp");
  121. guiDrawVLine(h,h+5,x+4,y+1,guiGetBackColor());
  122. guiDrawVLine(h,h+5,x+8,y+1,guiGetBackColor());
  123. guiDrawVLine(h,h+5,x+12,y+1,guiGetBackColor());
  124. guiDrawVLine(h,h+5,x+16,y+1,guiGetBackColor());//5.12
  125. }
  126. }
  127. //显示时间
  128. static void ShowTime(char flash,unsigned int exeInterval){
  129. static unsigned short nextExe=0;
  130. static unsigned char flag=0;
  131. MY_CLOCK myclock;
  132. char buf[30];
  133. if(nextExe==0 || flash){
  134. ohpocGetClock(&myclock);
  135. if(flag){
  136. snprintf(buf, sizeof(buf), "%02d:%02d",myclock.hour, myclock. min);
  137. flag=0;
  138. }else{
  139. snprintf(buf, sizeof(buf), "%02d %02d",myclock.hour, myclock. min);
  140. flag=1;
  141. }
  142. guiShowStr(TIME_ICON_X, 1,buf, FONT_MODE_12X12, REVERSED_NO,guiGetBackColor(),COLOR_STATUS_BAR);
  143. }
  144. if(++nextExe>=(1000/exeInterval)) nextExe=0;
  145. }
  146. //显示状态栏
  147. void uiShowStatusBar(char flash,unsigned int exeInterval){
  148. static unsigned char s_netshowvalue=0xff;
  149. static unsigned char lastPPPStatus;
  150. static int siCSQ;
  151. static int siVbat;
  152. static unsigned short batFirstShow=0;
  153. static char lastEnable=0;
  154. char tempFlash=flash;
  155. if(sutApp.enableKey==0) return;
  156. if(lastEnable==0){
  157. lastEnable=1;
  158. tempFlash=1;
  159. guiFillRect(0, 0, GLCD_WIDTH-1, UI_STATUS_BAR_HEIGH-1,COLOR_STATUS_BAR);//清除第一区
  160. }
  161. //显示信号
  162. if(tempFlash || siCSQ!=sutApp.g_iCSQ || lastPPPStatus != sutApp.pocPpp){
  163. lastPPPStatus=sutApp.pocPpp;
  164. siCSQ=sutApp.g_iCSQ;
  165. ShowSingle(sutApp.g_iCSQ);
  166. }
  167. //显示2G/3G/4G
  168. if(tempFlash || s_netshowvalue!=netshowvalue){
  169. s_netshowvalue=netshowvalue;
  170. Show_Net(s_netshowvalue);
  171. }
  172. //显示GPS是否正常及鉴权情况
  173. gpsIconShow(tempFlash);
  174. //电量显示
  175. if(batFirstShow < (1000/exeInterval)) {//开机前1秒显示一半电量
  176. sutApp.g_iBAT=360;
  177. batFirstShow++;
  178. }else if(tempFlash || siVbat!=sutApp.g_iBAT || sutApp.g_iBAT < WARN_PWR_LEVEL){
  179. siVbat=sutApp.g_iBAT;
  180. ShowBatttery(sutApp.g_iBAT,exeInterval);
  181. //MSG_INFO(1, "----%d", sutApp.g_iBAT);
  182. }
  183. //文本消息显示
  184. ShowMessageFlag(0);
  185. //GPS显示
  186. //时间显示
  187. ShowTime(tempFlash,exeInterval);
  188. //显示锁,UI状态变化时更新
  189. if(tempFlash && sutUIstatus.Status==UIS_STANDBY){
  190. if(sutApp.keyLock==0) guiClearRect(72,110,72+17,110+17,guiGetBackColor());
  191. else guiShowBmp(72,110, "lock.bmp");
  192. }
  193. }
  194. /****************************状态栏显示部分结束***********************************/
  195. /****************************待机界面显示部分开始***********************************/
  196. typedef enum{
  197. ME_NO_LOGIN,
  198. ME_NOBODY_SPEAK,
  199. ME_IAM_SPEAK,
  200. ME_SOMEBODY_SPEAK
  201. }ME_ENUM;
  202. static void uiShowGUName(int update);
  203. static void uiShowGuaDuan(unsigned char danhu);
  204. static void uiShowGroup(const char* info);
  205. static void uiShowUser(const char* info);
  206. static void uiShowHuaQuan(const char* info,char type);
  207. static void uiShowCallUserName(void);
  208. static void uiShowOffLineMessage(void);
  209. void uiShowMainInterface(char status,unsigned int exeInterval){
  210. short Flag=ME_NO_LOGIN;//ME_ENUM
  211. static unsigned char danhu=0;
  212. static short lastFlag=-1;
  213. static unsigned short siCt=0;
  214. char info[40];
  215. static char firstRun=0;
  216. static unsigned short dly=0;
  217. char tmpStatus=status;
  218. /*延时一下1秒后才显示后面的,如果直接登录了,就跳出延时*/
  219. if(firstRun==0){
  220. if((++dly>=(3*1000/exeInterval)) || sutPocStatus.logined!=0){
  221. firstRun=1;
  222. tmpStatus=1;
  223. sutApp.enableKey=1;//延时按键操作完成
  224. }else return;
  225. }
  226. /*逻辑处理开始*/
  227. if(tmpStatus){
  228. guiClearAll(guiGetBackColor());
  229. guiShowCaption(0,"加速度语音系统", UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  230. #ifdef DEVELOP_MODE
  231. guiShowStr(1, UI_BOTTOM_SHOW_Y,"研发版本", FONT_MODE_12X12, REVERSED_NO,guiGetBackColor(),COLOR_STATUS_BAR);
  232. #else
  233. guiShowStr(1, UI_BOTTOM_SHOW_Y,"菜单", FONT_MODE_12X12, REVERSED_NO,COLOR_STATUS_BAR, guiGetBackColor());
  234. #endif
  235. danhu=sutPocStatus.danHuStatus;
  236. uiShowGuaDuan(danhu);
  237. lastFlag=-1;
  238. siCt=0;
  239. return;
  240. }
  241. //更新单呼显示与否
  242. if(sutPocStatus.danHuStatus != danhu){
  243. danhu=sutPocStatus.danHuStatus;
  244. uiShowGuaDuan(danhu);
  245. }
  246. //提示解锁
  247. if(sutApp.lockShow!=0){
  248. guiShowMessageBox("请先解锁!");
  249. nwy_sleep(500);
  250. guiClearRect(0,GLCD_HEIGHT/2-20,GLCD_WIDTH-1,GLCD_HEIGHT/2+20,guiGetBackColor());
  251. lastFlag=-1;//让以下刷新一下
  252. sutApp.lockShow=0;
  253. }
  254. //以下持续调用,以便动态更新信息
  255. if(0==sutPocStatus.logined) Flag=ME_NO_LOGIN;//未登录
  256. else if(0==sutPocStatus.spk && 0==sutPocStatus.mic){//已登录,无人说话
  257. Flag=ME_NOBODY_SPEAK;
  258. }else if(0!=sutPocStatus.mic) Flag=ME_IAM_SPEAK;//已登录,本机说话
  259. else if(0!=sutPocStatus.spk) Flag=ME_SOMEBODY_SPEAK;//有人说话
  260. switch(Flag){
  261. case ME_NO_LOGIN://未登录
  262. if(Flag != lastFlag){
  263. guiFillRect(0, UI_CONTENT_SHOW_Y, GLCD_WIDTH-1, UI_BOTTOM_SHOW_Y-1,guiGetBackColor());
  264. guiShowBmp(0,UI_CONTENT_SHOW_Y, "logo.bmp");
  265. }
  266. break;
  267. case ME_NOBODY_SPEAK://已登录,无人说话
  268. if(Flag != lastFlag){
  269. if(ME_NO_LOGIN==lastFlag) guiFillRect(0, UI_CONTENT_SHOW_Y, GLCD_WIDTH-1, UI_CONTENT_SHOW_Y+16,guiGetBackColor());//从未登录到登录,'正在登录'那行也刷掉
  270. guiFillRect(0, UI_VOICE_SHOW_Y, GLCD_WIDTH-1, UI_VOICE_SHOW_Y+16,guiGetBackColor());
  271. uiShowHuaQuan("空闲",0);
  272. sutPocStatus.statusChaned = 1;
  273. }
  274. break;
  275. case ME_IAM_SPEAK://已登录,本机说话
  276. if(Flag != lastFlag){
  277. guiFillRect(0, UI_VOICE_SHOW_Y, GLCD_WIDTH-1, UI_VOICE_SHOW_Y+16,guiGetBackColor());
  278. uiShowHuaQuan("本机在讲话",1);
  279. }
  280. break;
  281. case ME_SOMEBODY_SPEAK://已登录,有人说话
  282. if(Flag != lastFlag){
  283. guiFillRect(0, UI_VOICE_SHOW_Y, GLCD_WIDTH-1, UI_VOICE_SHOW_Y+16,guiGetBackColor());
  284. sutPocStatus.statusChaned=1;//保证要刷新名字
  285. }
  286. uiShowCallUserName();
  287. break;
  288. }
  289. if(Flag>0){//已登录
  290. if(Flag != lastFlag && (lastFlag==-1 || ME_NO_LOGIN==lastFlag)){
  291. uiShowGUName(1);
  292. uiShowLearnGroup(1);
  293. }else{
  294. uiShowGUName(0);
  295. uiShowLearnGroup(0);
  296. }
  297. }else{//未登录
  298. snprintf(info, sizeof(info),"请等待网络连接.");
  299. switch(siCt){//not finished yet
  300. case 0:
  301. strcat(info, " ");
  302. guiShowStr(1, UI_CONTENT_SHOW_Y,info, FONT_MODE_12X12, REVERSED_NO,COLOR_STATUS_BAR,guiGetBackColor());
  303. break;
  304. case (1000/APP_SUB_DIV_TIME):
  305. strcat(info, ". ");
  306. guiShowStr(1, UI_CONTENT_SHOW_Y,info, FONT_MODE_12X12, REVERSED_NO,COLOR_STATUS_BAR,guiGetBackColor());
  307. break;
  308. case (2000/APP_SUB_DIV_TIME):
  309. strcat(info, "..");
  310. guiShowStr(1, UI_CONTENT_SHOW_Y,info, FONT_MODE_12X12, REVERSED_NO,COLOR_STATUS_BAR,guiGetBackColor());
  311. break;
  312. }
  313. //显示登录状态
  314. uiShowOffLineMessage();
  315. }
  316. if(++siCt>=(3000/APP_SUB_DIV_TIME)) siCt=0;
  317. if(Flag != lastFlag) lastFlag=Flag;
  318. }
  319. static void uiShowGUName(int update){
  320. static char scNameUser[POC_GROUP_USER_NAME_LEN];
  321. static char scNameGroup[POC_GROUP_USER_NAME_LEN];
  322. char name[POC_GROUP_USER_NAME_LEN];
  323. unsigned short len;
  324. unsigned char danHuanBuffer[9]={0xB5,0xA5,0xBA,0xF4,0xC4,0xA3,0xCA,0xBD,0};
  325. char GroupShowUpdate=0;
  326. char UserShowUpdate=0;
  327. if(sutPocStatus.danHuStatus==0){
  328. if(0!=strcmp(sutPocStatus.LocalGroup.name,scNameGroup) || update!=0){
  329. memset(scNameGroup,0,sizeof(scNameGroup));
  330. memcpy(scNameGroup,sutPocStatus.LocalGroup.name,sizeof(scNameGroup));
  331. GroupShowUpdate=1;
  332. }
  333. }else{
  334. if(0!=strcmp((char *)danHuanBuffer,scNameGroup) || update!=0){
  335. memset(scNameGroup,0,sizeof(scNameGroup));
  336. memcpy(scNameGroup, danHuanBuffer,sizeof(danHuanBuffer));
  337. GroupShowUpdate=1;
  338. }
  339. }
  340. if(0!=strcmp(sutPocStatus.LocalUser.name,scNameUser) || update!=0){
  341. memset(scNameUser,0,sizeof(scNameUser));
  342. memcpy(scNameUser,sutPocStatus.LocalUser.name,sizeof(scNameUser));
  343. UserShowUpdate=1;
  344. }
  345. if(GroupShowUpdate){
  346. guiClearRect(0,UI_GROUP_SHOW_Y,GLCD_WIDTH-1,UI_GROUP_SHOW_Y+16,guiGetBackColor());//18
  347. //刷新群组栏
  348. if(sutPocStatus.danHuStatus==0) StrIntercept(name, scNameGroup, sizeof(name));
  349. else snprintf(name, sizeof(name), "单呼模式");
  350. uiShowGroup(name);
  351. sutPocStatus.statusChaned=1;
  352. }
  353. if(UserShowUpdate){
  354. guiClearRect(0,UI_USER_SHOW_Y,GLCD_WIDTH-1,UI_GROUP_SHOW_Y+16,guiGetBackColor());//18
  355. //刷新成员栏
  356. StrIntercept(name, scNameUser, sizeof(name));
  357. uiShowUser(name);
  358. }
  359. }
  360. void uiShowLearnGName(const char *name){
  361. guiClearRect(2, UI_LEARN_SHOW_Y, GLCD_WIDTH-1, UI_LEARN_SHOW_Y+16, guiGetBackColor());
  362. guiShowBmp(2, UI_LEARN_SHOW_Y, "Group2.bmp");
  363. guiShowStr(2+16, UI_LEARN_SHOW_Y, "学习组:", FONT_MODE_16X16, REVERSED_NO,guiGetForeColor(),guiGetBackColor());
  364. guiShowStr(2+16+56, UI_LEARN_SHOW_Y,name, FONT_MODE_16X16, REVERSED_NO,guiGetForeColor(),guiGetBackColor());
  365. }
  366. static void uiShowGuaDuan(unsigned char danhu){
  367. if(danhu==0) guiClearArea(GLCD_WIDTH-32, UI_BOTTOM_SHOW_Y, 32, 14, guiGetBackColor());
  368. else guiShowStr(GLCD_WIDTH-32, UI_BOTTOM_SHOW_Y, "挂断", FONT_MODE_12X12, REVERSED_NO, COLOR_STATUS_BAR,guiGetBackColor());
  369. }
  370. static void uiShowGroup(const char* info){
  371. unsigned int color=guiGetForeColor();
  372. guiClearRect(2, UI_GROUP_SHOW_Y, GLCD_WIDTH-1, UI_GROUP_SHOW_Y+16, guiGetBackColor());
  373. if(sutPocStatus.danHuStatus==0) guiShowBmp(2, UI_GROUP_SHOW_Y, "Group2.bmp");
  374. else{
  375. guiShowBmp(2, UI_GROUP_SHOW_Y, "Onecall.bmp");
  376. color=COLOR_RED;
  377. }
  378. guiShowStr(2+16, UI_GROUP_SHOW_Y, "对讲组:", FONT_MODE_16X16, REVERSED_NO,color,guiGetBackColor());
  379. guiShowStr(2+16+56, UI_GROUP_SHOW_Y,info, FONT_MODE_16X16, REVERSED_NO,color,guiGetBackColor());
  380. }
  381. static void uiShowUser(const char* info){
  382. guiClearRect(2, UI_USER_SHOW_Y, GLCD_WIDTH-1, UI_USER_SHOW_Y+16, guiGetBackColor());
  383. guiShowBmp(2, UI_USER_SHOW_Y, "people2.bmp");
  384. guiShowStr(2+16, UI_USER_SHOW_Y,"昵称:", FONT_MODE_16X16, REVERSED_NO,guiGetForeColor(),guiGetBackColor());
  385. guiShowStr(2+16+40, UI_USER_SHOW_Y,info, FONT_MODE_16X16, REVERSED_NO,guiGetForeColor(),guiGetBackColor());
  386. }
  387. static void uiShowHuaQuan(const char* info,char type){
  388. unsigned int color=guiGetForeColor();
  389. guiClearRect(2, UI_VOICE_SHOW_Y, GLCD_WIDTH-1, UI_VOICE_SHOW_Y+16, guiGetBackColor());
  390. if(type==0) guiShowBmp(2, UI_VOICE_SHOW_Y, "Phone.bmp");
  391. else if(type==1){
  392. color=COLOR_RED;
  393. guiShowBmp(2, UI_VOICE_SHOW_Y, "Csend.bmp");
  394. }else if(type==2){
  395. guiShowBmp(2, UI_VOICE_SHOW_Y, "Creceive.bmp");
  396. color=COLOR_DEEP_GREEN;
  397. }
  398. guiShowStr(2+16, UI_VOICE_SHOW_Y,info, FONT_MODE_16X16, REVERSED_NO,color,guiGetBackColor());
  399. }
  400. static void uiShowCallUserName(void){
  401. static char scName[POC_GROUP_USER_NAME_LEN];
  402. char name[POC_GROUP_USER_NAME_LEN];
  403. if(0 != strncmp(scName, sutPocStatus.CallName, POC_GROUP_USER_NAME_LEN) ||
  404. sutPocStatus.statusChaned){
  405. //当名字变更或UI切换了,刷新显示
  406. sutPocStatus.statusChaned=0;
  407. memcpy(scName, sutPocStatus.CallName, POC_GROUP_USER_NAME_LEN);
  408. uiShowHuaQuan(scName,2);
  409. }
  410. }
  411. static void uiShowOffLineMessage(void){
  412. static unsigned char laReason;
  413. char info[50],update=0;
  414. unsigned short y;
  415. if(sutUIstatus.Status != UIS_STANDBY) return;
  416. if(sutPocStatus.PocLineOffReason==laReason && sutUIstatus.ItemRefresh==0) return;
  417. sutUIstatus.ItemRefresh=0;
  418. laReason=sutPocStatus.PocLineOffReason;
  419. if(sutApp.cardStatus==0){
  420. snprintf(info, sizeof(info), "请插卡");
  421. update=1;
  422. }else{
  423. switch(sutPocStatus.PocLineOffReason){
  424. case 1:snprintf(info, sizeof(info), "无网络连接");break;
  425. case 2:snprintf(info, sizeof(info), "无法连接");break;
  426. case 3:snprintf(info, sizeof(info), "没有服务");break;
  427. case 4:snprintf(info, sizeof(info), "账号信息错误");break;
  428. }
  429. if(sutPocStatus.PocLineOffReason!=0) update=1;
  430. }
  431. if(update!=0){
  432. y=UI_CONTENT_SHOW_Y+2+12;
  433. guiClearRect(1,y, GLCD_WIDTH-1, y +12, guiGetBackColor());
  434. guiShowStr(1, y,info, FONT_MODE_12X12, REVERSED_NO,COLOR_STATUS_BAR,guiGetBackColor());
  435. }
  436. }
  437. /****************************待机界面显示部分结束***********************************/
  438. #ifdef MAKE_IT_COMMON_VERSION
  439. #define LEARN_TASK_SEG "消息列表"
  440. #define LEARN_RANK_SEG "考勤信息"
  441. #define LEARN_GROUP_SEG "群组选择"
  442. #define LEARN_USER_SEG "成员选择"
  443. #else
  444. #define LEARN_TASK_SEG "学习任务"
  445. #define LEARN_RANK_SEG "学习排名"
  446. #define LEARN_GROUP_SEG "班级选择"
  447. #define LEARN_USER_SEG "同学选择"
  448. #endif
  449. /****************************主菜单显示部分开始*************************************/
  450. #include "Palace.h"
  451. SUT_PALACE sutPalace;
  452. void uiShowMenuMain(char update){
  453. static const char *apcMenuMain[]={
  454. #ifdef MAKE_IT_COMMON_VERSION
  455. "消息列表",
  456. "考勤信息",
  457. "群组选择",
  458. "成员选择",
  459. "定位设置",
  460. #else
  461. "学习任务",
  462. "学习排名",
  463. "班级选择",
  464. "同学选择",
  465. "消息通知",
  466. #endif
  467. "系统信息",
  468. ""
  469. };
  470. if(update) PalaceInit(&sutPalace,apcMenuMain,"Palace","主菜单");
  471. }
  472. void MenuMainResponse(void){
  473. unsigned short key;
  474. key=PalaceResponse(&sutPalace);
  475. if(MKEY_VALUE_MENU==key){
  476. switch(sutPalace.Index){
  477. case 0:
  478. #ifndef MAKE_IT_COMMON_VERSION
  479. uISetNextStatus(UIS_MENU_TASK_SEL);
  480. #endif
  481. break;
  482. case 1:
  483. #ifndef MAKE_IT_COMMON_VERSION
  484. uISetNextStatus(UIS_MENU_RANK_SEL);
  485. #endif
  486. break;
  487. case 2:
  488. uISetNextStatus(UIS_MENU_CLASS_SEL);
  489. break;
  490. case 3:
  491. uISetNextStatus(UIS_MENU_STUDENT_SEL);
  492. break;
  493. case 4:
  494. uISetNextStatus(UIS_MENU_LOCATION_SEL);
  495. break;
  496. case 5:
  497. uISetNextStatus(UIS_MENU_SYS_SEL);
  498. break;
  499. }
  500. uiPushStack(sutPalace.Index);
  501. }
  502. else if(MKEY_VALUE_ESC==key){
  503. uISetNextStatus(UIS_STANDBY);
  504. }
  505. }
  506. /****************************主菜单显示部分结束*************************************/
  507. /*****************************群组选择/成员选择部分开始*********************************/
  508. bool uiSwitchLock=false;
  509. bool isUiSwitchReady(void){return uiSwitchLock;}
  510. static char GUListBoxInited=0;
  511. static char SelMachine=0;
  512. static void ReFlashItemGU(char type);
  513. static void UserAssistAdd(void);
  514. void uiShowGUSel(char StatusUpdate,unsigned int exeInterval,char type){
  515. static char machine;
  516. static unsigned int timer;
  517. unsigned short timeout;
  518. char temp;
  519. if(StatusUpdate) machine=0;
  520. switch(machine){
  521. case 0:
  522. if(sutPocStatus.logined == 0){//not login
  523. guiShowMessageBox(" 请先登录 ");
  524. uTimerStart(&timer, 1000);
  525. machine=1;
  526. }else{
  527. uiSwitchLock=true;
  528. if(type==0) appSleepCtl(ASLEEP_GGROUP, 1);//要获取群组信息,不让休眠,记得超时或获取成功或获取失败后需要释放
  529. else appSleepCtl(ASLEEP_GUSER, 1);
  530. UiassistStart(0);
  531. machine=2;
  532. }
  533. break;
  534. case 1:
  535. if(uTimerExpired(&timer)){
  536. uISetNextStatus(UIS_STANDBY);
  537. }
  538. break;
  539. case 2:
  540. temp=getAssistResult();
  541. if(temp){//??è?íê3é
  542. guiClearAll(guiGetBackColor());
  543. if(type==0){
  544. guiShowCaption(0,LEARN_GROUP_SEG,UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12); //0
  545. uiMenuShowBottomIndacitor("确定", "返回");
  546. }else{
  547. guiShowCaption(0,LEARN_USER_SEG,UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12); //0
  548. uiMenuShowBottomIndacitor("单呼", "返回");
  549. }
  550. ReFlashItemGU(type);
  551. uiMenuShowBottomLine();
  552. machine=3;
  553. //获取成功后退出释放休眠
  554. if(type==0) appSleepCtl(ASLEEP_GGROUP, 0);
  555. else appSleepCtl(ASLEEP_GUSER, 0);
  556. uiSwitchLock=false;
  557. }
  558. break;
  559. }
  560. if(machine != 3) return;
  561. UserAssistAdd();
  562. }
  563. void GroupSelResponse(){
  564. unsigned int key;
  565. char buf[50];
  566. int i;
  567. key=getKeyValue();
  568. switch(SelMachine){
  569. case 0:
  570. if(sutListBox.handle==0 && MKEY_VALUE_UP==key){
  571. UiassistStart(1);
  572. SelMachine=1;
  573. }else if(((sutListBox.handle+1) == sutListBox.itemnum) && (MKEY_VALUE_DOWN==key)){
  574. UiassistStart(2);
  575. SelMachine=2;
  576. }
  577. key=ListBoxResponse(&sutListBox);
  578. if(MKEY_VALUE_ESC==key){
  579. uiAssist.status=0;
  580. if(getStackStruct()->FastUiChange)uISetNextStatus(UIS_STANDBY);
  581. else uISetNextStatus(UIS_MENU_MAIN);
  582. appSleepCtl(ASLEEP_GGROUP, 0);//按键退出后释放休眠
  583. GUListBoxInited=0;
  584. }else if(MKEY_VALUE_MENU==key){
  585. if(0 == sutPocStatus.ListCurOnlineNum) break;
  586. ///////////////////////////////////////
  587. UiassistEnd(1);
  588. sutApp.groupTTSEnable=1;
  589. snprintf(buf, sizeof(buf),"AT+POC=090000%08x\r\n",sutPocStatus.AllGroups[sutListBox.handle].ID);
  590. msgAtSend(buf);
  591. MSG_INFO(1,buf);
  592. snprintf(buf, sizeof(buf),"进入:%s",sutPocStatus.AllGroups[sutListBox.handle].name);
  593. MSG_INFO(1,buf);
  594. uISetNextStatus(UIS_STANDBY);
  595. SelMachine=0;
  596. }
  597. break;
  598. }
  599. }
  600. void UserSelResponse(){
  601. char buf[50];
  602. unsigned int key;
  603. key=getKeyValue();
  604. switch(SelMachine){
  605. case 0:
  606. if(GUListBoxInited==0) break;//还未初始化listbox时,不执行按键响应
  607. if(sutListBox.handle==0 && MKEY_VALUE_UP==key){
  608. UiassistStart(1);
  609. SelMachine=1;
  610. }else if((sutListBox.handle+1) == sutListBox.itemnum && (MKEY_VALUE_DOWN==key)){
  611. UiassistStart(2);
  612. SelMachine=2;
  613. }
  614. key=ListBoxResponse(&sutListBox);
  615. if(MKEY_VALUE_ESC==key){
  616. uiAssist.status=0;
  617. if(getStackStruct()->FastUiChange)uISetNextStatus(UIS_STANDBY);
  618. else uISetNextStatus(UIS_MENU_MAIN);
  619. appSleepCtl(ASLEEP_GUSER, 0);//按键退出后释放休眠
  620. GUListBoxInited=0;
  621. }else if(MKEY_VALUE_MENU==key){
  622. if(0 == sutPocStatus.ListCurOnlineNum) break;
  623. snprintf(buf, sizeof(buf),"AT+POC=0A0000%08x\r\n",sutPocStatus.AllUsers[sutListBox.handle].ID);
  624. msgAtSend(buf);
  625. MSG_INFO(1, buf);
  626. snprintf(buf, sizeof(buf),"呼叫:%s",sutPocStatus.AllUsers[sutListBox.handle].name);
  627. MSG_INFO(1, buf);
  628. uISetNextStatus(UIS_STANDBY);
  629. SelMachine=0;
  630. }
  631. break;
  632. }
  633. }
  634. static void UserAssistAdd(void){
  635. switch(SelMachine){
  636. case 1:
  637. if(getAssistResult()){
  638. if(sutUIstatus.Status==UIS_MENU_CLASS_SEL)ReFlashItemGU(0);
  639. else ReFlashItemGU(1);
  640. SelMachine=0;
  641. }
  642. break;
  643. case 2:
  644. if(getAssistResult()){
  645. if(sutUIstatus.Status==UIS_MENU_CLASS_SEL)ReFlashItemGU(0);
  646. else ReFlashItemGU(1);
  647. SelMachine=0;
  648. }
  649. break;
  650. }
  651. }
  652. static void ReFlashItemGU(char type){
  653. static unsigned short susCt=0;
  654. static const char *accIconFileName[]={
  655. "Group1.bmp",
  656. "Group2.bmp",
  657. "people1.bmp",
  658. "people2.bmp",
  659. ""
  660. };
  661. static char *icons[3];
  662. int i;
  663. unsigned short timeout;
  664. static char *GUName[POC_ALL_GROUPS_NUM+1]; //5
  665. static char GUFeatures[POC_ALL_GROUPS_NUM+1];//5
  666. if(type==0){
  667. icons[0]=accIconFileName[0];
  668. icons[1]=accIconFileName[1];
  669. }else{
  670. icons[0]=accIconFileName[2];
  671. icons[1]=accIconFileName[3];
  672. }
  673. icons[2]=accIconFileName[4];
  674. for(i=0;i<=POC_ALL_GROUPS_NUM;i++){
  675. GUName[i]=NullPtr;
  676. GUFeatures[i]=0;
  677. }
  678. for(i=0;i<sutPocStatus.ListFillIndex;i++){
  679. GUFeatures[i]=1;
  680. if(type==0){
  681. if(sutPocStatus.AllGroups[i].ID==sutPocStatus.LocalGroup.ID) GUFeatures[i]=0;
  682. GUName[i]=sutPocStatus.AllGroups[i].name;
  683. }else{
  684. if(sutPocStatus.AllUsers[i].ID==sutPocStatus.LocalUser.ID) GUFeatures[i]=0;
  685. GUName[i]=sutPocStatus.AllUsers[i].name;
  686. }
  687. }
  688. if(sutPocStatus.ListCurOnlineNum==0 || sutPocStatus.ListDetailValid==0){//没有成员总数或没有获取到明细
  689. GUName[0]="空";
  690. GUFeatures[i]=0;
  691. }
  692. //初始化ListBox控件
  693. ListBoxInit(&sutListBox,GUName,0,icons,GUFeatures);
  694. GUListBoxInited=1;
  695. }
  696. /*****************************群组选择/成员选择部分结束*********************************/
  697. /*****************************系统设置部分开始*********************************/
  698. void uiShowMenuSysSetup(char flash){
  699. static const char *apcPtr[]={
  700. "1,LCD设置",
  701. "2,本机密码",
  702. "3,功耗模式设置",
  703. "4,服务器设置",
  704. "5,版本升级",
  705. "6,提示音设置",
  706. "7,终端信息",
  707. "8,SD卡检测",
  708. "9,天线调试",
  709. #ifdef MENU_TEST
  710. "10,测试",
  711. #endif
  712. ""
  713. };
  714. if(flash){
  715. msgAtSend("AT+RSIM\r\n");//进此菜单前查询一下卡用于后面显示
  716. guiClearAll(guiGetBackColor());
  717. guiShowCaption(0,"系统设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  718. uiMenuShowBottomLine();
  719. uiMenuShowBottomIndacitor("确认", "返回");
  720. uiMenuInit(&sutMenuSysSetup,apcPtr,FONT_MODE_12X12,true);
  721. }
  722. }
  723. void sysTemSetResponse(void){
  724. unsigned short key;
  725. key=uiMenuResponse(&sutMenuSysSetup);
  726. if(MKEY_VALUE_MENU==key){
  727. switch(sutMenuSysSetup.handle){
  728. case 0://LCD设置
  729. uISetNextStatus(UIS_MENU_SYS_LCD);
  730. break;
  731. case 1://本机密码
  732. uISetNextStatus(UIS_MENU_SYS_PASS);
  733. break;
  734. case 2://功耗模式设置
  735. uISetNextStatus(UIS_MENU_SYS_PWR);
  736. break;
  737. case 3://服务器设置
  738. uISetNextStatus(UIS_MENU_SYS_SERVERPASS);
  739. break;
  740. case 4://版本升级
  741. uISetNextStatus(UIS_MENU_SYS_VERSION);
  742. break;
  743. case 5://提示音设置
  744. uISetNextStatus(UIS_MENU_SYS_NOTE);
  745. break;
  746. case 6://终端信息
  747. uISetNextStatus(UIS_MENU_SYS_INFO);
  748. break;
  749. case 7://SD卡检测
  750. uISetNextStatus(UIS_MENU_SYS_SD);
  751. break;
  752. case 8://天线调试
  753. uISetNextStatus(UIS_MENU_SYS_ANT);
  754. break;
  755. #ifdef MENU_TEST
  756. case 9://测试
  757. uISetNextStatus(UIS_MENU_SYS_TEST);
  758. break;
  759. }
  760. if(sutMenuSysSetup.handle<=9)
  761. #else
  762. }
  763. if(sutMenuSysSetup.handle<=8)
  764. #endif
  765. uiPushStack(sutMenuSysSetup.handle);
  766. }else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_MAIN);
  767. }
  768. /*****************************系统设置部分结束*********************************/
  769. /*****************************定位设置部分开始*********************************/
  770. unsigned char tempGpsIndex;
  771. static locationTimeFlash(char type);
  772. static locationXYFlash(char flash);
  773. void uiShowMenuLocationSel(char flash){
  774. #ifdef MAKE_IT_COMMON_VERSION
  775. if(flash){
  776. guiClearAll(guiGetBackColor());
  777. guiShowCaption(0,"定位设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  778. uiMenuShowBottomLine();
  779. if(newPara.gpsEnable==0){
  780. uiMenuShowBottomIndacitor(NULL, "返回");
  781. guiShowMessageBox("版本不支持");
  782. nwy_sleep(1000);
  783. uISetNextStatus(UIS_MENU_MAIN);
  784. return;
  785. }
  786. uiMenuShowBottomIndacitor("保存", "返回");
  787. locationTimeFlash(0);
  788. }
  789. if(newPara.gpsEnable!=0) locationXYFlash(flash);
  790. #else
  791. static const char *apcPtr[]={
  792. "1,课程表",
  793. "2,通知简报",
  794. ""
  795. };
  796. if(flash){
  797. guiClearAll(guiGetBackColor());
  798. guiShowCaption(0,"消息通知",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  799. uiMenuShowBottomLine();
  800. uiMenuShowBottomIndacitor("确认", "返回");
  801. uiMenuInit(&sutMenuSysSetup,apcPtr,FONT_MODE_12X12,true);
  802. }
  803. #endif
  804. }
  805. void loationSetResponse(void){
  806. #ifdef MAKE_IT_COMMON_VERSION
  807. unsigned short key;
  808. key=getKeyValue();
  809. if(MKEY_VALUE_UP==key) locationTimeFlash(1);
  810. else if(MKEY_VALUE_DOWN==key) locationTimeFlash(2);
  811. else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_MAIN);
  812. else if(MKEY_VALUE_MENU==key){
  813. if(tempGpsIndex != newPara.gpsTimeIndex){
  814. MSG_INFO(1, "GPS timeIndex update:%d",getGPSTimeValue(tempGpsIndex));
  815. newPara.gpsTimeIndex=tempGpsIndex;
  816. sysIniSave();
  817. gpsCheckInfo();//检测一下
  818. }
  819. uISetNextStatus(UIS_MENU_MAIN);
  820. }
  821. #else
  822. unsigned short key;
  823. key=uiMenuResponse(&sutMenuSysSetup);
  824. if(MKEY_VALUE_MENU==key){
  825. switch(sutMenuSysSetup.handle){
  826. case 0://课程表
  827. uISetNextStatus(UIS_MENU_LOCATION_CLASS);
  828. break;
  829. case 1://消息通知
  830. uISetNextStatus(UIS_MENU_LOCATION_NOTICE);
  831. break;
  832. }
  833. if(sutMenuSysSetup.handle<=1) uiPushStack(sutMenuSysSetup.handle);
  834. }else if(MKEY_VALUE_ESC==key){
  835. sdUnmount();
  836. uISetNextStatus(UIS_MENU_MAIN);
  837. }
  838. #endif
  839. }
  840. static locationTimeFlash(char type){
  841. unsigned short gpsTimeValue;
  842. char buf[50];
  843. unsigned short y=70;
  844. if(type==0){
  845. tempGpsIndex=newPara.gpsTimeIndex;
  846. }else if(type==1){
  847. if(++tempGpsIndex>=GPS_TABLE_NUM) tempGpsIndex=0;
  848. }else if(type==2){
  849. if(tempGpsIndex>0) tempGpsIndex--;
  850. else tempGpsIndex=GPS_TABLE_NUM-1;
  851. }else return;
  852. gpsTimeValue=getGPSTimeValue(tempGpsIndex);
  853. if(gpsTimeValue==0) snprintf(buf, sizeof(buf), "定位上传设置:关闭");
  854. else snprintf(buf, sizeof(buf), "定位上传设置:%d秒",gpsTimeValue);
  855. guiClearRect(0,y,GLCD_WIDTH-1, y+12,guiGetBackColor());
  856. guiShowStr(30,y, buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  857. }
  858. static locationXYFlash(char flash){
  859. char buf[50];
  860. unsigned short y=UI_CONTENT_SHOW_Y+2;
  861. if(gpsInfo.update==0 && flash==0) return;
  862. gpsInfo.update=0;
  863. guiClearRect(0, y,GLCD_WIDTH-1, y+12+5+12,guiGetBackColor());
  864. snprintf(buf, sizeof(buf), "纬度 S:%d.%05d",gpsInfo.Lat/1000000,gpsInfo.Lat%1000000);
  865. guiShowStr(30,y, buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  866. y+=12+5;
  867. snprintf(buf, sizeof(buf), "经度 W:%d.%05d",gpsInfo.Long/1000000,gpsInfo.Long%1000000);
  868. guiShowStr(30,y, buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  869. }
  870. /*****************************定位设置部分结束*********************************/
  871. /*******************************终端信息开始**********************************/
  872. unsigned char sysInfoType;
  873. static void sysInfoFlash(void){
  874. unsigned short x,y;
  875. char buf[50];
  876. unsigned char LineSpace=12+4;
  877. int len;
  878. x=2,y=UI_CONTENT_SHOW_Y+5;
  879. guiClearRect(0,y,GLCD_WIDTH-1,UI_BOTTOM_LINE_Y-1,guiGetBackColor());
  880. if(sysInfoType==0){
  881. //终端型号
  882. snprintf(buf, sizeof(buf),"终端型号:%s",OHPOC_APP_NAME);
  883. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  884. y+=LineSpace;
  885. //终端编码
  886. snprintf(buf, sizeof(buf),"终端编码:%lu",sutApp.account.psn);
  887. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  888. y+=LineSpace;
  889. //应用版本
  890. snprintf(buf, sizeof(buf),"应用版本:%s",OHPOC_VERSION);
  891. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  892. y+=LineSpace;
  893. //内部版本
  894. snprintf(buf, sizeof(buf),"内部版本:%d",CUSTOMER_CODE);
  895. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  896. }else if(sysInfoType==1){
  897. //对讲版本号
  898. snprintf(buf, sizeof(buf),"对讲版本:%s",sutApp.pocVersion);
  899. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  900. y+=LineSpace;
  901. //模块
  902. memset(buf,sizeof(buf),0);
  903. snprintf(buf,sizeof(buf),"模块:%s", sutApp.modemVer);
  904. len=strlen(buf);
  905. if(len>20){
  906. y+=LineSpace;
  907. guiShowStr(x+32,y,buf+20,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  908. buf[20]=0;
  909. y-=LineSpace;
  910. }
  911. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  912. }else if(sysInfoType==2){
  913. //显示服务器
  914. //对讲IP
  915. //getPIPAddr();getGIPAddr();
  916. guiShowStr(x,y,"交换服务器:",FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  917. y+= LineSpace;
  918. snprintf(buf, sizeof(buf),"%s",showPIP);
  919. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  920. y+=LineSpace;
  921. //GPS IP
  922. guiShowStr(x,y,"定位服务器:",FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  923. y+= LineSpace;
  924. snprintf(buf, sizeof(buf),"%s",showGIP);
  925. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  926. y+=LineSpace;
  927. snprintf(buf, sizeof(buf),"端口:%d",newPara.gpsPort);
  928. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  929. }
  930. }
  931. void uiShowInformation(char update){
  932. if(update){
  933. sysInfoType=0;
  934. guiClearAll(guiGetBackColor());
  935. guiShowCaption(0,"终端信息",UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  936. uiMenuShowBottomLine();
  937. uiMenuShowBottomIndacitor(NULL, "返回");
  938. sysInfoFlash();
  939. }
  940. }
  941. void uiShowInformationResponse(void){
  942. unsigned short key=getKeyValue();
  943. if(MKEY_VALUE_ESC==key) uISetNextStatus(sutUIstatus.LastStatus);
  944. else if(MKEY_VALUE_DOWN==key || MKEY_VALUE_UP==key){
  945. if(sysInfoType==0) sysInfoType=1;
  946. else sysInfoType=0;
  947. sysInfoFlash();
  948. }else if(MKEY_VALUE_CB_IP==key){
  949. sysInfoType=2;
  950. sysInfoFlash();
  951. }
  952. }
  953. /*****************************终端信息结束**********************************/
  954. /*****************************天线调试**************************************/
  955. void uiShowANT(char update){
  956. if(update){
  957. guiClearAll(guiGetBackColor());
  958. guiShowCaption(0,"天线调试",UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  959. guiShowMessageBox("确定进入?");
  960. uiMenuShowBottomLine();
  961. uiMenuShowBottomIndacitor("确定", "返回");
  962. }
  963. }
  964. void uiShowANTResponse(void){
  965. unsigned short key=getKeyValue();
  966. if(MKEY_VALUE_ESC==key) uISetNextStatus(sutUIstatus.LastStatus);
  967. else if(MKEY_VALUE_MENU==key){
  968. sutApp.antMode=1;
  969. guiShowMessageBox("天线模式");
  970. }
  971. }
  972. /*****************************天线调试****************************************/
  973. /*******************************留音记录开始**********************************/
  974. void uiShowVoiceInfo(char update){
  975. static unsigned int timer;
  976. static char *showInfo[3+1];
  977. static char empty;
  978. int i;
  979. if(update){
  980. guiClearAll(guiGetBackColor());
  981. guiShowCaption(0,"留音记录",UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  982. uiMenuShowBottomLine();
  983. uiMenuShowBottomIndacitor("播放", "返回");
  984. sutApp.voiceInfo.update=0;
  985. sutApp.voiceInfo.aNum=0;
  986. sutApp.voiceInfo.vNum=0;
  987. sutApp.voiceInfo.voiceValidNum=0;
  988. sutApp.voiceInfo.voiceStatus=1;
  989. empty=0;
  990. msgAtSend("AT+VINFO?\r\n");
  991. guiShowMessageBox("请稍后");
  992. uTimerStart(&timer, 2000);
  993. }
  994. switch(sutApp.voiceInfo.voiceStatus){
  995. case 1:
  996. if(sutApp.voiceInfo.update!=0){
  997. sutApp.voiceInfo.voiceStatus=2;
  998. break;
  999. }
  1000. if(uTimerExpired(&timer)){
  1001. showInfo[0]="空";
  1002. sutApp.voiceInfo.voiceStatus=2;
  1003. empty=1;
  1004. //MSG_INFO(1, "==>Empty");
  1005. }
  1006. break;
  1007. case 2:
  1008. if(empty==0) for(i=0;i<sutApp.voiceInfo.voiceValidNum;i++) showInfo[i]=sutApp.voiceInfo.info[i].info;
  1009. else i=1;
  1010. showInfo[i]=NullPtr;
  1011. guiFillRect(0,UI_CONTENT_SHOW_Y,GLCD_WIDTH-1,UI_BOTTOM_SHOW_Y-1,guiGetBackColor());
  1012. uiMenuInit(&sutMenuSysSetup,showInfo,FONT_MODE_12X12,false);
  1013. sutApp.voiceInfo.voiceStatus=3;
  1014. break;
  1015. }
  1016. }
  1017. void uiShowVoiceInfoResponse(void){
  1018. char cmd[30];
  1019. unsigned short key;
  1020. if(sutApp.voiceInfo.voiceStatus!=3) return;
  1021. key=uiMenuResponse(&sutMenuSysSetup);
  1022. if(MKEY_VALUE_ESC==key) uISetNextStatus(sutUIstatus.LastStatus);
  1023. else if(MKEY_VALUE_MENU==key){
  1024. if(sutApp.voiceInfo.voiceValidNum!=0){
  1025. snprintf(cmd, sizeof(cmd), "AT+VPLAY=%c\r\n", sutApp.voiceInfo.info[sutMenuSysSetup.handle].index);
  1026. msgAtSend(cmd);
  1027. }
  1028. }
  1029. }
  1030. /*****************************留音记录结束**********************************/
  1031. /*****************************SD卡检测***************************************/
  1032. void uiShowSD(char update){
  1033. static unsigned int timer;
  1034. if(update){
  1035. sysInfoType=0;
  1036. guiClearAll(guiGetBackColor());
  1037. guiShowCaption(0,"SD卡检测",UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1038. guiShowMessageBox("正在检测");
  1039. uiMenuShowBottomLine();
  1040. if(true==sdCardTest()) guiShowMessageBox("SD卡正常");
  1041. else guiShowMessageBox("SD卡异常");
  1042. uTimerStart(&timer, 2000);
  1043. }
  1044. if(uTimerExpired(&timer)){
  1045. getStackStruct()->ok_back=1;
  1046. uISetNextStatus(sutUIstatus.LastStatus);
  1047. }
  1048. }
  1049. /*****************************SD卡检测结束***********************************/
  1050. static const char *commonIcon2[]={
  1051. "APN.bmp",
  1052. "APN1.bmp",
  1053. ""
  1054. };
  1055. /*****************************LCD设置开始**********************************/
  1056. unsigned char lcdTmpIndex;
  1057. static void lcdTimeFlash(char type){
  1058. char buf[50];
  1059. unsigned short x=4,y=56,value;
  1060. if(type==0) guiShowStr(x+25, y, "背光时间:", FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1061. else if(type==1){
  1062. if(++lcdTmpIndex>=5) lcdTmpIndex=0;
  1063. }else if(type==2){
  1064. if(lcdTmpIndex>0) lcdTmpIndex--;
  1065. else lcdTmpIndex=4;
  1066. }
  1067. value=newPara.lcdParaList[lcdTmpIndex];
  1068. if(value==0) snprintf(buf, sizeof(buf), " 常亮 ");
  1069. else snprintf(buf, sizeof(buf), "%3d 秒", value);
  1070. guiShowStr(x+85, y, buf, FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1071. }
  1072. void uiShowLcdSel(char StatusUpdate){
  1073. if(StatusUpdate){
  1074. guiClearAll(guiGetBackColor());
  1075. guiShowCaption(0,"LCD设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1076. uiMenuShowBottomLine();
  1077. lcdTmpIndex=newPara.lcdParaDefaultIndex;
  1078. lcdTimeFlash(0);
  1079. uiMenuShowBottomIndacitor("保存", "返回");
  1080. }
  1081. }
  1082. void uiShowLcdSelResponse(void){
  1083. unsigned short key=getKeyValue();
  1084. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1085. else if(MKEY_VALUE_DOWN==key)lcdTimeFlash(1);
  1086. else if(MKEY_VALUE_UP==key) lcdTimeFlash(2);
  1087. else if(MKEY_VALUE_MENU==key){
  1088. getStackStruct()->ok_back=1;
  1089. if(lcdTmpIndex != newPara.lcdParaDefaultIndex){
  1090. newPara.lcdParaDefaultIndex=lcdTmpIndex;
  1091. MSG_INFO(1, "LCD TimeUpdate");
  1092. backLightReset();
  1093. sysIniSave();
  1094. }
  1095. uISetNextStatus(UIS_MENU_SYS_SEL);
  1096. }
  1097. }
  1098. /*****************************LCD设置结束**********************************/
  1099. /*****************************网络设置开始**********************************/
  1100. const unsigned char netModeSetTable[3]={1,2,4};//设置制式:AUTH,2G,4G
  1101. /*输入制式源始值,返回索引值对应值*/
  1102. unsigned char getNetModeIndex(unsigned char netModeValue){
  1103. unsigned char i;
  1104. for(i=0;i<sizeof(netModeSetTable);i++){
  1105. if(netModeValue==netModeSetTable[i]) return i;
  1106. }
  1107. return 0xff;//无对应值
  1108. }
  1109. /*输入制式索引值,返回制式源始值*/
  1110. unsigned char getNetModeValue(unsigned char netModeIndex){
  1111. if(netModeIndex>=sizeof(netModeSetTable)) return 0xff;
  1112. else return netModeSetTable[netModeIndex];
  1113. }
  1114. /*输入制式索引值,发送对应该命令给模块*/
  1115. void netModeSetCmd(unsigned char netModeIndex){
  1116. char buf[30];
  1117. unsigned char netModeValue=getNetModeValue(netModeIndex);
  1118. if(netModeValue==0xff){
  1119. MSG_ERR(1,"netMode index invalid:%d",netModeIndex);
  1120. return;
  1121. }
  1122. snprintf(buf, sizeof(buf), "AT$MYSYSINFO=%d\r\n",netModeValue);
  1123. msgAtSend(buf);
  1124. }
  1125. #define NET_MODE_NUM 3
  1126. void uiShowNetSel(char StatusUpdate){
  1127. static const char *netMode[NET_MODE_NUM+1]={
  1128. "AUTO",
  1129. "2G",
  1130. "4G",
  1131. ""
  1132. };
  1133. char Features[NET_MODE_NUM];
  1134. unsigned char i;
  1135. if(StatusUpdate){
  1136. guiClearAll(guiGetBackColor());
  1137. guiShowCaption(0,"网络设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1138. uiMenuShowBottomLine();
  1139. for(i=0;i<NET_MODE_NUM;i++){
  1140. if(i==newPara.netMode) Features[i]=1;
  1141. else Features[i]=0;
  1142. }
  1143. ListBoxInit(&sutListBox,netMode,0,commonIcon2,Features);
  1144. uiMenuShowBottomIndacitor("保存", "返回");
  1145. }
  1146. }
  1147. void uiShowNetSelResponse(void){
  1148. unsigned short key=ListBoxResponse(&sutListBox);
  1149. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1150. else if(MKEY_VALUE_MENU==key){
  1151. getStackStruct()->ok_back=1;
  1152. if(sutListBox.handle != newPara.netMode){
  1153. newPara.netMode=sutListBox.handle;
  1154. MSG_INFO(1, "netMode update:%d", newPara.netMode);
  1155. sysIniSave();
  1156. netModeSetCmd(newPara.netMode);
  1157. }
  1158. uISetNextStatus(UIS_MENU_SYS_SEL);
  1159. }
  1160. }
  1161. /*****************************网络设置结束**********************************/
  1162. /*****************************卡选择设置开始**********************************/
  1163. #define SIM_MODE_NUM 2
  1164. void uiShowSimSel(char StatusUpdate){
  1165. static const char *simMode[SIM_MODE_NUM+1]={
  1166. "卡1",
  1167. "卡2",
  1168. ""
  1169. };
  1170. char Features[SIM_MODE_NUM];
  1171. unsigned char i;
  1172. if(StatusUpdate){
  1173. guiClearAll(guiGetBackColor());
  1174. guiShowCaption(0,"SIM设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1175. uiMenuShowBottomLine();
  1176. for(i=0;i<SIM_MODE_NUM;i++){
  1177. if(i==sutApp.simSel) Features[i]=1;
  1178. else Features[i]=0;
  1179. }
  1180. ListBoxInit(&sutListBox,simMode,0,commonIcon2,Features);
  1181. uiMenuShowBottomIndacitor("保存", "返回");
  1182. }
  1183. }
  1184. void uiShowSimSelResponse(void){
  1185. char buf[30];
  1186. unsigned short key=ListBoxResponse(&sutListBox);
  1187. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1188. else if(MKEY_VALUE_MENU==key){
  1189. getStackStruct()->ok_back=1;
  1190. if(sutListBox.handle != sutApp.simSel){
  1191. snprintf(buf, sizeof(buf), "AT+SSIM=%d\r\n",sutListBox.handle+1);
  1192. msgAtSend(buf);
  1193. guiShowMessageBox("请重启设备");
  1194. msgAtSend("AT+TRB=1\r\n");
  1195. nwy_sleep(100);
  1196. for(;;){
  1197. MSG_INFO(1, "card changed, wait user reboot");
  1198. CTL_POWER_HOLD(0);
  1199. nwy_sleep(1000);
  1200. }
  1201. }
  1202. uISetNextStatus(UIS_MENU_SYS_SEL);
  1203. }
  1204. }
  1205. /*****************************卡选择设置结束**********************************/
  1206. /*****************************功耗设置开始**********************************/
  1207. typedef enum{
  1208. PMODE_DEFAULT_LOW,
  1209. PMODE_SUPER_LOW,
  1210. PMODE_NORMAL
  1211. }PWR_ENUMDEF;
  1212. //低功耗模式
  1213. #define MODE_LOW_PWR_NONE_4G 5
  1214. #define MODE_LOW_PWR_IS_4G 25
  1215. //超长待机模式
  1216. #define MODE_LONG_LOW_PWR_NONE_4G 5
  1217. #define MODE_LONG_LOW_PWR_IS_4G 55
  1218. //常规模式
  1219. #define MODE_NORMAL__NONE_4G 5
  1220. #define MODE_NORMAL__IS_4G 5
  1221. //终端放弃设置模式,由服务器决定使用什么
  1222. #define MODE_AUTO____NONE_4G 0
  1223. #define MODE_AUTO____IS_4G 0
  1224. //默认功耗模式
  1225. #define MODE_PWR_DEFAULT_NONE_4G MODE_LOW_PWR_NONE_4G
  1226. #define MODE_PWR_DEFAULT_IS_4G MODE_LOW_PWR_IS_4G
  1227. static void pwrModeSetCmd(unsigned char pwrMode){
  1228. unsigned char seg1,seg2;
  1229. char buf[30];
  1230. if(pwrMode==PMODE_DEFAULT_LOW){
  1231. seg1=MODE_PWR_DEFAULT_NONE_4G;
  1232. seg2=MODE_PWR_DEFAULT_IS_4G;
  1233. }else if(pwrMode==PMODE_SUPER_LOW){
  1234. seg1=MODE_LONG_LOW_PWR_NONE_4G;
  1235. seg2=MODE_LONG_LOW_PWR_IS_4G;
  1236. }else if(pwrMode==PMODE_NORMAL){
  1237. seg1=MODE_NORMAL__NONE_4G;
  1238. seg2=MODE_NORMAL__IS_4G;
  1239. }else return;
  1240. snprintf(buf, sizeof(buf), "AT+UDP=%d,%d\r\n",seg1,seg2);
  1241. msgAtSend(buf);
  1242. }
  1243. void pwrModeAckHandler(unsigned char seg1, unsigned char seg2){
  1244. if(seg1==MODE_PWR_DEFAULT_NONE_4G && seg2==MODE_PWR_DEFAULT_IS_4G && newPara.pwrMode != PMODE_DEFAULT_LOW){
  1245. goto SAVE_PWR_MODE;
  1246. }else if(seg1==MODE_LONG_LOW_PWR_NONE_4G && seg2==MODE_LONG_LOW_PWR_IS_4G && newPara.pwrMode != PMODE_SUPER_LOW){
  1247. goto SAVE_PWR_MODE;
  1248. }else if(seg1==MODE_NORMAL__NONE_4G && seg2==MODE_NORMAL__IS_4G && newPara.pwrMode != PMODE_NORMAL){
  1249. goto SAVE_PWR_MODE;
  1250. }else if(seg2!=MODE_LOW_PWR_IS_4G&&seg2!=MODE_LONG_LOW_PWR_IS_4G&& seg2!=MODE_NORMAL__IS_4G){
  1251. //Seg2 3个模式都不满足则切换为默认模式
  1252. newPara.pwrMode = PMODE_DEFAULT_LOW;
  1253. goto SAVE_PWR_MODE;
  1254. }
  1255. return;
  1256. SAVE_PWR_MODE:
  1257. sysIniSave();
  1258. pwrModeSetCmd(newPara.pwrMode);
  1259. }
  1260. #define PWR_MODE_NUM 3
  1261. void uiShowPwrSel(char StatusUpdate){
  1262. static const char *pwrMode[PWR_MODE_NUM+1]={
  1263. "低功耗模式",
  1264. "超长省电模式",
  1265. "常规模式",
  1266. "",
  1267. };
  1268. char Features[PWR_MODE_NUM];
  1269. unsigned char i;
  1270. if(StatusUpdate){
  1271. guiClearAll(guiGetBackColor());
  1272. guiShowCaption(0,"功耗设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1273. uiMenuShowBottomLine();
  1274. for(i=0;i<PWR_MODE_NUM;i++){
  1275. if(i==newPara.pwrMode) Features[i]=1;
  1276. else Features[i]=0;
  1277. }
  1278. ListBoxInit(&sutListBox,pwrMode,0,commonIcon2,Features);
  1279. uiMenuShowBottomIndacitor("保存", "返回");
  1280. }
  1281. }
  1282. void uiShowPwrSelResponse(void){
  1283. unsigned short key=ListBoxResponse(&sutListBox);
  1284. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1285. else if(MKEY_VALUE_MENU==key){
  1286. getStackStruct()->ok_back=1;
  1287. if(sutListBox.handle != newPara.pwrMode){
  1288. newPara.pwrMode=sutListBox.handle;
  1289. MSG_INFO(1, "pwrMode update:%d", newPara.pwrMode);
  1290. sysIniSave();
  1291. pwrModeSetCmd(newPara.pwrMode);
  1292. }
  1293. uISetNextStatus(UIS_MENU_SYS_SEL);
  1294. }
  1295. }
  1296. /*****************************功耗设置结束**********************************/
  1297. /*****************************服务器设置输入密码开始**********************************/
  1298. void uiShowServerPassSel(char StatusUpdate){
  1299. if(StatusUpdate){
  1300. guiClearAll(guiGetBackColor());
  1301. guiShowCaption(0,"密码验证",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1302. uiMenuShowBottomLine();
  1303. NumEditInit(&sutNumEdit,(GLCD_WIDTH-6*8)/2,(GLCD_HEIGHT-16)/2,"000000");
  1304. NumEditShow(&sutNumEdit);
  1305. uiMenuShowBottomIndacitor("[上]加值", "[下]移动");
  1306. }
  1307. }
  1308. void uiShowServerSelPassResponse(void){
  1309. unsigned short key=getKeyValue();
  1310. NumEditResponse(&sutNumEdit);
  1311. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1312. else if(MKEY_VALUE_MENU==key){
  1313. if(memcmp(sutNumEdit.buffer, getMenuKey(), 6)==0) uISetNextStatus(UIS_MENU_SYS_SERVER);
  1314. else{
  1315. guiShowMessageBox("密码错误");
  1316. nwy_sleep(1000);
  1317. getStackStruct()->ok_back=1;
  1318. uISetNextStatus(UIS_MENU_SYS_SEL);
  1319. }
  1320. }
  1321. }
  1322. /*****************************服务器设置输入密码结束**********************************/
  1323. /*****************************服务器设置开始**********************************/
  1324. void uiShowServerSel(char StatusUpdate){
  1325. static const char *serIcons[]={
  1326. "Ser.bmp",
  1327. "Sersel.bmp",
  1328. ""
  1329. };
  1330. static const char *serName[]={
  1331. "杭州服务器",
  1332. "山东服务器",
  1333. "IP分发服务器",
  1334. "集群服务器",
  1335. "自定义服务器",
  1336. "",
  1337. };
  1338. char Features[5];
  1339. unsigned char tempSer,i;
  1340. if(StatusUpdate){
  1341. guiClearAll(guiGetBackColor());
  1342. guiShowCaption(0,"服务器列表",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1343. uiMenuShowBottomLine();
  1344. uiMenuShowBottomIndacitor("确认", "返回");
  1345. tempSer=newPara.serList.defaultuse;
  1346. for(i=0;i<=SERVER_UR;i++){
  1347. if(i==tempSer) Features[i]=1;
  1348. else Features[i]=0;
  1349. }
  1350. ListBoxInit(&sutListBox,serName,0,serIcons,Features);
  1351. }
  1352. }
  1353. void uiShowServerSelResponse(void){
  1354. unsigned char tempSer;
  1355. char buf[50],buf1[100];
  1356. unsigned short key=ListBoxResponse(&sutListBox);
  1357. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1358. else if(MKEY_VALUE_MENU==key){
  1359. tempSer=sutListBox.handle;
  1360. if(tempSer != newPara.serList.defaultuse){
  1361. newPara.serList.defaultuse=tempSer;
  1362. sysIniSave();
  1363. getGIPAddr();
  1364. snprintf(buf, sizeof(buf), "ip=%s;domain=%s;",getPIPAddr(),getDOMAINAddr());
  1365. AscStrTurnHexStr(buf,buf1);
  1366. msgAtSend("AT+POC=010000");
  1367. msgAtSend(buf1);
  1368. msgAtSend("\r\n");
  1369. nwy_sleep(100);
  1370. msgAtSend("AT+POC=040000\r\n");
  1371. }
  1372. uISetNextStatus(UIS_STANDBY );
  1373. }
  1374. }
  1375. /*****************************服务器设置结束**********************************/
  1376. /*****************************版本设置开始**********************************/
  1377. unsigned char fotaStep;
  1378. unsigned int fotaTick;
  1379. void fotaMsgShow(char *msg){
  1380. int len=guiGetStrXLen((char *)msg,FONT_MODE_16X16);
  1381. guiClearRect(0, 60, GLCD_WIDTH-1, 60+16,guiGetBackColor());
  1382. guiShowStr((GLCD_WIDTH-len)/2,60, msg,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1383. }
  1384. void fotaMsgShow2(char *msg1, char *msg2){
  1385. guiClearRect(0, 45, GLCD_WIDTH-1, 45+16+2+16,guiGetBackColor());
  1386. int len=guiGetStrXLen((char *)msg1,FONT_MODE_16X16);
  1387. guiShowStr((GLCD_WIDTH-len)/2,45, msg1,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1388. len=guiGetStrXLen((char *)msg2,FONT_MODE_16X16);
  1389. guiShowStr((GLCD_WIDTH-len)/2,45+16+2, msg2,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1390. }
  1391. void uiShowVersionSel(char StatusUpdate){
  1392. char buf[50];
  1393. if(StatusUpdate){
  1394. sutApp.fotaVersion[0]=0;
  1395. guiClearAll(guiGetBackColor());
  1396. guiShowCaption(0,"版本更新",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1397. msgAtSend("AT+FOTA?\r\n");
  1398. fotaStep=0;
  1399. sutApp.fotaStatus=0;
  1400. fotaMsgShow("正在检测版本");
  1401. uiMenuShowBottomLine();
  1402. uiMenuShowBottomIndacitor("确定", "返回");
  1403. uTimerStart(&fotaTick, 500);
  1404. }
  1405. switch(fotaStep){
  1406. case 0:
  1407. if(sutApp.fotaStatus==1){
  1408. fotaMsgShow("无更新版本");
  1409. fotaStep=4;
  1410. break;
  1411. }else if(sutApp.fotaStatus==2){
  1412. snprintf(buf, sizeof(buf), "是否更新到:%s",sutApp.fotaVersion);
  1413. fotaMsgShow(buf);
  1414. fotaStep=1;
  1415. break;
  1416. }
  1417. if(uTimerExpired(&fotaTick)){
  1418. fotaMsgShow("检测超时");
  1419. fotaStep=4;
  1420. }
  1421. break;
  1422. case 1://等待用户确定
  1423. break;
  1424. case 2://用户确定后等待结果
  1425. if(sutApp.fotaStatus==3){
  1426. fotaMsgShow("升级失败");
  1427. fotaStep=4;
  1428. break;
  1429. }else if(sutApp.fotaStatus==4){
  1430. sutApp.fotaStatus=0;//否则会一直刷新本消息
  1431. fotaMsgShow("正在下载");
  1432. break;
  1433. }else if(sutApp.fotaStatus==5){
  1434. fotaMsgShow("下载成功");
  1435. fotaStep=3;
  1436. break;
  1437. }
  1438. if(uTimerExpired(&fotaTick)){
  1439. fotaMsgShow("超时退出");
  1440. fotaStep=4;
  1441. }
  1442. break;
  1443. case 3://下载成功
  1444. nwy_sleep(1000);
  1445. fotaStep=6;
  1446. fotaMsgShow2("确定将关机,需长按开","机键直至开机(约60秒)");
  1447. break;
  1448. case 4://延时显示2秒后退出
  1449. uTimerStart(&fotaTick, 2000);
  1450. fotaStep=5;
  1451. break;
  1452. case 5://退出升级流程
  1453. if(uTimerExpired(&fotaTick)) uISetNextStatus(UIS_MENU_SYS_SEL);
  1454. break;
  1455. case 6:
  1456. break;
  1457. }
  1458. }
  1459. void uiShowVersionSelResponse(void){
  1460. unsigned char key=getKeyValue();
  1461. if(fotaStep!=1 && fotaStep!=6) return;
  1462. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1463. else if(MKEY_VALUE_MENU==key){
  1464. if(fotaStep==1){
  1465. fotaMsgShow("请勿断电!");
  1466. fotaStep=2;
  1467. msgAtSend("AT+FOTA=1\r\n");
  1468. uTimerStart(&fotaTick, 10000);
  1469. }else if(fotaStep==6){
  1470. paControl(false);//防止一直滴音
  1471. if(nwy_version_update(true)<0){
  1472. MSG_ERR(1, "nwy_version_update failed");
  1473. fotaMsgShow("升级异常");
  1474. fotaStep=5;
  1475. }
  1476. msgAtSend("AT+TRB=2\r\n");
  1477. MSG_INFO(1, "Reset system!!!");
  1478. while(1){nwy_sleep(1000);}
  1479. }
  1480. }
  1481. }
  1482. /*****************************版本设置结束**********************************/
  1483. /*****************************提示音设置开始********************************/
  1484. unsigned char noteSetTmp;
  1485. static void switchFlash(void){
  1486. char info[30];
  1487. unsigned short x,y,len;
  1488. if(noteSetTmp==0) snprintf(info, sizeof(info), "关闭");
  1489. else snprintf(info, sizeof(info), "打开");
  1490. len=guiGetStrXLen((char *)info, FONT_MODE_12X12);
  1491. x=(GLCD_WIDTH-len)/2;
  1492. y=UI_CONTENT_SHOW_Y+(GLCD_HEIGHT-UI_CONTENT_SHOW_Y)/2-12;
  1493. guiShowStr(x,y,info, FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1494. }
  1495. void uiShowNoteSel(char StatusUpdate){
  1496. if(StatusUpdate){
  1497. guiClearAll(guiGetBackColor());
  1498. guiShowCaption(0,"提示音设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1499. uiMenuShowBottomLine();
  1500. noteSetTmp=newPara.KeySound;
  1501. switchFlash();
  1502. uiMenuShowBottomIndacitor("保存", "返回");
  1503. }
  1504. }
  1505. void uiShowNoteSelResponse(void){
  1506. unsigned short key=getKeyValue();
  1507. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1508. else if(MKEY_VALUE_MENU==key){
  1509. getStackStruct()->ok_back=1;
  1510. if(newPara.KeySound != noteSetTmp){
  1511. newPara.KeySound=noteSetTmp;
  1512. #ifndef ENABLE_PWM_BEEP
  1513. if(noteSetTmp==0) msgAtSend("AT+TONES=0\r\n");
  1514. else msgAtSend("AT+TONES=1\r\n");
  1515. #endif
  1516. sysIniSave();
  1517. }
  1518. uISetNextStatus(UIS_MENU_SYS_SEL);
  1519. }else if(MKEY_VALUE_DOWN || MKEY_VALUE_UP){
  1520. if(noteSetTmp==0) noteSetTmp=1;
  1521. else noteSetTmp=0;
  1522. switchFlash();
  1523. }
  1524. }
  1525. /*****************************提示音设置结束********************************/
  1526. void uiShowPassword(char StatusUpdate){
  1527. int len,x,y=GLCD_HEIGHT/2;
  1528. char info[60];
  1529. if(StatusUpdate){
  1530. guiClearAll(guiGetBackColor());
  1531. guiShowCaption(0,"本机密码",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1532. uiMenuShowBottomLine();
  1533. snprintf(info, sizeof(info), "%s",sutApp.account.password);
  1534. len=guiGetStrXLen(info,FONT_MODE_12X12);
  1535. x=(GLCD_WIDTH-len)/2;
  1536. guiShowStr(x,y-8,info,FONT_MODE_12X12,REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  1537. uiMenuShowBottomIndacitor(NULL, "返回");
  1538. }
  1539. }
  1540. void uiShowPasswordResponse(void){
  1541. unsigned short key=getKeyValue();
  1542. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1543. }
  1544. #ifdef MENU_TEST
  1545. ///////////////////////////////////测试
  1546. #define INFO1 "2021/05/17 16:16"
  1547. #define INFO2 "*我们都是中华人民共和国的子民。全球最大的中文搜索引擎、致力于让网民更便捷地获取信息,找到所求。百度超过千亿的中文网页数据库,可以瞬间找到相关的搜索结果,测试一二三四五六七八九十ABCDEFGHIJKLMNOPQRSTUVWXYZtest测试1234567890 abcdefghijklmnopqrstuvwxyz!"
  1548. #define INFO3 "end"
  1549. #include "newMessage.h"
  1550. int tflag=0;
  1551. void uiTest(char StatusUpdate){
  1552. char ret;
  1553. if(StatusUpdate){
  1554. guiClearAll(guiGetBackColor());
  1555. guiShowCaption(0,"测试",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1556. uiMenuShowBottomLine();
  1557. uiMenuShowBottomIndacitor(NULL, "返回");
  1558. switch(tflag){
  1559. case 0:ret=newMessageInit(FONT_MODE_12X12, NULL, NULL, INFO3);break;
  1560. case 1:ret=newMessageInit(FONT_MODE_12X12, NULL, INFO2, NULL);break;
  1561. case 2:ret=newMessageInit(FONT_MODE_12X12, NULL, INFO2, INFO3);break;
  1562. case 3:ret=newMessageInit(FONT_MODE_12X12, INFO1, NULL, NULL);break;
  1563. case 4:ret=newMessageInit(FONT_MODE_12X12, INFO1, NULL, INFO3);break;
  1564. case 5:ret=newMessageInit(FONT_MODE_12X12, INFO1, INFO2, NULL);break;
  1565. case 6:ret=newMessageInit(FONT_MODE_12X12, INFO1, INFO2, INFO3);break;
  1566. }
  1567. if(0!=ret){
  1568. guiShowMessageBox("异常");
  1569. uISetNextStatus(UIS_MENU_SYS_SEL);
  1570. }else{
  1571. if(++tflag>6) tflag=0;
  1572. }
  1573. }
  1574. }
  1575. void uiTestResponse(void){
  1576. unsigned short key=getKeyValue();
  1577. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1578. else if(MKEY_VALUE_DOWN==key) newMessageShow(SHOW_DOWN);
  1579. else if(MKEY_VALUE_UP==key) newMessageShow(SHOW_UP);
  1580. }
  1581. #endif