uiBlock.c 51 KB

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