uiBlock.c 48 KB

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