uiBlock.c 52 KB

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