uiBlock.c 53 KB

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