uiBlock(3839).c 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097
  1. #include "includes.h"
  2. unsigned char uiTmpVal;
  3. /****************************状态栏显示部分开始***********************************/
  4. //显示信号强度
  5. static void ShowSingle(int CSQ){
  6. unsigned short x=SIGNAL_ICON_X;
  7. unsigned short y=2;
  8. //if(sutApp.pocPpp == 0) guiShowBmp(x,y,"Single.bmp");
  9. //else guiShowBmp(x,y,"SingleOK.bmp");
  10. guiShowBinMap(0,1,"signal.bin");
  11. //11 3格
  12. x += 7;
  13. if(CSQ<5 || CSQ==99){
  14. GuiDrawSignalVLine(5);
  15. }else if(CSQ<11){
  16. GuiDrawSignalVLine(4);
  17. }else if(CSQ<18){
  18. GuiDrawSignalVLine(3);
  19. }else if(CSQ<22){
  20. GuiDrawSignalVLine(2);
  21. }else{
  22. GuiDrawSignalVLine(1);
  23. }
  24. }
  25. unsigned char netshowvalue=0xff;
  26. unsigned char ctecCurrentSet=0;
  27. //显示网络制式
  28. static void Show_Net(unsigned char s_netshowvalue){
  29. unsigned short y=0;
  30. if(s_netshowvalue==4){
  31. if(sutApp.UserInfo.tnet==5) newGuiShowStr(19, 1, "5G",REVERSED_NO,FONT_MODE_12X12);
  32. else newGuiShowStr(19, 1, "4G",REVERSED_NO,FONT_MODE_12X12);
  33. }
  34. }
  35. static void gpsIconShow(char flash){
  36. typedef struct{
  37. unsigned char located:1;
  38. unsigned char auth:1;
  39. unsigned char gpsF:1;
  40. }TMP_GPS_DEF;
  41. static TMP_GPS_DEF tmpGps;
  42. unsigned short x=GPS_ICON_X,y=0;
  43. return;
  44. if(tmpGps.located==gpsInfo.gpsLocated && tmpGps.auth==gpsInfo.bbAuth && tmpGps.gpsF==gpsInfo.gpsF && flash==0) return;
  45. guiClearRect(x,y,x+GPS_ICON_WX,y+11,COLOR_STATUS_BAR);
  46. if(gpsInfo.gpsF==0){//GPS未打开时
  47. if(gpsInfo.bbAuth==1) guiShowBmp(x,y,"GPS3.bmp");//已鉴权
  48. }else{//GPS已打开
  49. if(gpsInfo.bbAuth==1) guiShowBmp(x,y,"GPS1.bmp");//已鉴权
  50. else if(gpsInfo.bbAuth==1) guiShowBmp(x,y,"GPSA.bmp");//未鉴权
  51. if(gpsInfo.gpsLocated==1) guiShowBmp(x+10,y,"GPS2.bmp");//已定位
  52. }
  53. tmpGps.located=gpsInfo.gpsLocated;
  54. tmpGps.auth=gpsInfo.bbAuth;
  55. tmpGps.gpsF=gpsInfo.gpsF;
  56. }
  57. static void ShowCardType(char card){
  58. unsigned short x= CARD_ICON_X;
  59. unsigned short y=3;
  60. if(card==0) guiShowBmp(x, y, "SIM1.bmp");
  61. else if(card==1) guiShowBmp(x, y, "SIM2.bmp");
  62. }
  63. //显示电量
  64. static void ShowBatttery(int bat,unsigned int exeInterval){
  65. #if 0
  66. static unsigned int flashCnt=0;
  67. static unsigned char flag=0;
  68. static unsigned short cnt=0;
  69. unsigned short x=BAT_ICON_X,y=2,h=y+2;
  70. if(sutApp.chargeStatus!=0){//正在充电
  71. guiShowBmp(x, y, "CHARGE.bmp");
  72. }else if(bat<WARN_PWR_LEVEL){//请充电
  73. if(++cnt<(800/exeInterval)) return;
  74. cnt=0;
  75. if(sutApp.lowPwrWarn==0){
  76. sutApp.lowPwrWarn=1;
  77. sutApp.lowPwrCnt=WARN_TTS_INTERVAL-5000;//从非充电电压到充电电压,持续5秒开始播放,如果跳回非充电电压
  78. }
  79. if(flag==0){
  80. guiShowBmp(x,y,"VBAT1.bmp");
  81. flag=1;
  82. }else{
  83. flag=0;
  84. guiClearRect(x,y-2,x+21,y-2+0+12,COLOR_STATUS_BAR);
  85. }
  86. return;
  87. }else if(bat<355){//340<x<=355 1格
  88. guiShowBmp(x,y,"VBAT1.bmp");//3
  89. guiDrawVLine(h,h+5,x+16,y+1,guiGetBackColor());
  90. }
  91. else if(bat<375){//355<x<=375 2格
  92. guiShowBmp(x,y,"VBAT1.bmp");
  93. guiDrawVLine(h,h+5,x+12,y+1,guiGetBackColor());
  94. guiDrawVLine(h,h+5,x+16,y+1,guiGetBackColor());//5.12
  95. }
  96. else if(bat<400){//375<x<=400 3格
  97. guiShowBmp(x,y,"VBAT1.bmp");
  98. guiDrawVLine(h,h+5,x+8,y+1,guiGetBackColor());
  99. guiDrawVLine(h,h+5,x+12,y+1,guiGetBackColor());
  100. guiDrawVLine(h,h+5,x+16,y+1,guiGetBackColor());//5.12
  101. }
  102. else{//>=400 4格
  103. guiShowBmp(x,y,"VBAT1.bmp");
  104. guiDrawVLine(h,h+5,x+4,y+1,guiGetBackColor());
  105. guiDrawVLine(h,h+5,x+8,y+1,guiGetBackColor());
  106. guiDrawVLine(h,h+5,x+12,y+1,guiGetBackColor());
  107. guiDrawVLine(h,h+5,x+16,y+1,guiGetBackColor());//5.12
  108. }
  109. sutApp.lowPwrWarn=0;
  110. #else
  111. const unsigned short batTable[13]={320,328,336,344,352,360,368,376,384,392,400,405,410};
  112. short i;
  113. guiShowBinMap(114,1,"battery.bin");
  114. for(i=13;i>0;i--)
  115. {
  116. if(bat >= batTable[i-1]) NewDrawVLine(129-i,2,6);
  117. }
  118. LCDFlashPainPage(104,0);
  119. #endif
  120. }
  121. //显示时间
  122. static void ShowTime(char flash,unsigned int exeInterval){
  123. static unsigned short nextExe=0;
  124. static unsigned char flag=0;
  125. MY_CLOCK myclock;
  126. char buf[30];
  127. if(nextExe==0 || flash){
  128. if(flag){
  129. snprintf(buf, sizeof(buf), "%02d:%02d",myclock.hour, myclock. min);
  130. flag=0;
  131. }else{
  132. snprintf(buf, sizeof(buf), "%02d %02d",myclock.hour, myclock. min);
  133. flag=1;
  134. }
  135. newGuiShowStr((GLCD_WIDTH-40)/2,1, buf,REVERSED_NO,FONT_MODE_12X12);
  136. }
  137. if(++nextExe>=(1000/exeInterval)) nextExe=0;
  138. }
  139. //显示耳机接入状态
  140. static void ShowEarStatus(char flash){
  141. static unsigned char lastStatus=0;
  142. if(lastStatus==sutApp.earLev && flash==0) return;
  143. if(sutApp.earLev!=0) guiShowBmp(EAR_ICON_X, 1, "ear.bmp");
  144. else guiClearRect(EAR_ICON_X, 1, EAR_ICON_X+EAR_ICON_WX,1+12, COLOR_STATUS_BAR);
  145. lastStatus=sutApp.earLev;
  146. }
  147. //显示键盘锁状态
  148. static void ShowKeyLocStatus(char flash){
  149. static unsigned char lastStatus=0;
  150. if(lastStatus==sutApp.keyLock && flash==0) return;
  151. if(sutApp.keyLock!=0) guiShowBmp(LOCK_ICON_X, 1, "lock.bmp");
  152. else guiClearRect(LOCK_ICON_X, 1, LOCK_ICON_X+LOCK_ICON_WX,12, COLOR_STATUS_BAR);
  153. lastStatus=sutApp.keyLock;
  154. }
  155. //显示状态栏
  156. void uiShowStatusBar(char flash,unsigned int exeInterval){
  157. static unsigned char s_netshowvalue=0xff;
  158. static unsigned char lastPPPStatus;
  159. static int siCSQ;
  160. static int siVbat;
  161. static unsigned short batFirstShow=0;
  162. static char cardType=0;
  163. char tempFlash=flash;
  164. if(sutApp.enableKey==0) return;
  165. if(sutApp.updateStatusBar!=0){
  166. sutApp.updateStatusBar=0;
  167. tempFlash=1;
  168. newGuiClearBar();
  169. }
  170. //显示信号
  171. if(tempFlash || siCSQ!=sutApp.g_iCSQ || lastPPPStatus != sutApp.pocPpp){
  172. lastPPPStatus=sutApp.pocPpp;
  173. siCSQ=sutApp.g_iCSQ;
  174. ShowSingle(sutApp.g_iCSQ);
  175. }
  176. //显示卡选项
  177. // if(tempFlash || cardType != sutApp.simSel){
  178. // cardType=sutApp.simSel;
  179. // ShowCardType(cardType);
  180. // }
  181. //显示2G/3G/4G
  182. if(tempFlash || s_netshowvalue!=netshowvalue){
  183. s_netshowvalue=netshowvalue;
  184. Show_Net(s_netshowvalue);
  185. }
  186. //显示GPS是否正常及鉴权情况
  187. //gpsInfo.gpsLocated=1;
  188. //gpsInfo.bbAuth=1;
  189. //gpsInfo.gpsF=1;
  190. // gpsIconShow(tempFlash);
  191. //电量显示
  192. #if 0
  193. if(batFirstShow < (1000/exeInterval)) {//开机前1秒显示一半电量
  194. sutApp.g_iBAT=360;
  195. batFirstShow++;
  196. }else
  197. #endif
  198. if(tempFlash || siVbat!=sutApp.g_iBAT || sutApp.g_iBAT < WARN_PWR_LEVEL){
  199. if(sutApp.g_iBAT>=0){
  200. siVbat=sutApp.g_iBAT;
  201. ShowBatttery(sutApp.g_iBAT,exeInterval);
  202. }
  203. }
  204. //文本消息显示
  205. //sutSms.haveUnRead=1;
  206. //ShowMessageFlag(0);
  207. //GPS显示
  208. //时间显示
  209. ShowTime(tempFlash,exeInterval);
  210. //显示耳机状态
  211. // ShowEarStatus(tempFlash);
  212. //显示键盘锁状态
  213. // ShowKeyLocStatus(tempFlash);
  214. }
  215. /****************************状态栏显示部分结束***********************************/
  216. /****************************待机界面显示部分开始***********************************/
  217. typedef enum{
  218. ME_NO_LOGIN,
  219. ME_NOBODY_SPEAK,
  220. ME_IAM_SPEAK,
  221. ME_SOMEBODY_SPEAK
  222. }ME_ENUM;
  223. static void uiShowGUName(int update);
  224. static void uiShowGuaDuan(unsigned char danhu);
  225. static void uiShowGroup(const char* info);
  226. static void uiShowUser(const char* info);
  227. static void uiShowHuaQuan(const char* info);
  228. static void uiShowCallUserName(void);
  229. static void uiShowOffLineMessage(void);
  230. static void uiShowCopsInfo(void){
  231. char info[50];
  232. if(newPara.itemShowType==0){
  233. switch(sutApp.copstype){
  234. case 0:case 2:case 4:case 7://中国移动
  235. snprintf(info, sizeof(info), "中国移动");
  236. break;
  237. case 1:case 6:case 9://中移联通
  238. snprintf(info, sizeof(info), "中国联通");
  239. break;
  240. case 3:case 8:case 11://中国电信
  241. snprintf(info, sizeof(info), "中国电信");
  242. break;
  243. default:snprintf(info, sizeof(info), "公网集群对讲系统");break;
  244. }
  245. }else snprintf(info, sizeof(info), "公网集群对讲系统");
  246. guiFillRect(0, UI_STATUS_ITEM_Y, GLCD_WIDTH-1, UI_CONTENT_SHOW_Y-1, guiGetForeColor());//清除第二区
  247. guiShowCaption(0,info, UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  248. }
  249. #ifdef USE_LEFT_MOVING
  250. void movingShowNames(unsigned int dlyInterval,unsigned char reset, unsigned char now,unsigned char voice){
  251. const char *idleptr="空闲";
  252. const char *voiceptr="本机在讲话";
  253. const char *danhuptr="单呼模式";
  254. char *gname=danhuptr;
  255. char *voicePri=idleptr;
  256. char *uname=NULL;
  257. static unsigned int interval=0xffffff;
  258. if(sutPocStatus.logined==0) return;
  259. //if(sutPocStatus.statusChaned!=0){
  260. // sutPocStatus.statusChaned=0;
  261. // reset=1;
  262. //}
  263. if(++interval<500/dlyInterval && reset==0 && now==0) return;//0.5秒刷新一次
  264. interval=0;
  265. if(sutPocStatus.danHuStatus==0){
  266. if(sutPocStatus.LocalGroup.name[0]==0) gname=NULL;
  267. else gname=sutPocStatus.LocalGroup.name;
  268. }
  269. if(voice==0) voicePri=idleptr;
  270. else if(voice==1) voicePri=voiceptr;
  271. else voicePri=sutPocStatus.CallName;
  272. if(sutPocStatus.LocalUser.name[0]!=0) uname=sutPocStatus.LocalUser.name;
  273. mainScreenShowMoving(UI_GROUP_SHOW_Y, reset,gname,uname,voicePri);
  274. }
  275. #endif
  276. void uiShowMainInterface(char status,unsigned int exeInterval){
  277. short Flag=ME_NO_LOGIN;//ME_ENUM
  278. static unsigned char danhu=0;
  279. static short lastFlag=-1;
  280. static unsigned short siCt=0;
  281. char info[20];
  282. static char firstRun=0;
  283. static unsigned short dly=0;
  284. char tmpStatus=status;
  285. static int copsStatus;
  286. static unsigned int timer;
  287. static char lockStep=0;
  288. unsigned char reset=0;
  289. unsigned char moveFlash=0;
  290. static unsigned char voice=0;
  291. //提示解锁
  292. if(sutApp.lockShow!=0){
  293. if(lockStep==0){
  294. lockStep=1;
  295. backLightReset();
  296. uTimerStart(&timer, 1000);
  297. newGuiClearMainPage();
  298. newGuiShowStr(GLCD_WIDTH/2-32,STATUS_BAR_HEIGH, "键盘已锁",REVERSED_NO,FONT_MODE_16X16);
  299. newGuiShowStr(GLCD_WIDTH/2-32+8,STATUS_BAR_HEIGH+16,"请解锁",REVERSED_NO,FONT_MODE_16X16);
  300. }
  301. }else lockStep=0;
  302. if(lockStep==1){
  303. if(uTimerExpired(&timer)){
  304. newGuiClearMainPage();
  305. lastFlag=-1;//让以下刷新一下
  306. sutApp.lockShow=0;
  307. lockStep=0;
  308. sutUIstatus.ItemRefresh=1;//如果"请插卡"有显示,会被刷掉不再显示,这里让它重新显示出来
  309. }
  310. return;
  311. }
  312. #if 0
  313. /*延时一下1秒后才显示后面的,如果直接登录了,就跳出延时*/
  314. if(firstRun==0){
  315. if((++dly>=(1*1000/exeInterval)) || sutPocStatus.logined!=0){
  316. firstRun=1;
  317. tmpStatus=1;
  318. sutApp.enableKey=1;//延时按键操作完成
  319. }else return;
  320. }
  321. #endif
  322. /*逻辑处理开始*/
  323. if(tmpStatus){
  324. newGuiClearMainPage();
  325. danhu=sutPocStatus.danHuStatus;
  326. uiShowGuaDuan(danhu);
  327. lastFlag=-1;
  328. siCt=0;
  329. //return;
  330. }
  331. if(copsStatus != sutApp.copstype || tmpStatus){
  332. copsStatus=sutApp.copstype;
  333. //uiShowCopsInfo();
  334. }
  335. //更新单呼显示与否
  336. if(sutPocStatus.danHuStatus != danhu){
  337. danhu=sutPocStatus.danHuStatus;
  338. uiShowGuaDuan(danhu);
  339. }
  340. //以下持续调用,以便动态更新信息
  341. if(0==sutPocStatus.logined) Flag=ME_NO_LOGIN;//未登录
  342. else if(0==sutPocStatus.spk && 0==sutPocStatus.mic){//已登录,无人说话
  343. Flag=ME_NOBODY_SPEAK;
  344. }else if(0!=sutPocStatus.mic) Flag=ME_IAM_SPEAK;//已登录,本机说话
  345. else if(0!=sutPocStatus.spk) Flag=ME_SOMEBODY_SPEAK;//有人说话
  346. switch(Flag){
  347. case ME_NO_LOGIN://未登录
  348. if(Flag != lastFlag){
  349. newGuiClearMainPage();
  350. }
  351. break;
  352. case ME_NOBODY_SPEAK://已登录,无人说话
  353. if(Flag != lastFlag){
  354. if(ME_NO_LOGIN==lastFlag) newGuiClearPage(0, ROW_TWO);
  355. newGuiClearPage(0, ROW_FOUR);
  356. #ifdef USE_LEFT_MOVING
  357. voice=0;
  358. moveFlash=1;
  359. #else
  360. uiShowHuaQuan("空闲");
  361. #endif
  362. sutPocStatus.statusChaned = 1;
  363. }
  364. break;
  365. case ME_IAM_SPEAK://已登录,本机说话
  366. if(Flag != lastFlag){
  367. #ifdef USE_LEFT_MOVING
  368. voice=1;
  369. moveFlash=1;
  370. #else
  371. newGuiClearMainPage();
  372. uiShowHuaQuan("本机在讲话");
  373. #endif
  374. }
  375. break;
  376. case ME_SOMEBODY_SPEAK://已登录,有人说话
  377. if(Flag != lastFlag){
  378. newGuiClearPage(0, ROW_FOUR);
  379. sutPocStatus.statusChaned=1;//保证要刷新名字
  380. #ifdef USE_LEFT_MOVING
  381. voice=2;
  382. moveFlash=1;
  383. #endif
  384. }
  385. #ifndef USE_LEFT_MOVING
  386. uiShowCallUserName();
  387. #endif
  388. break;
  389. }
  390. if(Flag>0){//已登录
  391. if(Flag != lastFlag && (lastFlag==-1 || ME_NO_LOGIN==lastFlag)){
  392. #ifdef USE_LEFT_MOVING
  393. reset=1;
  394. #else
  395. uiShowGUName(1);
  396. #endif
  397. }
  398. #ifndef USE_LEFT_MOVING
  399. else uiShowGUName(0);
  400. #endif
  401. }else{//未登录
  402. snprintf(info, sizeof(info),"正在登陆.");
  403. switch(siCt){//not finished yet
  404. case 0:
  405. strcat(info, " ");
  406. newGuiShowStr(0, STATUS_BAR_HEIGH, info, REVERSED_NO, FONT_MODE_16X16);
  407. break;
  408. case (1000/APP_SUB_DIV_TIME):
  409. strcat(info, ". ");
  410. newGuiShowStr(0, STATUS_BAR_HEIGH, info, REVERSED_NO, FONT_MODE_16X16);
  411. break;
  412. case (2000/APP_SUB_DIV_TIME):
  413. strcat(info, "..");
  414. newGuiShowStr(0, STATUS_BAR_HEIGH, info, REVERSED_NO, FONT_MODE_16X16);
  415. break;
  416. }
  417. //显示登录状态
  418. uiShowOffLineMessage();
  419. }
  420. #ifdef USE_LEFT_MOVING
  421. movingShowNames(APP_SUB_DIV_TIME,reset,moveFlash,voice);
  422. #endif
  423. if(++siCt>=(3000/APP_SUB_DIV_TIME)) siCt=0;
  424. if(Flag != lastFlag) lastFlag=Flag;
  425. }
  426. static void uiShowGUName(int update){
  427. static char scNameUser[POC_GROUP_USER_NAME_LEN];
  428. static char scNameGroup[POC_GROUP_USER_NAME_LEN];
  429. char name[POC_GROUP_USER_NAME_LEN];
  430. unsigned short len;
  431. const unsigned char danHuanBuffer[9]={0xB5,0xA5,0xBA,0xF4,0xC4,0xA3,0xCA,0xBD,0};
  432. char GroupShowUpdate=0;
  433. char UserShowUpdate=0;
  434. if(sutPocStatus.danHuStatus==0){
  435. if(0!=strcmp(sutPocStatus.LocalGroup.name,scNameGroup) || update!=0){
  436. memset(scNameGroup,0,sizeof(scNameGroup));
  437. memcpy(scNameGroup,sutPocStatus.LocalGroup.name,sizeof(scNameGroup));
  438. GroupShowUpdate=1;
  439. }
  440. }else{
  441. if(0!=strcmp((char *)danHuanBuffer,scNameGroup) || update!=0){
  442. memset(scNameGroup,0,sizeof(scNameGroup));
  443. memcpy(scNameGroup, danHuanBuffer,sizeof(danHuanBuffer));
  444. GroupShowUpdate=1;
  445. }
  446. }
  447. if(0!=strcmp(sutPocStatus.LocalUser.name,scNameUser) || update!=0){
  448. memset(scNameUser,0,sizeof(scNameUser));
  449. memcpy(scNameUser,sutPocStatus.LocalUser.name,sizeof(scNameUser));
  450. UserShowUpdate=1;
  451. }
  452. if(GroupShowUpdate){
  453. guiClearRect(0,UI_GROUP_SHOW_Y,GLCD_WIDTH-1,UI_GROUP_SHOW_Y+16+2,guiGetBackColor());//18
  454. //刷新群组栏
  455. if(sutPocStatus.danHuStatus==0) StrIntercept(name, scNameGroup, sizeof(name));
  456. else snprintf(name, sizeof(name), "单呼模式");
  457. uiShowGroup(name);
  458. sutPocStatus.statusChaned=1;
  459. }
  460. if(UserShowUpdate){
  461. guiClearRect(0,UI_USER_SHOW_Y,GLCD_WIDTH-1,UI_GROUP_SHOW_Y+16,guiGetBackColor());//18
  462. //刷新成员栏
  463. StrIntercept(name, scNameUser, sizeof(name));
  464. uiShowUser(name);
  465. }
  466. }
  467. static void uiShowGuaDuan(unsigned char danhu){
  468. return;
  469. if(danhu==0) guiClearArea(GLCD_WIDTH-32, UI_BOTTOM_SHOW_Y, 32, 14, guiGetBackColor());
  470. else guiShowStr(GLCD_WIDTH-32, UI_BOTTOM_SHOW_Y, "挂断", FONT_MODE_12X12, REVERSED_NO, COLOR_STATUS_BAR,guiGetBackColor());
  471. }
  472. static void uiShowGroup(const char* info){
  473. guiClearRect(2, UI_GROUP_SHOW_Y-2, GLCD_WIDTH-1, UI_GROUP_SHOW_Y-2+17, guiGetBackColor());
  474. guiShowStr(2, UI_GROUP_SHOW_Y+2,"群组:", FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  475. #ifdef USE_12X12_FONT_ONLY
  476. guiShowStr(2+30, UI_GROUP_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  477. #else
  478. guiShowStr(2+30, UI_GROUP_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  479. #endif
  480. }
  481. static void uiShowUser(const char* info){
  482. guiClearRect(2, UI_USER_SHOW_Y-2, GLCD_WIDTH-1, UI_USER_SHOW_Y-2+17, guiGetBackColor());
  483. guiShowStr(2, UI_USER_SHOW_Y+2,"成员:", FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  484. #ifdef USE_12X12_FONT_ONLY
  485. guiShowStr(2+30, UI_USER_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  486. #else
  487. guiShowStr(2+30, UI_USER_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  488. #endif
  489. }
  490. void showGroup(void){
  491. uiShowGroup("默认群组");
  492. }
  493. void showUser(void){
  494. uiShowUser("小明");
  495. }
  496. static void uiShowHuaQuan(const char* info){
  497. guiClearRect(2, UI_VOICE_SHOW_Y-2, GLCD_WIDTH-1, UI_VOICE_SHOW_Y-2+17, guiGetBackColor());
  498. guiShowStr(2, UI_VOICE_SHOW_Y+2,"话权:", FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  499. #ifdef USE_12X12_FONT_ONLY
  500. guiShowStr(2+30, UI_VOICE_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  501. #else
  502. guiShowStr(2+30, UI_VOICE_SHOW_Y+2,info, FONT_MODE_12X12, REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  503. #endif
  504. }
  505. static void uiShowCallUserName(void){
  506. static char scName[POC_GROUP_USER_NAME_LEN];
  507. char name[POC_GROUP_USER_NAME_LEN];
  508. if(0 != strncmp(scName, sutPocStatus.CallName, POC_GROUP_USER_NAME_LEN) ||
  509. sutPocStatus.statusChaned){
  510. //当名字变更或UI切换了,刷新显示
  511. sutPocStatus.statusChaned=0;
  512. memcpy(scName, sutPocStatus.CallName, POC_GROUP_USER_NAME_LEN);
  513. uiShowHuaQuan(scName);
  514. }
  515. }
  516. static void uiShowOffLineMessage(void){
  517. static unsigned char laReason;
  518. char info[50],update=0;
  519. unsigned short y;
  520. if(sutUIstatus.Status != UIS_STANDBY) return;
  521. if(sutPocStatus.PocLineOffReason==laReason && sutUIstatus.ItemRefresh==0) return;
  522. sutUIstatus.ItemRefresh=0;
  523. laReason=sutPocStatus.PocLineOffReason;
  524. if(sutApp.cardStatus==0){
  525. snprintf(info, sizeof(info), "请插卡");
  526. update=1;
  527. }else{
  528. switch(sutPocStatus.PocLineOffReason){
  529. case 1:snprintf(info, sizeof(info), "无网络连接");break;
  530. case 2:snprintf(info, sizeof(info), "无法连接");break;
  531. case 3:snprintf(info, sizeof(info), "没有服务");break;
  532. case 4:snprintf(info, sizeof(info), "账号信息错误");break;
  533. }
  534. if(sutPocStatus.PocLineOffReason!=0) update=1;
  535. }
  536. if(update!=0){
  537. newGuiClearMainPage();
  538. newGuiShowStr(0, STATUS_BAR_HEIGH+16, info, REVERSED_NO, FONT_MODE_16X16);
  539. }
  540. }
  541. /****************************待机界面显示部分结束***********************************/
  542. /****************************主菜单显示部分开始*************************************/
  543. #include "Palace.h"
  544. void uiShowMenuMain(char update){
  545. static const char *apcMenuMain[]={
  546. "群组选择",
  547. "成员选择",
  548. "文本信息",
  549. "系统设置",
  550. "定位设置",
  551. "终端信息",
  552. ""
  553. };
  554. if(update) dotListBoxInit(apcMenuMain,"主菜单",-1,-1,0);
  555. }
  556. void MenuMainResponse(void){
  557. unsigned short handle;
  558. unsigned short key;
  559. key=dotListBoxResponse();
  560. if(MKEY_VALUE_MENU==key){
  561. handle=dotListGetHandle();
  562. switch(handle){
  563. case 0:
  564. uISetNextStatus(UIS_MENU_GROUP_SEL);
  565. break;
  566. case 1:
  567. uISetNextStatus(UIS_MENU_USER_SEL);
  568. break;
  569. case 2:
  570. uISetNextStatus(UIS_MENU_MAIL_SEL);
  571. break;
  572. case 3:
  573. uISetNextStatus(UIS_MENU_SYS_SEL);
  574. break;
  575. case 4:
  576. uISetNextStatus(UIS_MENU_LOCATION_SEL);
  577. break;
  578. case 5:
  579. uISetNextStatus(UIS_MENU_INFO_SEL);
  580. break;
  581. }
  582. uiPushStack(handle);
  583. }
  584. else if(MKEY_VALUE_ESC==key){
  585. uISetNextStatus(UIS_STANDBY);
  586. }
  587. }
  588. /****************************主菜单显示部分结束*************************************/
  589. /*****************************群组选择/成员选择部分开始*********************************/
  590. bool uiSwitchLock=false;
  591. bool isUiSwitchReady(void){return uiSwitchLock;}
  592. static char GUListBoxInited=0;
  593. static char SelMachine=0;
  594. static void ReFlashItemGU(char type);
  595. static void UserAssistAdd(void);
  596. void numGUFlash(int index, int total){
  597. char info[10];
  598. int x;
  599. snprintf(info, sizeof(info), "%d", total);
  600. x=GLCD_WIDTH-strlen(info)*12;
  601. guiClearRect(78, UI_STATUS_ITEM_Y, GLCD_WIDTH-1, UI_STATUS_ITEM_Y+12, guiGetForeColor());
  602. guiShowStr(x, UI_STATUS_ITEM_Y+1, info, FONT_MODE_12X12, REVERSED_NO, guiGetBackColor(), guiGetForeColor());
  603. }
  604. bool setHandleToZero=true;
  605. void uiShowGUSel(char StatusUpdate,unsigned int exeInterval,char type){
  606. static char machine;
  607. static unsigned int timer;
  608. unsigned short timeout;
  609. char temp;
  610. if(StatusUpdate) machine=0;
  611. switch(machine){
  612. case 0:
  613. newGuiClearMainPage();
  614. if(sutPocStatus.logined == 0){//not login
  615. newGuiShowMessageBox("请先登录", ROW_TWO);
  616. uTimerStart(&timer, 1000);
  617. machine=1;
  618. }else{
  619. newGuiShowMessageBox("请等候", ROW_TWO);
  620. uiSwitchLock=true;
  621. if(type==0) appSleepCtl(ASLEEP_GGROUP, 1);//要获取群组信息,不让休眠,记得超时或获取成功或获取失败后需要释放
  622. else appSleepCtl(ASLEEP_GUSER, 1);
  623. UiassistStart(0);
  624. machine=2;
  625. setHandleToZero=true;
  626. }
  627. break;
  628. case 1:
  629. if(uTimerExpired(&timer)){
  630. uISetNextStatus(UIS_STANDBY);
  631. }
  632. break;
  633. case 2:
  634. temp=getAssistResult();
  635. if(temp){//??è?íê3é
  636. ReFlashItemGU(type);
  637. machine=3;
  638. //获取成功后退出释放休眠
  639. if(type==0) appSleepCtl(ASLEEP_GGROUP, 0);
  640. else appSleepCtl(ASLEEP_GUSER, 0);
  641. uiSwitchLock=false;
  642. }
  643. break;
  644. }
  645. if(machine != 3) return;
  646. UserAssistAdd();
  647. dotLeftMoveSelectedItem();
  648. }
  649. void GroupSelResponse(){
  650. unsigned int key;
  651. char buf[50];
  652. int i;
  653. key=getKeyValue();
  654. switch(SelMachine){
  655. case 0:
  656. if(dotListGetHandle()==0 && MKEY_VALUE_UP==key){
  657. UiassistStart(1);
  658. SelMachine=1;
  659. }else if(((dotListGetHandle()+1) == dotListGetItemNum()) && (MKEY_VALUE_DOWN==key)){
  660. setHandleToZero=true;
  661. UiassistStart(2);
  662. SelMachine=2;
  663. }
  664. key=dotListBoxResponse();
  665. if(MKEY_VALUE_ESC==key){
  666. uiAssist.status=0;
  667. if(getStackStruct()->FastUiChange)uISetNextStatus(UIS_STANDBY);
  668. else uISetNextStatus(UIS_MENU_MAIN);
  669. appSleepCtl(ASLEEP_GGROUP, 0);//按键退出后释放休眠
  670. GUListBoxInited=0;
  671. uiSwitchLock=false;
  672. }else if(MKEY_VALUE_MENU==key){
  673. if(0 == sutPocStatus.ListCurOnlineNum) break;
  674. ///////////////////////////////////////
  675. UiassistEnd(0);
  676. sutApp.groupTTSEnable=1;
  677. snprintf(buf, sizeof(buf),"AT+POC=090000%08x\r\n",sutPocStatus.AllGroups[dotListGetHandle()].ID);
  678. msgAtSend(buf);
  679. MSG_INFO(1,buf);
  680. snprintf(buf, sizeof(buf),"进入:%s",sutPocStatus.AllGroups[dotListGetHandle()].name);
  681. MSG_INFO(1,buf);
  682. uISetNextStatus(UIS_STANDBY);
  683. SelMachine=0;
  684. }
  685. break;
  686. }
  687. }
  688. void UserSelResponse(){
  689. char buf[50];
  690. unsigned int key;
  691. key=getKeyValue();
  692. switch(SelMachine){
  693. case 0:
  694. if(GUListBoxInited==0) break;//还未初始化listbox时,不执行按键响应
  695. if(dotListGetHandle()==0 && MKEY_VALUE_UP==key){
  696. UiassistStart(1);
  697. SelMachine=1;
  698. }else if((dotListGetHandle()+1) == dotListGetItemNum() && (MKEY_VALUE_DOWN==key)){
  699. setHandleToZero=true;
  700. UiassistStart(2);
  701. SelMachine=2;
  702. }
  703. key=dotListBoxResponse();
  704. if(MKEY_VALUE_ESC==key){
  705. uiAssist.status=0;
  706. if(getStackStruct()->FastUiChange)uISetNextStatus(UIS_STANDBY);
  707. else uISetNextStatus(UIS_MENU_MAIN);
  708. appSleepCtl(ASLEEP_GUSER, 0);//按键退出后释放休眠
  709. GUListBoxInited=0;
  710. uiSwitchLock=false;
  711. }else if(MKEY_VALUE_MENU==key){
  712. if(0 == sutPocStatus.ListCurOnlineNum) break;
  713. UiassistEnd(0);
  714. snprintf(buf, sizeof(buf),"AT+POC=0A0000%08x\r\n",sutPocStatus.AllUsers[dotListGetHandle()].ID);
  715. msgAtSend(buf);
  716. MSG_INFO(1, buf);
  717. snprintf(buf, sizeof(buf),"呼叫:%s",sutPocStatus.AllUsers[dotListGetHandle()].name);
  718. MSG_INFO(1, buf);
  719. uISetNextStatus(UIS_STANDBY);
  720. SelMachine=0;
  721. }
  722. break;
  723. }
  724. }
  725. static void UserAssistAdd(void){
  726. switch(SelMachine){
  727. case 1:
  728. if(getAssistResult()){
  729. if(sutUIstatus.Status==UIS_MENU_GROUP_SEL)ReFlashItemGU(0);
  730. else ReFlashItemGU(1);
  731. SelMachine=0;
  732. }
  733. break;
  734. case 2:
  735. if(getAssistResult()){
  736. if(sutUIstatus.Status==UIS_MENU_GROUP_SEL)ReFlashItemGU(0);
  737. else ReFlashItemGU(1);
  738. SelMachine=0;
  739. }
  740. break;
  741. }
  742. }
  743. static void ReFlashItemGU(char type){
  744. int i;
  745. static char *GUName[POC_ALL_GROUPS_NUM+1];
  746. static const char *NullGU="";
  747. unsigned int showHandle;
  748. for(i=0;i<=POC_ALL_GROUPS_NUM;i++) GUName[i]=NullGU;
  749. for(i=0;i<sutPocStatus.ListFillIndex;i++){
  750. if(type==0){
  751. GUName[i]=sutPocStatus.AllGroups[i].name;
  752. }else{
  753. GUName[i]=sutPocStatus.AllUsers[i].name;
  754. }
  755. }
  756. if(sutPocStatus.ListCurOnlineNum==0 || sutPocStatus.ListDetailValid==0){//没有成员总数或没有获取到明细
  757. GUName[0]="空";
  758. }
  759. if(setHandleToZero==true){
  760. showHandle=0;
  761. setHandleToZero=false;
  762. }else{
  763. if(sutPocStatus.ListFillIndex) showHandle=sutPocStatus.ListFillIndex-1;
  764. else showHandle=0;
  765. }
  766. if(type==0) dotListBoxInit(GUName,"群组列表",sutPocStatus.ListCurOnlineNum,showHandle,sutPocStatus.handleIndex);
  767. else dotListBoxInit(GUName,"成员列表",sutPocStatus.ListCurOnlineNum,showHandle,sutPocStatus.handleIndex);
  768. GUListBoxInited=1;
  769. }
  770. /*****************************群组选择/成员选择部分结束*********************************/
  771. /*****************************系统设置部分开始*********************************/
  772. void uiShowMenuSysSetup(char flash){
  773. static const char *apcPtr[]={
  774. "LCD设置",
  775. "功耗模式设置",
  776. "提示音设置",
  777. "键锁设置",
  778. "工程设置",
  779. ""
  780. };
  781. if(flash){
  782. msgAtSend("AT+RSIM\r\n");//进此菜单前查询一下卡用于后面显示
  783. dotListBoxInit(apcPtr,"系统设置",-1,-1,0);
  784. }
  785. }
  786. void sysTemSetResponse(void){
  787. unsigned short key;
  788. unsigned short handle;
  789. key=dotListBoxResponse();
  790. if(MKEY_VALUE_MENU==key){
  791. handle=dotListGetHandle();
  792. switch(handle){
  793. case 0://LCD设置
  794. uISetNextStatus(UIS_MENU_SYS_LCD);
  795. break;
  796. case 1://功耗模式设置
  797. uISetNextStatus(UIS_MENU_SYS_PWR);
  798. break;
  799. case 2://提示音设置
  800. uISetNextStatus(UIS_MENU_SYS_NOTE);
  801. break;
  802. case 3://键锁设置
  803. uISetNextStatus(UIS_MENU_SYS_LOCK);
  804. break;
  805. case 4://工程设置
  806. uISetNextStatus(UIS_MENU_SYS_FACTORY);
  807. break;
  808. }
  809. if(handle<=4) uiPushStack(handle);
  810. }else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_MAIN);
  811. }
  812. /*****************************系统设置部分结束*********************************/
  813. /*****************************定位设置部分开始*********************************/
  814. static locationTimeFlash(char type);
  815. static locationXYFlash(char flash);
  816. void uiShowMenuLocationSel(char flash){
  817. static unsigned int timer;
  818. static char machine=0;
  819. if(flash){
  820. machine=0;
  821. newGuiClearMainPage();
  822. newGuiShowStr(0, 16, "定位设置",REVERSED_NO,FONT_MODE_16X16);
  823. if(newPara.gpsEnable==0){
  824. machine=1;
  825. newGuiShowMessageBox("版本不支持", ROW_THREE);
  826. uTimerStart(&timer, 1000);
  827. return;
  828. }
  829. locationTimeFlash(0);
  830. }
  831. if(newPara.gpsEnable!=0) locationXYFlash(flash);
  832. if(machine==1){
  833. if(uTimerExpired(&timer)){
  834. machine=0;
  835. uISetNextStatus(UIS_MENU_MAIN);
  836. }
  837. }
  838. }
  839. void loationSetResponse(void){
  840. unsigned short key;
  841. key=getKeyValue();
  842. if(newPara.gpsEnable==0){
  843. if(key!=MKEY_VALUE_ESC) return;
  844. }
  845. if(MKEY_VALUE_UP==key) locationTimeFlash(1);
  846. else if(MKEY_VALUE_DOWN==key) locationTimeFlash(2);
  847. else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_MAIN);
  848. else if(MKEY_VALUE_MENU==key){
  849. if(uiTmpVal != newPara.gpsTimeIndex){
  850. MSG_INFO(1, "GPS timeIndex update:%d",getGPSTimeValue(uiTmpVal));
  851. newPara.gpsTimeIndex=uiTmpVal;
  852. sysIniSave();
  853. gpsCheckInfo();//检测一下
  854. }
  855. uISetNextStatus(UIS_MENU_MAIN);
  856. }
  857. }
  858. static locationTimeFlash(char type){
  859. unsigned short gpsTimeValue;
  860. char buf[50];
  861. unsigned short y=70;
  862. if(type==0){
  863. uiTmpVal=newPara.gpsTimeIndex;
  864. }else if(type==1){
  865. if(++uiTmpVal>=GPS_TABLE_NUM) uiTmpVal=0;
  866. }else if(type==2){
  867. if(uiTmpVal>0) uiTmpVal--;
  868. else uiTmpVal=GPS_TABLE_NUM-1;
  869. }else return;
  870. gpsTimeValue=getGPSTimeValue(uiTmpVal);
  871. if(gpsTimeValue==0) snprintf(buf, sizeof(buf), "关闭");
  872. else snprintf(buf, sizeof(buf), "间隔:%d秒",gpsTimeValue);
  873. newGuiClearPage(0, ROW_THREE);
  874. newGuiShowStr(0, 32, buf,REVERSED_NO,FONT_MODE_16X16);
  875. }
  876. static locationXYFlash(char flash){
  877. char buf[50];
  878. unsigned short y=UI_CONTENT_SHOW_Y+2;
  879. if(gpsInfo.update==0 && flash==0) return;
  880. gpsInfo.update=0;
  881. guiClearRect(0, y,GLCD_WIDTH-1, y+12+5+12,guiGetBackColor());
  882. snprintf(buf, sizeof(buf), "纬度 S:%d.%05d",gpsInfo.Lat/1000000,gpsInfo.Lat%1000000);
  883. guiShowStr(30,y, buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  884. y+=12+5;
  885. snprintf(buf, sizeof(buf), "经度 W:%d.%05d",gpsInfo.Long/1000000,gpsInfo.Long%1000000);
  886. guiShowStr(30,y, buf,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  887. }
  888. /*****************************定位设置部分结束*********************************/
  889. /*******************************终端信息开始**********************************/
  890. unsigned char sysInfoType;
  891. static void sysInfoFlash(void){
  892. int len;
  893. char info[60];
  894. unsigned char i=STATUS_BAR_HEIGH;
  895. newGuiClearMainPage();
  896. if(sysInfoType==0){
  897. snprintf(info, sizeof(info), "PSN:%s", sutApp.UserInfo.psn);
  898. newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16);
  899. i+= 16;
  900. snprintf(info, sizeof(info), "AVER:%s", OHPOC_VERSION);
  901. newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16);
  902. i+= 16;
  903. snprintf(info, sizeof(info), "IVER:%d", CUSTOMER_CODE);
  904. newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16);
  905. }else if(sysInfoType==1){
  906. snprintf(info, sizeof(info), "PLAT:%s", OHPOC_POC_PLATFORM);
  907. newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16);
  908. i+= 16;
  909. snprintf(info, sizeof(info), "VPOC:%s",sutApp.pocVersion);
  910. newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16);
  911. }else if(sysInfoType==2){
  912. snprintf(info, sizeof(info), "VMOD:%s", sutApp.modemVer);
  913. len=strlen(info);
  914. if(len>16){
  915. i+= 16;
  916. newGuiShowStr(0, i, info+16,REVERSED_NO,FONT_MODE_16X16);
  917. i-= 16;
  918. info[16]=0;
  919. }
  920. newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16);
  921. }else if(sysInfoType==3){
  922. snprintf(info, sizeof(info), "IMEI:%s", ohpocGetIMEI());
  923. len=strlen(info);
  924. if(len>16){
  925. i+= 16;
  926. newGuiShowStr(0, i, info+16,REVERSED_NO,FONT_MODE_16X16);
  927. i-= 16;
  928. info[16]=0;
  929. }
  930. newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16);
  931. }else if(sysInfoType==4){
  932. snprintf(info, sizeof(info), "P%s",showPIP);
  933. newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16);
  934. i+= 16;
  935. snprintf(info, sizeof(info), "G%s",showGIP);
  936. newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16);
  937. i+= 16;
  938. snprintf(info, sizeof(info), "%d",newPara.gpsPort);
  939. newGuiShowStr(0, i, info,REVERSED_NO,FONT_MODE_16X16);
  940. }
  941. }
  942. void uiShowInformation(char update){
  943. if(update){
  944. sysInfoType=0;
  945. sysInfoFlash();
  946. }
  947. }
  948. void uiShowInformationResponse(void){
  949. unsigned short key=getKeyValue();
  950. if(MKEY_VALUE_ESC==key) uISetNextStatus(sutUIstatus.LastStatus);
  951. else if(MKEY_VALUE_DOWN==key){
  952. if(++sysInfoType>3) sysInfoType=0;
  953. sysInfoFlash();
  954. }else if(MKEY_VALUE_UP==key){
  955. if(sysInfoType==0) sysInfoType=3;
  956. else sysInfoType--;
  957. sysInfoFlash();
  958. }else if(MKEY_VALUE_CB_IP==key){
  959. sysInfoType=4;
  960. sysInfoFlash();
  961. }
  962. }
  963. /*****************************终端信息结束**********************************/
  964. static const char *commonIcon2[]={
  965. "APN.bmp",
  966. "APN1.bmp",
  967. ""
  968. };
  969. /*****************************LCD设置开始**********************************/
  970. static void lcdTimeFlash(char type){
  971. char buf[50];
  972. unsigned short x=4,y=56,value;
  973. if(type==1){
  974. if(++uiTmpVal>=5) uiTmpVal=0;
  975. }else if(type==2){
  976. if(uiTmpVal>0) uiTmpVal--;
  977. else uiTmpVal=4;
  978. }else if(type!=0) return;
  979. value=newPara.lcdParaList[uiTmpVal];
  980. if(value==0) snprintf(buf, sizeof(buf), "常亮");
  981. else snprintf(buf, sizeof(buf), "%3d 秒", value);
  982. newGuiClearPage(0, ROW_FOUR);
  983. newGuiShowStr(0, 48, buf,REVERSED_NO,FONT_MODE_16X16);
  984. if(uiTmpVal==newPara.lcdParaDefaultIndex) guiShowBinMap(GLCD_WIDTH-15,48,"APN1.bin");
  985. }
  986. void uiShowLcdSel(char StatusUpdate){
  987. if(StatusUpdate){
  988. newGuiClearMainPage();
  989. newGuiShowStr(0, 16, "LCD设置",REVERSED_NO,FONT_MODE_16X16);
  990. newGuiShowStr(0, 32, "背光时长",REVERSED_NO,FONT_MODE_16X16);
  991. uiTmpVal=newPara.lcdParaDefaultIndex;
  992. lcdTimeFlash(0);
  993. }
  994. }
  995. void uiShowLcdSelResponse(void){
  996. unsigned short key=getKeyValue();
  997. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  998. else if(MKEY_VALUE_DOWN==key)lcdTimeFlash(1);
  999. else if(MKEY_VALUE_UP==key) lcdTimeFlash(2);
  1000. else if(MKEY_VALUE_MENU==key){
  1001. getStackStruct()->ok_back=1;
  1002. if(uiTmpVal != newPara.lcdParaDefaultIndex){
  1003. newPara.lcdParaDefaultIndex=uiTmpVal;
  1004. MSG_INFO(1, "LCD TimeUpdate");
  1005. backLightReset();
  1006. sysIniSave();
  1007. }
  1008. uISetNextStatus(UIS_MENU_SYS_SEL);
  1009. }
  1010. }
  1011. /*****************************LCD设置结束**********************************/
  1012. /*****************************网络设置开始**********************************/
  1013. const unsigned char netModeSetTable[3]={1,2,4};//设置制式:AUTH,2G,4G
  1014. /*输入制式源始值,返回索引值对应值*/
  1015. unsigned char getNetModeIndex(unsigned char netModeValue){
  1016. unsigned char i;
  1017. for(i=0;i<sizeof(netModeSetTable);i++){
  1018. if(netModeValue==netModeSetTable[i]) return i;
  1019. }
  1020. return 0xff;//无对应值
  1021. }
  1022. /*输入制式索引值,返回制式源始值*/
  1023. unsigned char getNetModeValue(unsigned char netModeIndex){
  1024. if(netModeIndex>=sizeof(netModeSetTable)) return 0xff;
  1025. else return netModeSetTable[netModeIndex];
  1026. }
  1027. /*输入制式索引值,发送对应该命令给模块*/
  1028. void netModeSetCmd(unsigned char netMode){
  1029. char buf[30];
  1030. snprintf(buf, sizeof(buf), "AT+CTEC=%d,%d\r\n",ctecCurrentSet, netMode);
  1031. msgAtSend(buf);
  1032. }
  1033. #define NET_MODE_NUM 3
  1034. void uiShowNetSel(char StatusUpdate){
  1035. static const char *netMode[NET_MODE_NUM+1]={
  1036. "AUTO",
  1037. "2G",
  1038. "4G",
  1039. ""
  1040. };
  1041. char Features[NET_MODE_NUM];
  1042. unsigned char i;
  1043. if(StatusUpdate){
  1044. guiClearAll(guiGetBackColor());
  1045. guiShowCaption(0,"网络设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1046. uiMenuShowBottomLine();
  1047. for(i=0;i<NET_MODE_NUM;i++){
  1048. if(i==newPara.netMode) Features[i]=1;
  1049. else Features[i]=0;
  1050. }
  1051. ListBoxInit(&sutListBox,netMode,0,commonIcon2,Features,0);
  1052. uiMenuShowBottomIndacitor("保存", "返回");
  1053. }
  1054. }
  1055. void uiShowNetSelResponse(void){
  1056. unsigned short key=ListBoxResponse(&sutListBox);
  1057. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1058. else if(MKEY_VALUE_MENU==key){
  1059. getStackStruct()->ok_back=1;
  1060. if(sutListBox.handle*2 != newPara.netMode){
  1061. newPara.netMode=sutListBox.handle*2;
  1062. MSG_INFO(1, "netMode update:%d", newPara.netMode);
  1063. sysIniSave();
  1064. netModeSetCmd(newPara.netMode);
  1065. }
  1066. uISetNextStatus(UIS_MENU_SYS_SEL);
  1067. }
  1068. }
  1069. /*****************************网络设置结束**********************************/
  1070. /*****************************卡选择设置开始**********************************/
  1071. #define SIM_MODE_NUM 2
  1072. void uiShowSimSel(char StatusUpdate){
  1073. static const char *simMode[SIM_MODE_NUM+1]={
  1074. "卡1",
  1075. "卡2",
  1076. ""
  1077. };
  1078. char Features[SIM_MODE_NUM];
  1079. unsigned char i;
  1080. if(StatusUpdate){
  1081. guiClearAll(guiGetBackColor());
  1082. guiShowCaption(0,"SIM设置",UI_STATUS_ITEM_Y+1,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1083. uiMenuShowBottomLine();
  1084. for(i=0;i<SIM_MODE_NUM;i++){
  1085. if(i==sutApp.simSel) Features[i]=1;
  1086. else Features[i]=0;
  1087. }
  1088. ListBoxInit(&sutListBox,simMode,0,commonIcon2,Features,0);
  1089. uiMenuShowBottomIndacitor("保存", "返回");
  1090. }
  1091. }
  1092. void uiShowSimSelResponse(void){
  1093. char buf[30];
  1094. unsigned short key=ListBoxResponse(&sutListBox);
  1095. if(MKEY_VALUE_ESC==key){
  1096. if(getStackStruct()->FastUiChange)uISetNextStatus(UIS_STANDBY);
  1097. else uISetNextStatus(UIS_MENU_SYS_SEL);
  1098. }else if(MKEY_VALUE_MENU==key){
  1099. getStackStruct()->ok_back=1;
  1100. if(sutListBox.handle != sutApp.simSel){
  1101. snprintf(buf, sizeof(buf), "AT+SIMCROSS=%d\r\n",sutListBox.handle);
  1102. msgAtSend(buf);
  1103. guiShowMessageBox("请重启设备");
  1104. msgAtSend("AT+TRB\r\n");
  1105. LSAPI_OSI_ThreadSleep(100);
  1106. CTL_POWER_HOLD(false);
  1107. for(;;){
  1108. MSG_INFO(1, "card changed, wait user reboot");
  1109. CTL_POWER_HOLD(false);
  1110. LSAPI_OSI_ThreadSleep(1000);
  1111. }
  1112. }
  1113. uISetNextStatus(UIS_MENU_SYS_SEL);
  1114. }
  1115. }
  1116. /*****************************卡选择设置结束**********************************/
  1117. /*****************************功耗设置开始**********************************/
  1118. typedef enum{
  1119. PMODE_DEFAULT_LOW,
  1120. PMODE_SUPER_LOW,
  1121. PMODE_NORMAL
  1122. }PWR_ENUMDEF;
  1123. //低功耗模式
  1124. #define MODE_LOW_PWR_NONE_4G 5
  1125. #define MODE_LOW_PWR_IS_4G 25
  1126. //超长待机模式
  1127. #define MODE_LONG_LOW_PWR_NONE_4G 5
  1128. #define MODE_LONG_LOW_PWR_IS_4G 55
  1129. //常规模式
  1130. #define MODE_NORMAL__NONE_4G 5
  1131. #define MODE_NORMAL__IS_4G 5
  1132. //终端放弃设置模式,由服务器决定使用什么
  1133. #define MODE_AUTO____NONE_4G 0
  1134. #define MODE_AUTO____IS_4G 0
  1135. //默认功耗模式
  1136. #define MODE_PWR_DEFAULT_NONE_4G MODE_LOW_PWR_NONE_4G
  1137. #define MODE_PWR_DEFAULT_IS_4G MODE_LOW_PWR_IS_4G
  1138. static void pwrModeSetCmd(unsigned char pwrMode){
  1139. unsigned char seg1,seg2;
  1140. char buf[30];
  1141. if(pwrMode==PMODE_DEFAULT_LOW){
  1142. seg1=MODE_PWR_DEFAULT_NONE_4G;
  1143. seg2=MODE_PWR_DEFAULT_IS_4G;
  1144. }else if(pwrMode==PMODE_SUPER_LOW){
  1145. seg1=MODE_LONG_LOW_PWR_NONE_4G;
  1146. seg2=MODE_LONG_LOW_PWR_IS_4G;
  1147. }else if(pwrMode==PMODE_NORMAL){
  1148. seg1=MODE_NORMAL__NONE_4G;
  1149. seg2=MODE_NORMAL__IS_4G;
  1150. }else return;
  1151. snprintf(buf, sizeof(buf), "AT+UDP=%d,%d\r\n",seg1,seg2);
  1152. msgAtSend(buf);
  1153. }
  1154. void pwrModeAckHandler(unsigned char seg1, unsigned char seg2){
  1155. if(seg1==MODE_PWR_DEFAULT_NONE_4G && seg2==MODE_PWR_DEFAULT_IS_4G && newPara.pwrMode != PMODE_DEFAULT_LOW){
  1156. goto SAVE_PWR_MODE;
  1157. }else if(seg1==MODE_LONG_LOW_PWR_NONE_4G && seg2==MODE_LONG_LOW_PWR_IS_4G && newPara.pwrMode != PMODE_SUPER_LOW){
  1158. goto SAVE_PWR_MODE;
  1159. }else if(seg1==MODE_NORMAL__NONE_4G && seg2==MODE_NORMAL__IS_4G && newPara.pwrMode != PMODE_NORMAL){
  1160. goto SAVE_PWR_MODE;
  1161. }else if(seg2!=MODE_LOW_PWR_IS_4G&&seg2!=MODE_LONG_LOW_PWR_IS_4G&& seg2!=MODE_NORMAL__IS_4G){
  1162. //Seg2 3个模式都不满足则切换为默认模式
  1163. newPara.pwrMode = PMODE_DEFAULT_LOW;
  1164. goto SAVE_PWR_MODE;
  1165. }
  1166. return;
  1167. SAVE_PWR_MODE:
  1168. sysIniSave();
  1169. pwrModeSetCmd(newPara.pwrMode);
  1170. }
  1171. #define PWR_MODE_NUM 3
  1172. void pwrModeFlash(char type,unsigned char defaultVal){
  1173. if(type==1){
  1174. if(++uiTmpVal>=3) uiTmpVal=0;
  1175. }else if(type==2){
  1176. if(uiTmpVal==0) uiTmpVal=2;
  1177. else uiTmpVal--;
  1178. }else if(type != 0)return;
  1179. newGuiClearPage(0, ROW_FOUR);
  1180. switch(uiTmpVal){
  1181. case 0:newGuiShowStr(0, 48, "低功耗模式",REVERSED_NO,FONT_MODE_16X16);
  1182. break;
  1183. case 1:newGuiShowStr(0, 48, "超长待机模式",REVERSED_NO,FONT_MODE_16X16);
  1184. break;
  1185. case 2:newGuiShowStr(0, 48, "常规模式",REVERSED_NO,FONT_MODE_16X16);
  1186. break;
  1187. }
  1188. if(uiTmpVal==defaultVal) guiShowBinMap(GLCD_WIDTH-15,48,"APN1.bin");
  1189. }
  1190. void uiShowPwrSel(char StatusUpdate){
  1191. if(StatusUpdate){
  1192. newGuiClearMainPage();
  1193. newGuiShowStr(0, 16, "功耗设置",REVERSED_NO,FONT_MODE_16X16);
  1194. newGuiShowStr(0, 32, "类别:",REVERSED_NO,FONT_MODE_16X16);
  1195. uiTmpVal=newPara.pwrMode;
  1196. pwrModeFlash(0,newPara.pwrMode);
  1197. }
  1198. }
  1199. void uiShowPwrSelResponse(void){
  1200. unsigned short key=getKeyValue();
  1201. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1202. else if(MKEY_VALUE_MENU==key){
  1203. getStackStruct()->ok_back=1;
  1204. if(uiTmpVal != newPara.pwrMode){
  1205. newPara.pwrMode=uiTmpVal;
  1206. MSG_INFO(1, "pwrMode update:%d", newPara.pwrMode);
  1207. sysIniSave();
  1208. pwrModeSetCmd(newPara.pwrMode);
  1209. }
  1210. uISetNextStatus(UIS_MENU_SYS_SEL);
  1211. }else if(MKEY_VALUE_DOWN==key) pwrModeFlash(1,newPara.pwrMode);
  1212. }
  1213. /*****************************功耗设置结束**********************************/
  1214. /*****************************服务器设置输入密码开始**********************************/
  1215. unsigned char keybuf[6];
  1216. unsigned char keyflash=0;
  1217. void KeyNumFlash(void){
  1218. static char status=0;
  1219. char info[6];
  1220. static unsigned int timer;
  1221. if(++timer<(500/APP_SUB_DIV_TIME) && keyflash==0) return;
  1222. timer=0;
  1223. if(status==0) status=1;
  1224. else status=0;
  1225. if(keyflash==1) status=0;
  1226. else if(keyflash==2) status=1;
  1227. keyflash=0;
  1228. sprintf(info, "%c%c%c%c%c%c",keybuf[0],keybuf[1],keybuf[2],keybuf[3],keybuf[4],keybuf[5]);
  1229. if(status) info[uiTmpVal]='*';
  1230. newGuiShowStr(0, 48, info,REVERSED_NO,FONT_MODE_16X16);
  1231. }
  1232. void uiShowServerPassSel(char StatusUpdate){
  1233. if(StatusUpdate){
  1234. newGuiClearMainPage();
  1235. newGuiShowStr(0, 16, "密码验证",REVERSED_NO,FONT_MODE_16X16);
  1236. newGuiShowStr(0, 32, "P2移动",REVERSED_NO,FONT_MODE_16X16);
  1237. memset(keybuf, '0', sizeof(keybuf));
  1238. uiTmpVal=0;
  1239. }
  1240. KeyNumFlash();
  1241. }
  1242. void uiShowServerSelPassResponse(void){
  1243. unsigned short key=getKeyValue();
  1244. if(MKEY_VALUE_F1==key){
  1245. if(++keybuf[uiTmpVal]>'9') keybuf[uiTmpVal]='0';
  1246. keyflash=1;
  1247. }else if(MKEY_VALUE_F2==key){
  1248. if(++uiTmpVal>=sizeof(keybuf)) uiTmpVal=0;
  1249. keyflash=2;
  1250. }else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY);
  1251. else if(MKEY_VALUE_MENU==key){
  1252. if(memcmp(keybuf, getMenuKey(), 6)==0) uISetNextStatus(UIS_MENU_SYS_SERVER);
  1253. else{
  1254. newGuiShowStr(0, 48, "密码错误!!!",REVERSED_NO,FONT_MODE_16X16);
  1255. LSAPI_OSI_ThreadSleep(1000);
  1256. getStackStruct()->ok_back=1;
  1257. uISetNextStatus(UIS_MENU_SYS_FACTORY);
  1258. }
  1259. }
  1260. }
  1261. /*****************************服务器设置输入密码结束**********************************/
  1262. /*****************************服务器设置开始**********************************/
  1263. void serverFlash(unsigned char defaultVal){
  1264. newGuiClearPage(0, ROW_FOUR);
  1265. switch(uiTmpVal){
  1266. case 0:newGuiShowStr(0, 48, "杭州服务器",REVERSED_NO,FONT_MODE_16X16);break;
  1267. case 1:newGuiShowStr(0, 48, "山东服务器",REVERSED_NO,FONT_MODE_16X16);break;
  1268. case 2:newGuiShowStr(0, 48, "IP分发服务器",REVERSED_NO,FONT_MODE_16X16);break;
  1269. case 3:newGuiShowStr(0, 48, "集群服务器",REVERSED_NO,FONT_MODE_16X16);break;
  1270. case 4:newGuiShowStr(0, 48, "自定义服务器",REVERSED_NO,FONT_MODE_16X16);break;
  1271. }
  1272. if(uiTmpVal==defaultVal) guiShowBinMap(GLCD_WIDTH-15,48,"APN1.bin");
  1273. }
  1274. void uiShowServerSel(char StatusUpdate){
  1275. if(StatusUpdate){
  1276. newGuiClearMainPage();
  1277. newGuiShowStr(0, 16, "服务器列表",REVERSED_NO,FONT_MODE_16X16);
  1278. newGuiShowStr(0, 32, "类别",REVERSED_NO,FONT_MODE_16X16);
  1279. uiTmpVal=newPara.serList.defaultuse;
  1280. serverFlash(newPara.serList.defaultuse);
  1281. }
  1282. }
  1283. void uiShowServerSelResponse(void){
  1284. // unsigned char tempSer;
  1285. // char buf[50],buf1[100];
  1286. // unsigned short key=ListBoxResponse(&sutListBox);
  1287. //
  1288. // if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1289. // else if(MKEY_VALUE_MENU==key){
  1290. // tempSer=uiTmpVal;
  1291. // if(tempSer != newPara.serList.defaultuse){
  1292. // newPara.serList.defaultuse=tempSer;
  1293. // sysIniSave();
  1294. // getGIPAddr();
  1295. // snprintf(buf, sizeof(buf), "ip=%s;domain=%s;",getPIPAddr(),getDOMAINAddr());
  1296. // AscStrTurnHexStr(buf,buf1);
  1297. // msgAtSend("AT+POC=010000");
  1298. // msgAtSend(buf1);
  1299. // msgAtSend("\r\n");
  1300. // LSAPI_OSI_ThreadSleep(100);
  1301. // msgAtSend("AT+POC=040000\r\n");
  1302. // }
  1303. // uISetNextStatus(UIS_STANDBY );
  1304. // }else if(MKEY_VALUE_DOWN==key){
  1305. // if(++uiTmpVal>=5) uiTmpVal=0;
  1306. // serverFlash(newPara.serList.defaultuse);
  1307. // }
  1308. }
  1309. /*****************************服务器设置结束**********************************/
  1310. /*****************************版本设置开始**********************************/
  1311. unsigned char fotaStep;
  1312. unsigned int fotaTick;
  1313. void fotaStepSet(unsigned char newStep){
  1314. fotaStep=newStep;
  1315. }
  1316. void fotaMsgShow(char *msg){
  1317. #if 1
  1318. newGuiClearPage(0, ROW_THREE);
  1319. newGuiShowStr(0, 32, msg,REVERSED_NO,FONT_MODE_16X16);
  1320. #else
  1321. #ifdef USE_12X12_FONT_ONLY
  1322. int len=guiGetStrXLen((char *)msg,FONT_MODE_12X12);
  1323. #else
  1324. int len=guiGetStrXLen((char *)msg,FONT_MODE_16X16);
  1325. #endif
  1326. guiClearRect(0, 60, GLCD_WIDTH-1, 60+16,guiGetBackColor());
  1327. #ifdef USE_12X12_FONT_ONLY
  1328. guiShowStr((GLCD_WIDTH-len)/2,60+2, msg,FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1329. #else
  1330. guiShowStr((GLCD_WIDTH-len)/2,60, msg,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1331. #endif
  1332. #endif
  1333. }
  1334. void fotaMsgShow2(char *msg1, char *msg2){
  1335. #if 1
  1336. newGuiClearPage(0, ROW_THREE);
  1337. newGuiShowStr(0, 32, msg1,REVERSED_NO,FONT_MODE_16X16);
  1338. newGuiClearPage(0, ROW_FOUR);
  1339. newGuiShowStr(0, 48, msg2,REVERSED_NO,FONT_MODE_16X16);
  1340. #else
  1341. guiClearRect(0, 45, GLCD_WIDTH-1, 45+16+2+16,guiGetBackColor());
  1342. int len=guiGetStrXLen((char *)msg1,FONT_MODE_16X16);
  1343. guiShowStr((GLCD_WIDTH-len)/2,45, msg1,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1344. len=guiGetStrXLen((char *)msg2,FONT_MODE_16X16);
  1345. guiShowStr((GLCD_WIDTH-len)/2,45+16+2, msg2,FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  1346. #endif
  1347. }
  1348. void uiShowVersionSel(char StatusUpdate){
  1349. char buf[50];
  1350. if(StatusUpdate){
  1351. sutApp.fotaVersion[0]=0;
  1352. newGuiClearMainPage();
  1353. newGuiShowStr(0, 16, "版本更新",REVERSED_NO,FONT_MODE_16X16);
  1354. msgAtSend("AT+FOTA?\r\n");
  1355. fotaStep=0;
  1356. sutApp.fotaStatus=0;
  1357. fotaMsgShow("正在检测版本.");
  1358. uTimerStart(&fotaTick, 2000);
  1359. }
  1360. switch(fotaStep){
  1361. case 0:
  1362. if(sutApp.fotaStatus==1){
  1363. fotaMsgShow("无更新版本");
  1364. fotaStep=4;
  1365. break;
  1366. }else if(sutApp.fotaStatus==2){
  1367. fotaMsgShow("是否更新到:");
  1368. snprintf(buf, sizeof(buf), "%s",sutApp.fotaVersion);
  1369. fotaMsgShow(buf);
  1370. fotaStep=1;
  1371. break;
  1372. }
  1373. if(uTimerExpired(&fotaTick)){
  1374. fotaMsgShow("检测超时");
  1375. fotaStep=4;
  1376. }
  1377. break;
  1378. case 1://等待用户确定
  1379. break;
  1380. case 2://用户确定后等待结果
  1381. if(sutApp.fotaStatus==3){
  1382. fotaMsgShow("升级失败");
  1383. fotaStep=4;
  1384. break;
  1385. }else if(sutApp.fotaStatus==4){
  1386. sutApp.fotaStatus=0;//否则会一直刷新本消息
  1387. fotaMsgShow("正在下载");
  1388. break;
  1389. }else if(sutApp.fotaStatus==5){
  1390. fotaMsgShow("下载成功");
  1391. fotaStep=3;
  1392. break;
  1393. }
  1394. if(uTimerExpired(&fotaTick)){
  1395. fotaMsgShow("超时退出");
  1396. fotaStep=4;
  1397. }
  1398. break;
  1399. case 3://升级成功,等待重启
  1400. LSAPI_OSI_ThreadSleep(1000);
  1401. fotaStep=6;
  1402. fotaMsgShow2("确定将关机,再","开机需约60秒");
  1403. //msgAtSend("AT+POC=050000\r\n");//停止POC后复位
  1404. //MSG_INFO(1, "Stop poc");
  1405. //LSAPI_OSI_ThreadSleep(2000);
  1406. //msgAtSend("AT+TRB\r\n");
  1407. //MSG_INFO(1, "Reset system!!!");
  1408. //while(1){LSAPI_OSI_ThreadSleep(1000);}
  1409. break;
  1410. case 4://延时显示2秒后退出
  1411. uTimerStart(&fotaTick, 2000);
  1412. fotaStep=5;
  1413. break;
  1414. case 5://退出升级流程
  1415. if(uTimerExpired(&fotaTick)){
  1416. getStackStruct()->ok_back=1;
  1417. uISetNextStatus(UIS_MENU_SYS_FACTORY);
  1418. }
  1419. break;
  1420. case 6://无更新版本
  1421. sutApp.timeOutCnt=0;//不让界面返回待机界面
  1422. break;
  1423. }
  1424. }
  1425. void uiShowVersionSelResponse(void){
  1426. unsigned char key=getKeyValue();
  1427. if(fotaStep!=1 && fotaStep!=6) return;
  1428. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY);
  1429. else if(MKEY_VALUE_MENU==key){
  1430. if(fotaStep==1){
  1431. fotaMsgShow("请勿断电!");
  1432. fotaStep=2;
  1433. msgAtSend("AT+FOTA=1\r\n");
  1434. uTimerStart(&fotaTick, 10000);
  1435. }else if(fotaStep==6){
  1436. paControl(false);//防止一直滴音
  1437. MSG_INFO(1, "Reset system!!!");
  1438. msgAtSend("AT+POC=050000\r\n");
  1439. msgAtSend("AT+TRB\r\n");
  1440. while(1){LSAPI_OSI_ThreadSleep(1000);}
  1441. }
  1442. }
  1443. }
  1444. /*****************************版本设置结束**********************************/
  1445. /*****************************工程设置开始*********************************/
  1446. void uiShowFactory(char flash){
  1447. static const char *apcPtr[]={
  1448. "服务器设置",
  1449. "版本升级",
  1450. "CSQ查看",
  1451. "耳机MIC增益",
  1452. // "耳机SPK增益",
  1453. "字库更新",
  1454. ""
  1455. };
  1456. if(flash) dotListBoxInit(apcPtr,"工程设置",-1,-1,0);
  1457. }
  1458. void uiShowFactoryResponse(void){
  1459. unsigned short key;
  1460. unsigned char handle;
  1461. key=dotListBoxResponse();
  1462. if(MKEY_VALUE_MENU==key){
  1463. handle=dotListGetHandle();
  1464. switch(handle){
  1465. case 0://服务器设置
  1466. uISetNextStatus(UIS_MENU_SYS_SERVERPASS);
  1467. break;
  1468. case 1://版本升级
  1469. uISetNextStatus(UIS_MENU_SYS_VERSION);
  1470. break;
  1471. case 2://CSQ查看
  1472. uISetNextStatus(UIS_MENU_SYS_CSQ);
  1473. break;
  1474. case 3://设置mic增益
  1475. uISetNextStatus(UIS_MENU_SYS_MIC);
  1476. break;
  1477. //case 4://耳机SPK增益
  1478. // uISetNextStatus(UIS_MENU_SYS_SPK);
  1479. // break;
  1480. case 4://字库更新
  1481. uISetNextStatus(UIS_MENU_SYS_FONT);
  1482. break;
  1483. }
  1484. if(handle<=4) uiPushStack(handle);
  1485. }else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1486. }
  1487. /*****************************工程设置结束***********************************/
  1488. /*****************************提示音设置开始********************************/
  1489. static void switchFlash(unsigned char defaultVal){
  1490. char info[10];
  1491. if(uiTmpVal==0) snprintf(info, sizeof(info), "关闭");
  1492. else snprintf(info, sizeof(info), "打开");
  1493. newGuiClearPage(0, ROW_FOUR);
  1494. newGuiShowStr(0,48,info,REVERSED_NO,FONT_MODE_16X16);
  1495. if(uiTmpVal==defaultVal) guiShowBinMap(GLCD_WIDTH-15,48,"APN1.bin");
  1496. }
  1497. void uiShowNoteSel(char StatusUpdate){
  1498. if(StatusUpdate){
  1499. newGuiClearMainPage();
  1500. newGuiShowStr(0, 16, "提示音设置",REVERSED_NO,FONT_MODE_16X16);
  1501. newGuiShowStr(0, 32, "类别:",REVERSED_NO,FONT_MODE_16X16);
  1502. uiTmpVal=newPara.KeySound;
  1503. switchFlash(newPara.KeySound);
  1504. }
  1505. }
  1506. void uiShowNoteSelResponse(void){
  1507. unsigned short key=getKeyValue();
  1508. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1509. else if(MKEY_VALUE_MENU==key){
  1510. getStackStruct()->ok_back=1;
  1511. if(newPara.KeySound != uiTmpVal){
  1512. newPara.KeySound=uiTmpVal;
  1513. #ifndef ENABLE_PWM_BEEP
  1514. if(uiTmpVal==0) msgAtSend("AT+TONES=0\r\n");
  1515. else msgAtSend("AT+TONES=1\r\n");
  1516. #endif
  1517. sysIniSave();
  1518. }
  1519. uISetNextStatus(UIS_MENU_SYS_SEL);
  1520. }else if(MKEY_VALUE_DOWN || MKEY_VALUE_UP){
  1521. if(uiTmpVal==0) uiTmpVal=1;
  1522. else uiTmpVal=0;
  1523. switchFlash(newPara.KeySound);
  1524. }
  1525. }
  1526. /*****************************提示音设置结束********************************/
  1527. /*****************************关机界面提示开始**********************************/
  1528. void uiShowShutDown(char update){
  1529. if(update){
  1530. lcdBackLightApi(1);
  1531. guiClearAll(guiGetBackColor());
  1532. guiShowCaption(0,"关机",UI_STATUS_BAR_HEIGH,guiGetBackColor(),guiGetForeColor(),FONT_MODE_12X12);
  1533. guiShowMessageBox("确定关机?");
  1534. uiMenuShowBottomLine();
  1535. uiMenuShowBottomIndacitor("确定", "取消");
  1536. }
  1537. }
  1538. void uiShowShutDownResponse(void){
  1539. unsigned short key=getKeyValue();
  1540. if(MKEY_VALUE_ESC==key){
  1541. if(sutApp.waitEscReleased==0) uISetNextStatus(UIS_STANDBY);
  1542. }else if(MKEY_VALUE_MENU==key){
  1543. MSG_INFO(1, "Power is off!");
  1544. appSleepCtl(ASLEEP_PWR, 1);
  1545. }
  1546. }
  1547. /*****************************关机界面提示结束**********************************/
  1548. /*****************************CSQ查看开始********************************/
  1549. void CSQShow(unsigned int exeInterval,char StatusUpdate){
  1550. char info[30];
  1551. static int g_iCSQ=-1,cnt=1000;
  1552. int y=UI_CONTENT_SHOW_Y+(GLCD_HEIGHT-UI_CONTENT_SHOW_Y)/2-12;
  1553. if(g_iCSQ!=sutApp.g_iCSQ || StatusUpdate){
  1554. g_iCSQ=sutApp.g_iCSQ;
  1555. snprintf(info, sizeof(info), "CSQ:%d", g_iCSQ);
  1556. newGuiClearPage(0, ROW_THREE);
  1557. newGuiShowStr(0, 32, info,REVERSED_NO,FONT_MODE_16X16);
  1558. }
  1559. if(++cnt<(1500/exeInterval)) return;
  1560. cnt=0;
  1561. msgAtSend("AT+CSQ\r\n");
  1562. }
  1563. void uiShowCsqSel(char StatusUpdate,unsigned int exeInterval){
  1564. if(StatusUpdate){
  1565. newGuiClearMainPage();
  1566. newGuiShowStr(0, 16, "CSQ查看",REVERSED_NO,FONT_MODE_16X16);
  1567. }
  1568. CSQShow(exeInterval,StatusUpdate);
  1569. }
  1570. void uiShowCsqSelResponse(void){
  1571. unsigned short key=getKeyValue();
  1572. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY);
  1573. }
  1574. /*****************************CSQ查看结束********************************/
  1575. /*******************************MIC/SPK查看************************************/
  1576. void MicSpkShow(unsigned char defaultVal){
  1577. char info[30];
  1578. unsigned short x,y,len;
  1579. snprintf(info, sizeof(info), "%d",uiTmpVal+1);
  1580. newGuiClearPage(0, ROW_THREE);
  1581. newGuiShowStr(0, 32, info,REVERSED_NO,FONT_MODE_16X16);
  1582. if(uiTmpVal==newPara.micGain) guiShowBinMap(GLCD_WIDTH-15,32,"APN1.bin");
  1583. }
  1584. void uiShowMicSel(char StatusUpdate){
  1585. if(StatusUpdate){
  1586. newGuiClearMainPage();
  1587. newGuiShowStr(0, 16, "耳机MIC增益",REVERSED_NO,FONT_MODE_16X16);
  1588. uiTmpVal=newPara.micGain;
  1589. MicSpkShow(newPara.micGain);
  1590. }
  1591. }
  1592. void uiShowMicSelResponse(void){
  1593. unsigned short key=getKeyValue();
  1594. if(MKEY_VALUE_DOWN==key){
  1595. if(uiTmpVal==0) uiTmpVal=MIC_GAIN_NUM-1;
  1596. else uiTmpVal--;
  1597. MicSpkShow(newPara.micGain);
  1598. }else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY);
  1599. else if(MKEY_VALUE_MENU==key){
  1600. if(uiTmpVal!= newPara.micGain){
  1601. newPara.micGain=uiTmpVal;
  1602. sysIniSave();
  1603. if(sutApp.earLev!=0) VolMicUpdate();
  1604. }
  1605. getStackStruct()->ok_back=1;
  1606. uISetNextStatus(UIS_MENU_SYS_FACTORY);
  1607. }
  1608. }
  1609. void uiShowSpkSel(char StatusUpdate){
  1610. if(StatusUpdate){
  1611. newGuiClearMainPage();
  1612. newGuiShowStr(0, 16, "耳机SPK增益",REVERSED_NO,FONT_MODE_16X16);
  1613. uiTmpVal=newPara.spkGain;
  1614. MicSpkShow(newPara.spkGain);
  1615. }
  1616. }
  1617. void uiShowSpkSelResponse(void){
  1618. unsigned short key=getKeyValue();
  1619. if(MKEY_VALUE_DOWN==key){
  1620. if(uiTmpVal==0) uiTmpVal=SPK_GAIN_NUM-1;
  1621. else uiTmpVal--;
  1622. MicSpkShow(newPara.spkGain);
  1623. }else if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY);
  1624. else if(MKEY_VALUE_MENU==key){
  1625. if(uiTmpVal!= newPara.spkGain){
  1626. newPara.spkGain=uiTmpVal;
  1627. sysIniSave();
  1628. if(sutApp.earLev!=0) VolSpkUpdate();
  1629. }
  1630. getStackStruct()->ok_back=1;
  1631. uISetNextStatus(UIS_MENU_SYS_FACTORY);
  1632. }
  1633. }
  1634. /******************************MIC/SPK查看结束*********************************/
  1635. /******************************fota更新生辟字库**********************************/
  1636. #include "lsapi_http.h"
  1637. #define FONT_16_FILE HZK_16_NEW_FILE
  1638. #define FONT_16_MD5 "HZK16_Ext_md5.txt"
  1639. #define FONT_12_FILE HZK_12_NEW_FILE
  1640. #define FONT_12_MD5 "HZK12_Ext_md5.txt"
  1641. LSAPI_OSI_Thread_t *fontThread=NULL;
  1642. short fontLoadStatus;
  1643. bool fontResult;
  1644. HttpInfoSet httpFont;
  1645. //return:false, not finished, true, done
  1646. //status:1:busy
  1647. //status:-1:get 16 file failed
  1648. //status:-2:16 file len err
  1649. //status:-3:16 file format err
  1650. //status:-4:16 ok, get 12 file failed
  1651. //status:-5:16 ok, get 12 file len err
  1652. //status:-6:16 ok, get 12 file fotmat err
  1653. //status:0 16,12 ok
  1654. bool httpFontGetStatus(short *status){//获取更新结果接口
  1655. if(fontResult==true) *status=fontLoadStatus;
  1656. return fontResult;
  1657. }
  1658. static void fontEntry(void *param);
  1659. bool httpFontGetStart(void){//开启更新接口
  1660. fontResult=false;
  1661. if(NULL != fontThread) return true;
  1662. fontLoadStatus=-1;
  1663. fontThread=LSAPI_OSI_ThreadCreate("lteEntry", fontEntry,NULL,LSAPI_OSI_PRIORITY_NORMAL,1024*10,4);
  1664. if(NULL==fontThread) return false;
  1665. }
  1666. void fontSaveData(unsigned char *data, unsigned int len){
  1667. int fd;
  1668. char filename[30];
  1669. if(data[0]==12){
  1670. extFontFileCtl(data[0],false);
  1671. snprintf(filename,sizeof(filename), "%s",FONT_12_FILE);
  1672. }else if(data[0]==16){
  1673. extFontFileCtl(data[0],false);
  1674. snprintf(filename,sizeof(filename), "%s",FONT_16_FILE);
  1675. }
  1676. else return;
  1677. fd=LSAPI_FS_Open(filename, LSAPI_FS_O_RDWR | LSAPI_FS_O_CREAT | LSAPI_FS_O_TRUNC,0x0);
  1678. if(fd<0){
  1679. extFontFileCtl(data[0],true);
  1680. return;
  1681. }
  1682. LSAPI_FS_Write(fd, data, len);
  1683. LSAPI_FS_Close(fd);
  1684. extFontFileCtl(data[0],true);
  1685. }
  1686. bool checkFileMd5(char type, unsigned char *md5, unsigned int len){
  1687. int fd;
  1688. char filename[30];
  1689. unsigned char rmd5[32];
  1690. if(type==0)snprintf(filename,sizeof(filename), "%s",FONT_16_MD5);
  1691. else if(type==1)snprintf(filename,sizeof(filename), "%s",FONT_12_MD5);
  1692. else return false;
  1693. fd=LSAPI_FS_Open(filename, LSAPI_FS_O_RDONLY,0);
  1694. if(fd<0){
  1695. MSG_WARN(1, "'%s' open failed to read", filename);
  1696. return false;
  1697. }
  1698. LSAPI_FS_Read(fd, rmd5, sizeof(rmd5));
  1699. LSAPI_FS_Close(fd);
  1700. if(0==memcmp(rmd5, md5, len)) return true;
  1701. else return false;
  1702. }
  1703. void fontSaveMd5(char type, unsigned char *md5, unsigned int len){
  1704. int fd;
  1705. char filename[30];
  1706. if(type==0)snprintf(filename,sizeof(filename), "%s",FONT_16_MD5);
  1707. else if(type==1)snprintf(filename,sizeof(filename), "%s",FONT_12_MD5);
  1708. else return;
  1709. fd=LSAPI_FS_Open(filename, LSAPI_FS_O_RDWR | LSAPI_FS_O_CREAT | LSAPI_FS_O_TRUNC,0);
  1710. if(fd<0){
  1711. MSG_WARN(1, "'%s' open failed to save", filename);
  1712. return;
  1713. }
  1714. LSAPI_FS_Write(fd, md5, len);
  1715. LSAPI_FS_Close(fd);
  1716. }
  1717. static void fontEntry(void *param){
  1718. bool font12_noneed_update=true;
  1719. bool font16_noneed_update=true;
  1720. char type=0;
  1721. unsigned int md5_len;
  1722. unsigned char rmd5[32];
  1723. bool needClear=true;
  1724. //get 16 md5
  1725. MSG_INFO(1,"try get 16 md5");
  1726. memset(&httpFont, 0, sizeof(httpFont));httpFont.cid=1;
  1727. snprintf(httpFont.url, sizeof(httpFont.url),"http://120.77.66.129/higos/extFonts/%s",FONT_16_MD5);
  1728. if(LSAPI_HTTP_GET(&httpFont)){
  1729. fontLoadStatus=-2;
  1730. goto FONT_END;
  1731. }
  1732. //ana 16 md5
  1733. if(httpFont.recvlen!=32){
  1734. fontLoadStatus=-3;
  1735. goto FONT_END;
  1736. }
  1737. md5_len=httpFont.recvlen;
  1738. memcpy(rmd5, httpFont.RecvData, md5_len);
  1739. LSAPI_HTTP_ParaClear(&httpFont);
  1740. font16_noneed_update=checkFileMd5(type, rmd5, md5_len);
  1741. if(false==font16_noneed_update){
  1742. MSG_INFO(1,"try get 16 file");
  1743. //get 16 first
  1744. memset(&httpFont, 0, sizeof(httpFont));httpFont.cid=1;
  1745. snprintf(httpFont.url, sizeof(httpFont.url),"http://120.77.66.129/higos/extFonts/%s",FONT_16_FILE);
  1746. if(LSAPI_HTTP_GET(&httpFont)){//尝试获取差分包
  1747. fontLoadStatus=-4;
  1748. goto FONT_END;
  1749. }
  1750. if(httpFont.recvlen<35){//1+[2+32]....
  1751. fontLoadStatus=-5;
  1752. goto FONT_END;
  1753. }else if(httpFont.RecvData[0]!=16 || (httpFont.recvlen-1)%34){
  1754. fontLoadStatus=-6;
  1755. goto FONT_END;
  1756. }
  1757. fontSaveData(httpFont.RecvData, httpFont.recvlen);
  1758. fontSaveMd5(type, rmd5, md5_len);
  1759. LSAPI_HTTP_ParaClear(&httpFont);
  1760. }
  1761. type=1;
  1762. //get 12 md5
  1763. MSG_INFO(1,"try get 12 md5");
  1764. memset(&httpFont, 0, sizeof(httpFont));httpFont.cid=1;
  1765. snprintf(httpFont.url, sizeof(httpFont.url),"http://120.77.66.129/higos/extFonts/%s",FONT_12_MD5);
  1766. if(LSAPI_HTTP_GET(&httpFont)){
  1767. fontLoadStatus=-7;
  1768. goto FONT_END;
  1769. }
  1770. //ana 12 md5
  1771. if(httpFont.recvlen!=32){
  1772. fontLoadStatus=-8;
  1773. goto FONT_END;
  1774. }
  1775. md5_len=httpFont.recvlen;
  1776. memcpy(rmd5, httpFont.RecvData, md5_len);
  1777. LSAPI_HTTP_ParaClear(&httpFont);
  1778. font12_noneed_update=checkFileMd5(type, rmd5, md5_len);
  1779. if(false==font12_noneed_update){
  1780. MSG_INFO(1,"try get 12 file");
  1781. //get 12 then
  1782. memset(&httpFont, 0, sizeof(httpFont));httpFont.cid=1;
  1783. snprintf(httpFont.url, sizeof(httpFont.url),"http://120.77.66.129/higos/extFonts/%s",FONT_12_FILE);
  1784. if(LSAPI_HTTP_GET(&httpFont)){//尝试获取差分包
  1785. fontLoadStatus=-9;
  1786. goto FONT_END;
  1787. }
  1788. if(httpFont.recvlen<27){//1+[2+24]....
  1789. fontLoadStatus=-10;
  1790. goto FONT_END;
  1791. }else if(httpFont.RecvData[0]!=12 || (httpFont.recvlen-1)%26){
  1792. fontLoadStatus=-11;
  1793. goto FONT_END;
  1794. }
  1795. fontSaveData(httpFont.RecvData, httpFont.recvlen);
  1796. fontSaveMd5(type, rmd5, md5_len);
  1797. LSAPI_HTTP_ParaClear(&httpFont);
  1798. needClear=false;
  1799. }else needClear=false;
  1800. if(font12_noneed_update==true && font16_noneed_update==true) fontLoadStatus=0;
  1801. else fontLoadStatus=1;
  1802. FONT_END:
  1803. fontThread=NULL;
  1804. fontResult=true;
  1805. if(needClear==true) LSAPI_HTTP_ParaClear(&httpFont);
  1806. LSAPI_OSI_ThreadExit();
  1807. }
  1808. //6、UI接口界面(供参考)
  1809. char fontUpdateStatus=0;
  1810. void uiShowFontUpdate(char StatusUpdate){
  1811. static unsigned int timer;
  1812. short status;
  1813. if(StatusUpdate){
  1814. newGuiClearMainPage();
  1815. newGuiShowStr(0, 16, "字库更新",REVERSED_NO,FONT_MODE_16X16);
  1816. newGuiShowStr(0, 32, "确定更新?",REVERSED_NO,FONT_MODE_16X16);
  1817. fontUpdateStatus=0;
  1818. }
  1819. if(fontUpdateStatus==1){
  1820. if(true==httpFontGetStatus(&status)){
  1821. if(status==1){
  1822. newGuiShowStr(0, 32, "更新成功",REVERSED_NO,FONT_MODE_16X16);
  1823. uTimerStart(&timer, 2000);
  1824. }else if(status==0){
  1825. newGuiShowStr(0, 32, "无需更新",REVERSED_NO,FONT_MODE_16X16);
  1826. uTimerStart(&timer, 2000);
  1827. }else{
  1828. newGuiShowStr(0, 32, "更新失败",REVERSED_NO,FONT_MODE_16X16);
  1829. uTimerStart(&timer, 2000);
  1830. }
  1831. fontUpdateStatus=2;
  1832. }
  1833. }else if(fontUpdateStatus==2){
  1834. if(uTimerExpired(&timer)){
  1835. getStackStruct()->ok_back=1;
  1836. uISetNextStatus(UIS_MENU_SYS_FACTORY);
  1837. }
  1838. }
  1839. }
  1840. void uiShowFontUpdateResponse(){
  1841. unsigned short key=getKeyValue();
  1842. if(fontUpdateStatus!=0) return;
  1843. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_FACTORY);
  1844. else if(MKEY_VALUE_MENU==key){
  1845. httpFontGetStart();
  1846. fontUpdateStatus=1;
  1847. newGuiShowStr(0, 32, "正在更新.",REVERSED_NO,FONT_MODE_16X16);
  1848. }
  1849. }
  1850. /******************************fota更新生辟字库结束***********************************/
  1851. #ifdef USE_LEFT_MOVING
  1852. /***************************主界面滚动显示**********************************/
  1853. #define MOVING_ITME_NUM 3 //显示三条项目
  1854. #define MAX_ROW_BYTE (20+1+2) //最多显示20个字节,10个中文
  1855. #define MAX_SHOW_BYTE 11 //最多一次性显示10个字节
  1856. void leftMoveStr(char *name, unsigned short len){
  1857. char temp[3];
  1858. unsigned char move=1;
  1859. unsigned short i;
  1860. if(name[0] > 0x80) move=2;
  1861. for(i=0;i<move;i++) temp[i]=name[i];
  1862. for(i=0;i<len-move;i++) name[i]=name[i+move];
  1863. for(i=0;i<move;i++) name[i+len-move]=temp[i];
  1864. }
  1865. void getRealShow(char *des, char *src,int maxsize)
  1866. {//??è?×??à12+1??×??ú??ê?
  1867. int i,j,cpsize=maxsize-1;
  1868. for(i=0;i<cpsize;i++){
  1869. if(src[i]>0x80){
  1870. if(i+2>cpsize){//装不下了,停止
  1871. break;
  1872. }
  1873. des[i]=src[i];
  1874. des[i+1]=src[i+1];
  1875. i++;
  1876. }else des[i]=src[i];
  1877. }
  1878. des[i]=0;
  1879. }
  1880. void showbufdata(char type, unsigned char *data, int len){
  1881. char info[100],buf[3];
  1882. int i;
  1883. sprintf(info, "D[%d]%c:",len,type);
  1884. for(i=0;i<len;i++){
  1885. sprintf(buf, "%02x",data[i]);
  1886. strcat(info, buf);
  1887. }
  1888. MSG_INFO(1, info);
  1889. }
  1890. //除去标识(群组:/成员:/话权:)外的字节数,多的1字节用于加空格
  1891. void mainScreenShowMoving(unsigned short y, unsigned char reset,char *gname,char *uname,char *voicePri){
  1892. unsigned char i;
  1893. int j,len;
  1894. unsigned short showX,showY,showPage;
  1895. //显示缓存,最多显示7个中文
  1896. const char indicators[MOVING_ITME_NUM][6]={
  1897. "群组:","成员:","话垚:",
  1898. };
  1899. static char item[MOVING_ITME_NUM][MAX_ROW_BYTE];
  1900. static unsigned short itemSum[MOVING_ITME_NUM];
  1901. unsigned short *sum,tsum;
  1902. char *ptr,*showPtr;
  1903. char showMax[MAX_ROW_BYTE];//用于临时存储条目全内容,判定是否发生变化
  1904. char needMove;
  1905. for(i=0;i<MOVING_ITME_NUM;i++){
  1906. showX=0;
  1907. showPage=ROW_TWO+i;
  1908. showY=STATUS_BAR_HEIGH+16*i;
  1909. sum=&itemSum[i];
  1910. showPtr=&item[i][0];
  1911. switch(i){
  1912. case 0://群组:默认群组
  1913. snprintf(showMax, sizeof(showMax), "%s ",gname);
  1914. break;
  1915. case 1://成员:测试组1
  1916. snprintf(showMax, sizeof(showMax), "%s ",uname);
  1917. break;
  1918. case 2://话权:空闲
  1919. snprintf(showMax, sizeof(showMax), "%s ",voicePri);
  1920. break;
  1921. }
  1922. ptr=showMax;
  1923. len=strlen(ptr);
  1924. //计算buff的sum
  1925. tsum=0;
  1926. for(j=0;j<len;j++) tsum += ptr[j];
  1927. //检测是否需要移动处理
  1928. if(len>MAX_SHOW_BYTE) needMove=1;
  1929. else needMove=0;
  1930. if(*sum != tsum || reset){
  1931. newGuiClearPage(0,showPage);
  1932. newGuiShowStr(showX, showY, &indicators[i][0], REVERSED_NO, FONT_MODE_16X16);
  1933. }
  1934. showX += 40;
  1935. if(needMove==0){
  1936. if(*sum != tsum || reset){//内容发生了变化
  1937. //只显示一次即可
  1938. snprintf(showPtr, MAX_ROW_BYTE, "%s", ptr);
  1939. newGuiClearPage(showX,showPage);
  1940. newGuiShowStr(showX, showY, showPtr, REVERSED_NO, FONT_MODE_16X16);
  1941. }
  1942. }else{//做移动处理
  1943. if(*sum != tsum) memcpy(showPtr, ptr, MAX_ROW_BYTE);
  1944. else leftMoveStr(showPtr, strlen(showPtr));
  1945. getRealShow(showMax, showPtr,MAX_SHOW_BYTE);
  1946. newGuiClearPage(showX,showPage);
  1947. newGuiShowStr(showX, showY, showMax, REVERSED_NO, FONT_MODE_16X16);
  1948. }
  1949. *sum=tsum;
  1950. }
  1951. }
  1952. #endif
  1953. /*****************************提示音设置开始********************************/
  1954. #define LOCK_MODE_NUM 2
  1955. void lockFlash(unsigned char defaultVal){
  1956. char info[20];
  1957. newGuiClearPage(0, ROW_FOUR);
  1958. if(uiTmpVal==0) snprintf(info, sizeof(info), "锁按键");
  1959. else snprintf(info,sizeof(info), "锁按键+PTT");
  1960. newGuiShowStr(0, 48, info,REVERSED_NO,FONT_MODE_16X16);
  1961. if(uiTmpVal==defaultVal) guiShowBinMap(GLCD_WIDTH-15,48,"APN1.bin");
  1962. }
  1963. void uiShowLockUpdate(char StatusUpdate){
  1964. if(StatusUpdate){
  1965. newGuiClearMainPage();
  1966. newGuiShowStr(0, 16, "键锁设置",REVERSED_NO,FONT_MODE_16X16);
  1967. newGuiShowStr(0, 32, "类别:",REVERSED_NO,FONT_MODE_16X16);
  1968. uiTmpVal=newPara.lockType;
  1969. lockFlash(newPara.lockType);
  1970. }
  1971. }
  1972. void uiShowLockUpdateResponse(void){
  1973. unsigned short key=getKeyValue();
  1974. if(MKEY_VALUE_ESC==key) uISetNextStatus(UIS_MENU_SYS_SEL);
  1975. else if(MKEY_VALUE_MENU==key){
  1976. getStackStruct()->ok_back=1;
  1977. if(newPara.lockType != uiTmpVal){
  1978. newPara.lockType=uiTmpVal;
  1979. sysIniSave();
  1980. }
  1981. uISetNextStatus(UIS_MENU_SYS_SEL);
  1982. }else if(MKEY_VALUE_DOWN==key){
  1983. if(uiTmpVal==0) uiTmpVal=1;
  1984. else uiTmpVal=0;
  1985. lockFlash(newPara.lockType);
  1986. }
  1987. }
  1988. /*****************************提示音设置结束********************************/