uiBlock.c 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563
  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. ""
  702. };
  703. if(flash){
  704. msgAtSend("AT+RSIM\r\n");//进此菜单前查询一下卡用于后面显示
  705. guiClearAll(guiGetBackColor());
  706. guiShowCaption(0,"系统设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  707. uiMenuShowBottomLine();
  708. uiMenuShowBottomIndacitor("确认", "返回");
  709. uiMenuInit(&sutMenuSysSetup,apcPtr,FONT_MODE_12X12,true);
  710. }
  711. }
  712. void sysTemSetResponse(void){
  713. unsigned short key;
  714. key=uiMenuResponse(&sutMenuSysSetup);
  715. if(MKEY_VALUE_MENU==key){
  716. switch(sutMenuSysSetup.handle){
  717. case 0://LCD设置
  718. uISetNextStatus(UIS_MENU_SYS_LCD);
  719. break;
  720. case 1://本机密码
  721. uISetNextStatus(UIS_MENU_SYS_PASS);
  722. break;
  723. case 2://功耗模式设置
  724. uISetNextStatus(UIS_MENU_SYS_PWR);
  725. break;
  726. case 3://服务器设置
  727. uISetNextStatus(UIS_MENU_SYS_SERVERPASS);
  728. break;
  729. case 4://版本升级
  730. uISetNextStatus(UIS_MENU_SYS_VERSION);
  731. break;
  732. case 5://提示音设置
  733. uISetNextStatus(UIS_MENU_SYS_NOTE);
  734. break;
  735. case 6://终端信息
  736. uISetNextStatus(UIS_MENU_SYS_INFO);
  737. break;
  738. case 7://SD卡检测
  739. uISetNextStatus(UIS_MENU_SYS_SD);
  740. break;
  741. case 8://留音记录设置
  742. uISetNextStatus(UIS_MENU_SYS_VOICE);
  743. break;
  744. }
  745. if(sutMenuSysSetup.handle<=8) uiPushStack(sutMenuSysSetup.handle);
  746. }else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_MAIN);
  747. }
  748. /*****************************系统设置部分结束*********************************/
  749. /*****************************定位设置部分开始*********************************/
  750. unsigned char tempGpsIndex;
  751. static locationTimeFlash(char type);
  752. static locationXYFlash(char flash);
  753. void uiShowMenuLocationSel(char flash){
  754. #ifdef MAKE_IT_COMMON_VERSION
  755. if(flash){
  756. guiClearAll(guiGetBackColor());
  757. guiShowCaption(0,"定位设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  758. uiMenuShowBottomLine();
  759. if(newPara.gpsEnable==0){
  760. uiMenuShowBottomIndacitor(NULL, "返回");
  761. guiShowMessageBox("版本不支持");
  762. nwy_sleep(1000);
  763. uISetNextStatus(UIS_MENU_MAIN);
  764. return;
  765. }
  766. uiMenuShowBottomIndacitor("保存", "返回");
  767. locationTimeFlash(0);
  768. }
  769. if(newPara.gpsEnable!=0) locationXYFlash(flash);
  770. #else
  771. static const char *apcPtr[]={
  772. "1,课程表",
  773. "2,通知简报",
  774. ""
  775. };
  776. if(flash){
  777. guiClearAll(guiGetBackColor());
  778. guiShowCaption(0,"消息通知",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  779. uiMenuShowBottomLine();
  780. uiMenuShowBottomIndacitor("确认", "返回");
  781. uiMenuInit(&sutMenuSysSetup,apcPtr,FONT_MODE_12X12,true);
  782. }
  783. #endif
  784. }
  785. void loationSetResponse(void){
  786. #ifdef MAKE_IT_COMMON_VERSION
  787. unsigned short key;
  788. key=getKeyValue();
  789. if(MKEY_VALUE_UP==key) locationTimeFlash(1);
  790. else if(MKEY_VALUE_DOWN==key) locationTimeFlash(2);
  791. else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_MAIN);
  792. else if(MKEY_VALUE_MENU==key){
  793. if(tempGpsIndex != newPara.gpsTimeIndex){
  794. MSG_INFO(1, "GPS timeIndex update:%d",getGPSTimeValue(tempGpsIndex));
  795. newPara.gpsTimeIndex=tempGpsIndex;
  796. sysIniSave();
  797. gpsCheckInfo();//检测一下
  798. }
  799. uISetNextStatus(UIS_MENU_MAIN);
  800. }
  801. #else
  802. unsigned short key;
  803. key=uiMenuResponse(&sutMenuSysSetup);
  804. if(MKEY_VALUE_MENU==key){
  805. switch(sutMenuSysSetup.handle){
  806. case 0://课程表
  807. uISetNextStatus(UIS_MENU_LOCATION_CLASS);
  808. break;
  809. case 1://消息通知
  810. uISetNextStatus(UIS_MENU_LOCATION_NOTICE);
  811. break;
  812. }
  813. if(sutMenuSysSetup.handle<=1) uiPushStack(sutMenuSysSetup.handle);
  814. }else if(MKEY_VALUE_ESC==key){
  815. sdUnmount();
  816. uISetNextStatus(UIS_MENU_MAIN);
  817. }
  818. #endif
  819. }
  820. static locationTimeFlash(char type){
  821. unsigned short gpsTimeValue;
  822. char buf[50];
  823. unsigned short y=70;
  824. if(type==0){
  825. tempGpsIndex=newPara.gpsTimeIndex;
  826. }else if(type==1){
  827. if(++tempGpsIndex>=GPS_TABLE_NUM) tempGpsIndex=0;
  828. }else if(type==2){
  829. if(tempGpsIndex>0) tempGpsIndex--;
  830. else tempGpsIndex=GPS_TABLE_NUM-1;
  831. }else return;
  832. gpsTimeValue=getGPSTimeValue(tempGpsIndex);
  833. if(gpsTimeValue==0) snprintf(buf, sizeof(buf), "定位上传设置:关闭");
  834. else snprintf(buf, sizeof(buf), "定位上传设置:%d秒",gpsTimeValue);
  835. guiClearRect(0,y,GLCD_WIDTH-1, y+12,guiGetBackColor());
  836. guiShowStr(30,y, buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  837. }
  838. static locationXYFlash(char flash){
  839. char buf[50];
  840. unsigned short y=UI_CONTENT_SHOW_Y+2;
  841. if(gpsInfo.update==0 && flash==0) return;
  842. gpsInfo.update=0;
  843. guiClearRect(0, y,GLCD_WIDTH-1, y+12+5+12,guiGetBackColor());
  844. snprintf(buf, sizeof(buf), "纬度 S:%d.%05d",gpsInfo.Lat/1000000,gpsInfo.Lat%1000000);
  845. guiShowStr(30,y, buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  846. y+=12+5;
  847. snprintf(buf, sizeof(buf), "经度 W:%d.%05d",gpsInfo.Long/1000000,gpsInfo.Long%1000000);
  848. guiShowStr(30,y, buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  849. }
  850. /*****************************定位设置部分结束*********************************/
  851. /*******************************终端信息开始**********************************/
  852. unsigned char sysInfoType;
  853. static void sysInfoFlash(void){
  854. unsigned short x,y;
  855. char buf[50];
  856. unsigned char LineSpace=12+4;
  857. int len;
  858. x=2,y=UI_CONTENT_SHOW_Y+5;
  859. guiClearRect(0,y,GLCD_WIDTH-1,UI_BOTTOM_LINE_Y-1,guiGetBackColor());
  860. if(sysInfoType==0){
  861. //终端型号
  862. snprintf(buf, sizeof(buf),"终端型号:%s",OHPOC_APP_NAME);
  863. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  864. y+=LineSpace;
  865. //终端编码
  866. snprintf(buf, sizeof(buf),"终端编码:%lu",sutApp.account.psn);
  867. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  868. y+=LineSpace;
  869. //应用版本
  870. snprintf(buf, sizeof(buf),"应用版本:%s",OHPOC_VERSION);
  871. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  872. y+=LineSpace;
  873. //内部版本
  874. snprintf(buf, sizeof(buf),"内部版本:%d",CUSTOMER_CODE);
  875. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  876. }else if(sysInfoType==1){
  877. //对讲版本号
  878. snprintf(buf, sizeof(buf),"对讲版本:%s",sutApp.pocVersion);
  879. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  880. y+=LineSpace;
  881. //模块
  882. memset(buf,sizeof(buf),0);
  883. snprintf(buf,sizeof(buf),"模块:%s", sutApp.modemVer);
  884. len=strlen(buf);
  885. if(len>20){
  886. y+=LineSpace;
  887. guiShowStr(x+32,y,buf+20,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  888. buf[20]=0;
  889. y-=LineSpace;
  890. }
  891. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  892. }else if(sysInfoType==2){
  893. //显示服务器
  894. //对讲IP
  895. //getPIPAddr();getGIPAddr();
  896. guiShowStr(x,y,"交换服务器:",FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  897. y+= LineSpace;
  898. snprintf(buf, sizeof(buf),"%s",showPIP);
  899. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  900. y+=LineSpace;
  901. //GPS IP
  902. guiShowStr(x,y,"定位服务器:",FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  903. y+= LineSpace;
  904. snprintf(buf, sizeof(buf),"%s",showGIP);
  905. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  906. y+=LineSpace;
  907. snprintf(buf, sizeof(buf),"端口:%d",newPara.gpsPort);
  908. guiShowStr(x,y,buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK,guiGetBackColor());
  909. }
  910. }
  911. void uiShowInformation(char update){
  912. if(update){
  913. sysInfoType=0;
  914. guiClearAll(guiGetBackColor());
  915. guiShowCaption(0,"终端信息",UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  916. uiMenuShowBottomLine();
  917. uiMenuShowBottomIndacitor(NULL, "返回");
  918. sysInfoFlash();
  919. }
  920. }
  921. void uiShowInformationResponse(void){
  922. unsigned short key=getKeyValue();
  923. if(MKEY_VALUE_ESC==key) uISetNextStatus(sutUIstatus.LastStatus);
  924. else if(MKEY_VALUE_DOWN==key || MKEY_VALUE_UP==key){
  925. if(sysInfoType==0) sysInfoType=1;
  926. else sysInfoType=0;
  927. sysInfoFlash();
  928. }else if(MKEY_VALUE_CB_IP==key){
  929. sysInfoType=2;
  930. sysInfoFlash();
  931. }
  932. }
  933. /*****************************终端信息结束**********************************/
  934. /*******************************留音记录开始**********************************/
  935. void uiShowVoiceInfo(char update){
  936. static unsigned int timer;
  937. static char *showInfo[3+1];
  938. static char empty;
  939. int i;
  940. if(update){
  941. guiClearAll(guiGetBackColor());
  942. guiShowCaption(0,"留音记录",UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  943. uiMenuShowBottomLine();
  944. uiMenuShowBottomIndacitor("播放", "返回");
  945. sutApp.voiceInfo.update=0;
  946. sutApp.voiceInfo.aNum=0;
  947. sutApp.voiceInfo.vNum=0;
  948. sutApp.voiceInfo.voiceValidNum=0;
  949. sutApp.voiceInfo.voiceStatus=1;
  950. empty=0;
  951. msgAtSend("AT+VINFO?\r\n");
  952. guiShowMessageBox("请稍后");
  953. uTimerStart(&timer, 2000);
  954. }
  955. switch(sutApp.voiceInfo.voiceStatus){
  956. case 1:
  957. if(sutApp.voiceInfo.update!=0){
  958. sutApp.voiceInfo.voiceStatus=2;
  959. break;
  960. }
  961. if(uTimerExpired(&timer)){
  962. showInfo[0]="空";
  963. sutApp.voiceInfo.voiceStatus=2;
  964. empty=1;
  965. //MSG_INFO(1, "==>Empty");
  966. }
  967. break;
  968. case 2:
  969. if(empty==0) for(i=0;i<sutApp.voiceInfo.voiceValidNum;i++) showInfo[i]=sutApp.voiceInfo.info[i].info;
  970. else i=1;
  971. showInfo[i]=NullPtr;
  972. guiFillRect(0,UI_CONTENT_SHOW_Y,GLCD_WIDTH-1,UI_BOTTOM_SHOW_Y-1,guiGetBackColor());
  973. uiMenuInit(&sutMenuSysSetup,showInfo,FONT_MODE_12X12,false);
  974. sutApp.voiceInfo.voiceStatus=3;
  975. break;
  976. }
  977. }
  978. void uiShowVoiceInfoResponse(void){
  979. char cmd[30];
  980. unsigned short key;
  981. if(sutApp.voiceInfo.voiceStatus!=3) return;
  982. key=uiMenuResponse(&sutMenuSysSetup);
  983. if(MKEY_VALUE_ESC==key) uISetNextStatus(sutUIstatus.LastStatus);
  984. else if(MKEY_VALUE_MENU==key){
  985. if(sutApp.voiceInfo.voiceValidNum!=0){
  986. snprintf(cmd, sizeof(cmd), "AT+VPLAY=%c\r\n", sutApp.voiceInfo.info[sutMenuSysSetup.handle].index);
  987. msgAtSend(cmd);
  988. }
  989. }
  990. }
  991. /*****************************留音记录结束**********************************/
  992. /*****************************SD卡检测***************************************/
  993. void uiShowSD(char update){
  994. static unsigned int timer;
  995. if(update){
  996. sysInfoType=0;
  997. guiClearAll(guiGetBackColor());
  998. guiShowCaption(0,"SD卡检测",UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  999. guiShowMessageBox("正在检测");
  1000. uiMenuShowBottomLine();
  1001. if(true==sdCardTest()) guiShowMessageBox("SD卡正常");
  1002. else guiShowMessageBox("SD卡异常");
  1003. uTimerStart(&timer, 2000);
  1004. }
  1005. if(uTimerExpired(&timer)){
  1006. getStackStruct()->ok_back=1;
  1007. uISetNextStatus(sutUIstatus.LastStatus);
  1008. }
  1009. }
  1010. /*****************************SD卡检测结束***********************************/
  1011. static const char *commonIcon2[]={
  1012. "APN.bmp",
  1013. "APN1.bmp",
  1014. ""
  1015. };
  1016. /*****************************LCD设置开始**********************************/
  1017. unsigned char lcdTmpIndex;
  1018. static void lcdTimeFlash(char type){
  1019. char buf[50];
  1020. unsigned short x=4,y=56,value;
  1021. if(type==0) guiShowStr(x+25, y, "背光时间:", FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1022. else if(type==1){
  1023. if(++lcdTmpIndex>=5) lcdTmpIndex=0;
  1024. }else if(type==2){
  1025. if(lcdTmpIndex>0) lcdTmpIndex--;
  1026. else lcdTmpIndex=4;
  1027. }
  1028. value=newPara.lcdParaList[lcdTmpIndex];
  1029. if(value==0) snprintf(buf, sizeof(buf), " 常亮 ");
  1030. else snprintf(buf, sizeof(buf), "%3d 秒", value);
  1031. guiShowStr(x+85, y, buf, FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1032. }
  1033. void uiShowLcdSel(char StatusUpdate){
  1034. if(StatusUpdate){
  1035. guiClearAll(guiGetBackColor());
  1036. guiShowCaption(0,"LCD设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1037. uiMenuShowBottomLine();
  1038. lcdTmpIndex=newPara.lcdParaDefaultIndex;
  1039. lcdTimeFlash(0);
  1040. uiMenuShowBottomIndacitor("保存", "返回");
  1041. }
  1042. }
  1043. void uiShowLcdSelResponse(void){
  1044. unsigned short key=getKeyValue();
  1045. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1046. else if(MKEY_VALUE_DOWN==key)lcdTimeFlash(1);
  1047. else if(MKEY_VALUE_UP==key) lcdTimeFlash(2);
  1048. else if(MKEY_VALUE_MENU==key){
  1049. getStackStruct()->ok_back=1;
  1050. if(lcdTmpIndex != newPara.lcdParaDefaultIndex){
  1051. newPara.lcdParaDefaultIndex=lcdTmpIndex;
  1052. MSG_INFO(1, "LCD TimeUpdate");
  1053. backLightReset();
  1054. sysIniSave();
  1055. }
  1056. uISetNextStatus(UIS_MENU_SYS_SEL);
  1057. }
  1058. }
  1059. /*****************************LCD设置结束**********************************/
  1060. /*****************************网络设置开始**********************************/
  1061. const unsigned char netModeSetTable[3]={1,2,4};//设置制式:AUTH,2G,4G
  1062. /*输入制式源始值,返回索引值对应值*/
  1063. unsigned char getNetModeIndex(unsigned char netModeValue){
  1064. unsigned char i;
  1065. for(i=0;i<sizeof(netModeSetTable);i++){
  1066. if(netModeValue==netModeSetTable[i]) return i;
  1067. }
  1068. return 0xff;//无对应值
  1069. }
  1070. /*输入制式索引值,返回制式源始值*/
  1071. unsigned char getNetModeValue(unsigned char netModeIndex){
  1072. if(netModeIndex>=sizeof(netModeSetTable)) return 0xff;
  1073. else return netModeSetTable[netModeIndex];
  1074. }
  1075. /*输入制式索引值,发送对应该命令给模块*/
  1076. void netModeSetCmd(unsigned char netModeIndex){
  1077. char buf[30];
  1078. unsigned char netModeValue=getNetModeValue(netModeIndex);
  1079. if(netModeValue==0xff){
  1080. MSG_ERR(1,"netMode index invalid:%d",netModeIndex);
  1081. return;
  1082. }
  1083. snprintf(buf, sizeof(buf), "AT$MYSYSINFO=%d\r\n",netModeValue);
  1084. msgAtSend(buf);
  1085. }
  1086. #define NET_MODE_NUM 3
  1087. void uiShowNetSel(char StatusUpdate){
  1088. static const char *netMode[NET_MODE_NUM+1]={
  1089. "AUTO",
  1090. "2G",
  1091. "4G",
  1092. ""
  1093. };
  1094. char Features[NET_MODE_NUM];
  1095. unsigned char i;
  1096. if(StatusUpdate){
  1097. guiClearAll(guiGetBackColor());
  1098. guiShowCaption(0,"网络设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1099. uiMenuShowBottomLine();
  1100. for(i=0;i<NET_MODE_NUM;i++){
  1101. if(i==newPara.netMode) Features[i]=1;
  1102. else Features[i]=0;
  1103. }
  1104. ListBoxInit(&sutListBox,netMode,0,commonIcon2,Features);
  1105. uiMenuShowBottomIndacitor("保存", "返回");
  1106. }
  1107. }
  1108. void uiShowNetSelResponse(void){
  1109. unsigned short key=ListBoxResponse(&sutListBox);
  1110. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1111. else if(MKEY_VALUE_MENU==key){
  1112. getStackStruct()->ok_back=1;
  1113. if(sutListBox.handle != newPara.netMode){
  1114. newPara.netMode=sutListBox.handle;
  1115. MSG_INFO(1, "netMode update:%d", newPara.netMode);
  1116. sysIniSave();
  1117. netModeSetCmd(newPara.netMode);
  1118. }
  1119. uISetNextStatus(UIS_MENU_SYS_SEL);
  1120. }
  1121. }
  1122. /*****************************网络设置结束**********************************/
  1123. /*****************************卡选择设置开始**********************************/
  1124. #define SIM_MODE_NUM 2
  1125. void uiShowSimSel(char StatusUpdate){
  1126. static const char *simMode[SIM_MODE_NUM+1]={
  1127. "卡1",
  1128. "卡2",
  1129. ""
  1130. };
  1131. char Features[SIM_MODE_NUM];
  1132. unsigned char i;
  1133. if(StatusUpdate){
  1134. guiClearAll(guiGetBackColor());
  1135. guiShowCaption(0,"SIM设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1136. uiMenuShowBottomLine();
  1137. for(i=0;i<SIM_MODE_NUM;i++){
  1138. if(i==sutApp.simSel) Features[i]=1;
  1139. else Features[i]=0;
  1140. }
  1141. ListBoxInit(&sutListBox,simMode,0,commonIcon2,Features);
  1142. uiMenuShowBottomIndacitor("保存", "返回");
  1143. }
  1144. }
  1145. void uiShowSimSelResponse(void){
  1146. char buf[30];
  1147. unsigned short key=ListBoxResponse(&sutListBox);
  1148. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1149. else if(MKEY_VALUE_MENU==key){
  1150. getStackStruct()->ok_back=1;
  1151. if(sutListBox.handle != sutApp.simSel){
  1152. snprintf(buf, sizeof(buf), "AT+SSIM=%d\r\n",sutListBox.handle+1);
  1153. msgAtSend(buf);
  1154. guiShowMessageBox("请重启设备");
  1155. msgAtSend("AT+TRB=1\r\n");
  1156. nwy_sleep(100);
  1157. for(;;){
  1158. MSG_INFO(1, "card changed, wait user reboot");
  1159. CTL_POWER_HOLD(0);
  1160. nwy_sleep(1000);
  1161. }
  1162. }
  1163. uISetNextStatus(UIS_MENU_SYS_SEL);
  1164. }
  1165. }
  1166. /*****************************卡选择设置结束**********************************/
  1167. /*****************************功耗设置开始**********************************/
  1168. typedef enum{
  1169. PMODE_DEFAULT_LOW,
  1170. PMODE_SUPER_LOW,
  1171. PMODE_NORMAL
  1172. }PWR_ENUMDEF;
  1173. //低功耗模式
  1174. #define MODE_LOW_PWR_NONE_4G 5
  1175. #define MODE_LOW_PWR_IS_4G 25
  1176. //超长待机模式
  1177. #define MODE_LONG_LOW_PWR_NONE_4G 5
  1178. #define MODE_LONG_LOW_PWR_IS_4G 55
  1179. //常规模式
  1180. #define MODE_NORMAL__NONE_4G 5
  1181. #define MODE_NORMAL__IS_4G 5
  1182. //终端放弃设置模式,由服务器决定使用什么
  1183. #define MODE_AUTO____NONE_4G 0
  1184. #define MODE_AUTO____IS_4G 0
  1185. //默认功耗模式
  1186. #define MODE_PWR_DEFAULT_NONE_4G MODE_LOW_PWR_NONE_4G
  1187. #define MODE_PWR_DEFAULT_IS_4G MODE_LOW_PWR_IS_4G
  1188. static void pwrModeSetCmd(unsigned char pwrMode){
  1189. unsigned char seg1,seg2;
  1190. char buf[30];
  1191. if(pwrMode==PMODE_DEFAULT_LOW){
  1192. seg1=MODE_PWR_DEFAULT_NONE_4G;
  1193. seg2=MODE_PWR_DEFAULT_IS_4G;
  1194. }else if(pwrMode==PMODE_SUPER_LOW){
  1195. seg1=MODE_LONG_LOW_PWR_NONE_4G;
  1196. seg2=MODE_LONG_LOW_PWR_IS_4G;
  1197. }else if(pwrMode==PMODE_NORMAL){
  1198. seg1=MODE_NORMAL__NONE_4G;
  1199. seg2=MODE_NORMAL__IS_4G;
  1200. }else return;
  1201. snprintf(buf, sizeof(buf), "AT+UDP=%d,%d\r\n",seg1,seg2);
  1202. msgAtSend(buf);
  1203. }
  1204. void pwrModeAckHandler(unsigned char seg1, unsigned char seg2){
  1205. if(seg1==MODE_PWR_DEFAULT_NONE_4G && seg2==MODE_PWR_DEFAULT_IS_4G && newPara.pwrMode != PMODE_DEFAULT_LOW){
  1206. goto SAVE_PWR_MODE;
  1207. }else if(seg1==MODE_LONG_LOW_PWR_NONE_4G && seg2==MODE_LONG_LOW_PWR_IS_4G && newPara.pwrMode != PMODE_SUPER_LOW){
  1208. goto SAVE_PWR_MODE;
  1209. }else if(seg1==MODE_NORMAL__NONE_4G && seg2==MODE_NORMAL__IS_4G && newPara.pwrMode != PMODE_NORMAL){
  1210. goto SAVE_PWR_MODE;
  1211. }else if(seg2!=MODE_LOW_PWR_IS_4G&&seg2!=MODE_LONG_LOW_PWR_IS_4G&& seg2!=MODE_NORMAL__IS_4G){
  1212. //Seg2 3个模式都不满足则切换为默认模式
  1213. newPara.pwrMode = PMODE_DEFAULT_LOW;
  1214. goto SAVE_PWR_MODE;
  1215. }
  1216. return;
  1217. SAVE_PWR_MODE:
  1218. sysIniSave();
  1219. pwrModeSetCmd(newPara.pwrMode);
  1220. }
  1221. #define PWR_MODE_NUM 3
  1222. void uiShowPwrSel(char StatusUpdate){
  1223. static const char *pwrMode[PWR_MODE_NUM+1]={
  1224. "低功耗模式",
  1225. "超长省电模式",
  1226. "常规模式",
  1227. "",
  1228. };
  1229. char Features[PWR_MODE_NUM];
  1230. unsigned char i;
  1231. if(StatusUpdate){
  1232. guiClearAll(guiGetBackColor());
  1233. guiShowCaption(0,"功耗设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1234. uiMenuShowBottomLine();
  1235. for(i=0;i<PWR_MODE_NUM;i++){
  1236. if(i==newPara.pwrMode) Features[i]=1;
  1237. else Features[i]=0;
  1238. }
  1239. ListBoxInit(&sutListBox,pwrMode,0,commonIcon2,Features);
  1240. uiMenuShowBottomIndacitor("保存", "返回");
  1241. }
  1242. }
  1243. void uiShowPwrSelResponse(void){
  1244. unsigned short key=ListBoxResponse(&sutListBox);
  1245. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1246. else if(MKEY_VALUE_MENU==key){
  1247. getStackStruct()->ok_back=1;
  1248. if(sutListBox.handle != newPara.pwrMode){
  1249. newPara.pwrMode=sutListBox.handle;
  1250. MSG_INFO(1, "pwrMode update:%d", newPara.pwrMode);
  1251. sysIniSave();
  1252. pwrModeSetCmd(newPara.pwrMode);
  1253. }
  1254. uISetNextStatus(UIS_MENU_SYS_SEL);
  1255. }
  1256. }
  1257. /*****************************功耗设置结束**********************************/
  1258. /*****************************服务器设置输入密码开始**********************************/
  1259. void uiShowServerPassSel(char StatusUpdate){
  1260. if(StatusUpdate){
  1261. guiClearAll(guiGetBackColor());
  1262. guiShowCaption(0,"密码验证",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1263. uiMenuShowBottomLine();
  1264. NumEditInit(&sutNumEdit,(GLCD_WIDTH-6*8)/2,(GLCD_HEIGHT-16)/2,"000000");
  1265. NumEditShow(&sutNumEdit);
  1266. uiMenuShowBottomIndacitor("[上]加值", "[下]移动");
  1267. }
  1268. }
  1269. void uiShowServerSelPassResponse(void){
  1270. unsigned short key=getKeyValue();
  1271. NumEditResponse(&sutNumEdit);
  1272. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1273. else if(MKEY_VALUE_MENU==key){
  1274. if(memcmp(sutNumEdit.buffer, getMenuKey(), 6)==0) uISetNextStatus(UIS_MENU_SYS_SERVER);
  1275. else{
  1276. guiShowMessageBox("密码错误");
  1277. nwy_sleep(1000);
  1278. getStackStruct()->ok_back=1;
  1279. uISetNextStatus(UIS_MENU_SYS_SEL);
  1280. }
  1281. }
  1282. }
  1283. /*****************************服务器设置输入密码结束**********************************/
  1284. /*****************************服务器设置开始**********************************/
  1285. void uiShowServerSel(char StatusUpdate){
  1286. static const char *serIcons[]={
  1287. "Ser.bmp",
  1288. "Sersel.bmp",
  1289. ""
  1290. };
  1291. static const char *serName[]={
  1292. "杭州服务器",
  1293. "山东服务器",
  1294. "IP分发服务器",
  1295. "集群服务器",
  1296. "自定义服务器",
  1297. "",
  1298. };
  1299. char Features[5];
  1300. unsigned char tempSer,i;
  1301. if(StatusUpdate){
  1302. guiClearAll(guiGetBackColor());
  1303. guiShowCaption(0,"服务器列表",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1304. uiMenuShowBottomLine();
  1305. uiMenuShowBottomIndacitor("确认", "返回");
  1306. tempSer=newPara.serList.defaultuse;
  1307. for(i=0;i<=SERVER_UR;i++){
  1308. if(i==tempSer) Features[i]=1;
  1309. else Features[i]=0;
  1310. }
  1311. ListBoxInit(&sutListBox,serName,0,serIcons,Features);
  1312. }
  1313. }
  1314. void uiShowServerSelResponse(void){
  1315. unsigned char tempSer;
  1316. char buf[50],buf1[100];
  1317. unsigned short key=ListBoxResponse(&sutListBox);
  1318. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1319. else if(MKEY_VALUE_MENU==key){
  1320. tempSer=sutListBox.handle;
  1321. if(tempSer != newPara.serList.defaultuse){
  1322. newPara.serList.defaultuse=tempSer;
  1323. sysIniSave();
  1324. getGIPAddr();
  1325. snprintf(buf, sizeof(buf), "ip=%s;domain=%s;",getPIPAddr(),getDOMAINAddr());
  1326. AscStrTurnHexStr(buf,buf1);
  1327. msgAtSend("AT+POC=010000");
  1328. msgAtSend(buf1);
  1329. msgAtSend("\r\n");
  1330. nwy_sleep(100);
  1331. msgAtSend("AT+POC=040000\r\n");
  1332. }
  1333. uISetNextStatus(UIS_STANDBY );
  1334. }
  1335. }
  1336. /*****************************服务器设置结束**********************************/
  1337. /*****************************版本设置开始**********************************/
  1338. unsigned char fotaStep;
  1339. unsigned int fotaTick;
  1340. void fotaStepSet(unsigned char newStep){
  1341. fotaStep=newStep;
  1342. }
  1343. void fotaMsgShow(char *msg){
  1344. int len=guiGetStrXLen((char *)msg,FONT_MODE_16X16);
  1345. guiClearRect(0, 60, GLCD_WIDTH-1, 60+16,guiGetBackColor());
  1346. guiShowStr((GLCD_WIDTH-len)/2,60, msg,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1347. }
  1348. void fotaMsgShow2(char *msg1, char *msg2){
  1349. guiClearRect(0, 45, GLCD_WIDTH-1, 45+16+2+16,guiGetBackColor());
  1350. int len=guiGetStrXLen((char *)msg1,FONT_MODE_16X16);
  1351. guiShowStr((GLCD_WIDTH-len)/2,45, msg1,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1352. len=guiGetStrXLen((char *)msg2,FONT_MODE_16X16);
  1353. guiShowStr((GLCD_WIDTH-len)/2,45+16+2, msg2,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1354. }
  1355. void uiShowVersionSel(char StatusUpdate){
  1356. if(StatusUpdate){
  1357. sutApp.fotaVersion[0]=0;
  1358. guiClearAll(guiGetBackColor());
  1359. guiShowCaption(0,"版本更新",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1360. msgAtSend("AT+FOTA?\r\n");
  1361. fotaStep=0;
  1362. fotaMsgShow("正在检测版本");
  1363. uiMenuShowBottomLine();
  1364. uiMenuShowBottomIndacitor("确定", "返回");
  1365. uTimerStart(&fotaTick, 500);
  1366. }
  1367. switch(fotaStep){
  1368. case 0:
  1369. if(uTimerExpired(&fotaTick)){
  1370. fotaMsgShow("检测超时");
  1371. fotaStep=4;
  1372. }
  1373. break;
  1374. case 1://等待用户确定
  1375. break;
  1376. case 2://用户确定后等待结果
  1377. if(uTimerExpired(&fotaTick)){
  1378. fotaMsgShow("超时退出");
  1379. fotaStep=4;
  1380. }
  1381. break;
  1382. case 3://下载成功
  1383. nwy_sleep(1000);
  1384. fotaStep=6;
  1385. fotaMsgShow2("确定将关机,需长按开","机键直至开机(约60秒)");
  1386. break;
  1387. case 4://延时显示2秒后退出
  1388. uTimerStart(&fotaTick, 2000);
  1389. fotaStep=5;
  1390. break;
  1391. case 5://退出升级流程
  1392. if(uTimerExpired(&fotaTick)) uISetNextStatus(UIS_MENU_SYS_SEL);
  1393. break;
  1394. case 6:
  1395. break;
  1396. }
  1397. }
  1398. void uiShowVersionSelResponse(void){
  1399. unsigned char key=getKeyValue();
  1400. if(fotaStep!=1 && fotaStep!=6) return;
  1401. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1402. else if(MKEY_VALUE_MENU==key){
  1403. if(fotaStep==1){
  1404. fotaMsgShow("请勿断电!");
  1405. fotaStep=2;
  1406. msgAtSend("AT+FOTA=1\r\n");
  1407. uTimerStart(&fotaTick, 10000);
  1408. }else if(fotaStep==6){
  1409. if(nwy_version_update(true)<0){
  1410. MSG_ERR(1, "nwy_version_update failed");
  1411. fotaMsgShow("升级异常");
  1412. fotaStep=5;
  1413. }
  1414. msgAtSend("AT+TRB=2\r\n");
  1415. MSG_INFO(1, "Reset system!!!");
  1416. while(1){nwy_sleep(1000);}
  1417. }
  1418. }
  1419. }
  1420. /*****************************版本设置结束**********************************/
  1421. /*****************************提示音设置开始********************************/
  1422. unsigned char noteSetTmp;
  1423. static void switchFlash(void){
  1424. char info[30];
  1425. unsigned short x,y,len;
  1426. if(noteSetTmp==0) snprintf(info, sizeof(info), "关闭");
  1427. else snprintf(info, sizeof(info), "打开");
  1428. len=guiGetStrXLen((char *)info, FONT_MODE_12X12);
  1429. x=(GLCD_WIDTH-len)/2;
  1430. y=UI_CONTENT_SHOW_Y+(GLCD_HEIGHT-UI_CONTENT_SHOW_Y)/2-12;
  1431. guiShowStr(x,y,info, FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1432. }
  1433. void uiShowNoteSel(char StatusUpdate){
  1434. if(StatusUpdate){
  1435. guiClearAll(guiGetBackColor());
  1436. guiShowCaption(0,"提示音设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1437. uiMenuShowBottomLine();
  1438. noteSetTmp=newPara.KeySound;
  1439. switchFlash();
  1440. uiMenuShowBottomIndacitor("保存", "返回");
  1441. }
  1442. }
  1443. void uiShowNoteSelResponse(void){
  1444. unsigned short key=getKeyValue();
  1445. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1446. else if(MKEY_VALUE_MENU==key){
  1447. getStackStruct()->ok_back=1;
  1448. if(newPara.KeySound != noteSetTmp){
  1449. newPara.KeySound=noteSetTmp;
  1450. #ifndef ENABLE_PWM_BEEP
  1451. if(noteSetTmp==0) msgAtSend("AT+TONES=0\r\n");
  1452. else msgAtSend("AT+TONES=1\r\n");
  1453. #endif
  1454. sysIniSave();
  1455. }
  1456. uISetNextStatus(UIS_MENU_SYS_SEL);
  1457. }else if(MKEY_VALUE_DOWN || MKEY_VALUE_UP){
  1458. if(noteSetTmp==0) noteSetTmp=1;
  1459. else noteSetTmp=0;
  1460. switchFlash();
  1461. }
  1462. }
  1463. /*****************************提示音设置结束********************************/
  1464. void uiShowPassword(char StatusUpdate){
  1465. int len,x,y=GLCD_HEIGHT/2;
  1466. char info[60];
  1467. if(StatusUpdate){
  1468. guiClearAll(guiGetBackColor());
  1469. guiShowCaption(0,"本机密码",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1470. uiMenuShowBottomLine();
  1471. snprintf(info, sizeof(info), "%s",sutApp.account.password);
  1472. len=guiGetStrXLen(info,FONT_MODE_12X12);
  1473. x=(GLCD_WIDTH-len)/2;
  1474. guiShowStr(x,y-8,info,FONT_MODE_12X12,REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  1475. uiMenuShowBottomIndacitor(NULL, "返回");
  1476. }
  1477. }
  1478. void uiShowPasswordResponse(void){
  1479. unsigned short key=getKeyValue();
  1480. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1481. }