UI.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  1. /********************************************************************************
  2. * File Name: UI.c
  3. * Function Describe:user interface module
  4. * Relate Module:
  5. * Explain: 用户界面,注意,为避免操作系统中多任务调用而导致资源访问冲突,只允许在同一个任务中调用。目前设定在MainTask任务中调用!
  6. * Writer: ShiLiangWen
  7. * Date: 2016.1.28
  8. *******************************************************************************/
  9. #include "includes.h"
  10. #include "LCD.h"
  11. SUT_UI_STATUS sutUIstatus;
  12. void UISetNextStatus(unsigned char status);
  13. void ShowStatusBar(int Update);//显示状态栏
  14. void ShowButton(u16 x,u16 y,const char *str);//显示一个按钮
  15. void ShowMessageBox(char *msg);
  16. int siCt1=-1;
  17. SUT_LIST_BOX sutListBox;//ListBox控件,因为内部用到了features[]数据比较大,为节省内存控件,建议整个项目共用一个list
  18. /******************************************************
  19. 在同一个位置交替显示本机用户名和本机当前群组名
  20. 参数:x,y 显示位置左上角的坐标
  21. update ==0 时根据内部静态群组名比较决定是否刷屏显示
  22. update !=0 时强制刷屏显示
  23. ******************************************************/
  24. void ShowGroupAndUserName(u16 x,u16 y,int update)
  25. {
  26. #if POC_USER_NAME_LEN>POC_GROUP_NAME_LEN
  27. static char scName[POC_USER_NAME_LEN];
  28. char name[POC_USER_NAME_LEN];
  29. #else
  30. static char scName[POC_GROUP_NAME_LEN];
  31. char name[POC_GROUP_NAME_LEN];
  32. #endif
  33. static char scCt=0;//0~2--显示群组名 3~5--显示用户名
  34. u16 len;
  35. unsigned char danHuanBuffer[9]={0xB5,0xA5,0xBA,0xF4,0xC4,0xA3,0xCA,0xBD,0};
  36. char GroupShowUpdate=0;
  37. if(++scCt>=6 || update!=0)scCt=0;
  38. if(scCt<3){
  39. if(sutPocStatus.danHunStatus==0){
  40. if(0!=strcmp(sutPocStatus.LocalGroup.name,scName) || update!=0){
  41. memcpy(scName,sutPocStatus.LocalGroup.name,sizeof(scName));
  42. GroupShowUpdate=1;
  43. }
  44. }else{
  45. if(0!=strcmp((char *)danHuanBuffer,scName) || update!=0){
  46. memcpy(scName, danHuanBuffer,sizeof(danHuanBuffer));
  47. GroupShowUpdate=1;
  48. }
  49. }
  50. if(GroupShowUpdate){
  51. GuiClearRect(x,y,159,y+16);
  52. StrIntercept(name,scName,sizeof(name));
  53. GuiShowStr(x,y,name,0x01);
  54. sutPocStatus.statusChaned=1;
  55. }
  56. }else{
  57. if(0!=strcmp(sutPocStatus.LocalUser.name,scName) || update!=0){
  58. memcpy(scName,sutPocStatus.LocalUser.name,sizeof(scName));
  59. GuiClearRect(x,y,159,y+16);
  60. StrIntercept(name,scName,sizeof(name));;
  61. GuiShowStr(x,y,name,0x01);
  62. sutPocStatus.statusChaned=1;
  63. }
  64. }
  65. }
  66. #if 1
  67. void ShowCallUserName(u16 x,u16 y)
  68. {
  69. static char scName[POC_USER_NAME_LEN];
  70. char name[POC_USER_NAME_LEN];
  71. uint8_t thisName;
  72. static uint8_t suCt=0;
  73. if(suCt%50)
  74. {
  75. if(strncmp(scName, sutPocStatus.Callname,sizeof(scName)) != 0 ||
  76. strncmp(scName, sutPocStatus.Callname,sizeof(sutPocStatus.Callname))!=0 ||
  77. sutPocStatus.statusChaned)
  78. {//当名字变更后,刷新
  79. GuiClearRect(0,18,159,18+16);
  80. memcpy(scName,sutPocStatus.Callname,sizeof(sutPocStatus.Callname));
  81. sutPocStatus.statusChaned=0;
  82. }
  83. StrIntercept(name,scName,sizeof(name));
  84. GuiShowStr(x+48,y,sutPocStatus.Callname,0x01);
  85. }
  86. if(++suCt>=50)
  87. suCt=0;
  88. }
  89. #else
  90. u8 statusChaned;//用来修复当低优先级用户一直在讲话,不释放,然后被抢麦,
  91. //只要抢麦者释放话语权后,低优先级用户显示出群组名字,再
  92. //被抢麦,都会显示有问题。第二次以后都会。
  93. void ShowCallUserName(u16 x,u16 y)
  94. {
  95. static char scName[POC_USER_NAME_LEN];
  96. char name[POC_USER_NAME_LEN];
  97. unsigned char thisName;
  98. static int siCt=0;
  99. static u8 lastFlag;
  100. if(siCt==0||siCt==50||siCt==100 || siCt==150|| siCt==200){
  101. if(strncmp(scName, sutPocStatus.Callname,sizeof(scName)) != 0 ||
  102. strncmp(scName, sutPocStatus.Callname,sizeof(sutPocStatus.Callname))!=0 ||
  103. statusChaned)
  104. {//当名字变更后,刷新
  105. GuiClearRect(0,18,159,18+16);
  106. memcpy(scName,sutPocStatus.Callname,sizeof(sutPocStatus.Callname));
  107. statusChaned=0;
  108. }
  109. StrIntercept(name,scName,sizeof(name));
  110. GuiShowStr(x+48,y,sutPocStatus.Callname,0x01);
  111. }
  112. if(++siCt>=200)siCt=0;
  113. }
  114. #endif
  115. /**********************************************************
  116. 显示主界面
  117. ************************************************************/
  118. void UIShowMainInterface(int StatusUpdate)
  119. {
  120. int Flag;//主界面状态:0--未登录 1--无人说话 2--本机说话 3--对方说话
  121. static int siLastFlag=-1;//上一个Flag状态值
  122. static int siCt=0;
  123. char info[20];
  124. static unsigned char lastLoginResult=0xff;
  125. if(StatusUpdate){
  126. GuiClearAll();
  127. ShowButton(1,107,"菜单");
  128. ShowButton(121,107,"消息");
  129. siLastFlag=-1;
  130. siCt=0;
  131. ShowStatusBar(StatusUpdate);
  132. return;
  133. }
  134. //======以下持续调用,以便动态更新信息==========
  135. //----顶部显示状态栏-----------
  136. ShowStatusBar(StatusUpdate);
  137. //-----登陆状态标志更新--------
  138. if(0==sutPocStatus.Logined){//未登录时,显示LOGO
  139. Flag=0;
  140. }else if(sutPocStatus.Speaker==0 && sutPocStatus.PPTpress==0){//对方未说话,本机未说话
  141. Flag=1;
  142. siCt1=0;
  143. }else if(sutPocStatus.Speaker==0 && sutPocStatus.PPTpress>0 ){//对方未说话,本机说话
  144. Flag=2;
  145. }else if(sutPocStatus.Speaker>0){//对方说话了
  146. Flag=3;
  147. if(siCt1==0){
  148. siCt1=1;
  149. GuiClearRect(0,18,159,18+16);
  150. }
  151. }
  152. //-------中间图片显示-------
  153. switch(Flag){
  154. case 0://未登录
  155. if(Flag!=siLastFlag){
  156. GuiClearRect(0,38,159,38+59);
  157. GuiShowBmp(30,38,"logo.bmp");
  158. }
  159. break;
  160. case 1://已登录,但无人说话
  161. if(Flag!=siLastFlag){
  162. GuiClearRect(0,38,159,38+59);
  163. GuiShowBmp(30,38,"logo.bmp");
  164. sutPocStatus.statusChaned = 1;
  165. }
  166. break;
  167. case 2://已登录,本机说话
  168. if(Flag!=siLastFlag)GuiClearRect(0,38,159,38+59);
  169. if(0==siCt)GuiShowBmp(40+12,40,"Pickup.bmp");
  170. else if(100==siCt)GuiShowBmp(40+12,40,"Pickup1.bmp");
  171. else if(200==siCt)GuiShowBmp(40+12,40,"Pickup2.bmp");
  172. break;
  173. case 3://已登录,对方说话
  174. if(Flag!=siLastFlag)GuiClearRect(0,38,159,38+59);
  175. if(0==siCt)GuiShowBmp(30+24,38,"speaker.bmp");
  176. else if(100==siCt)GuiShowBmp(30+24,38,"speaker1.bmp");
  177. else if(200==siCt)GuiShowBmp(30+24,38,"speaker2.bmp");
  178. //显示对方名字
  179. ShowCallUserName(0,18);
  180. break;
  181. }
  182. //------群组、用户显示--------
  183. if(Flag>0){//已登陆
  184. if(siCt==0 || siCt==100 || siCt==200){//每秒刷一次,以便及时更新。刷太快也影响
  185. if(Flag!=3)
  186. {
  187. if(Flag!=siLastFlag)
  188. {
  189. ShowGroupAndUserName(0,18,1);//当前群组和用户名显示
  190. }else
  191. {
  192. ShowGroupAndUserName(0,18,0);//当前群组和用户名显示
  193. }
  194. }
  195. }
  196. }else{//未登陆
  197. memset(info, ' ',sizeof(info));
  198. memcpy(info, "正在登陆.", 9);
  199. if(0==siCt)
  200. {
  201. GuiShowStr(0,18,info,1);
  202. }
  203. else if(100==siCt)
  204. {
  205. info[9]='.';
  206. GuiShowStr(0,18,info,1);
  207. }
  208. else if(200==siCt)
  209. {
  210. info[9]='.';info[10]='.';
  211. GuiShowStr(0,18,info,1);
  212. }
  213. if(lastLoginResult != sutPocStatus.loginResult || siLastFlag==-1)
  214. {
  215. lastLoginResult=sutPocStatus.loginResult;
  216. if(lastLoginResult==1) snprintf(info, sizeof(info), "账号信息错误");
  217. else if(lastLoginResult==2) snprintf(info, sizeof(info), "无网络连接 ");
  218. else if(lastLoginResult==4) snprintf(info, sizeof(info), "请插卡 ");
  219. else if(lastLoginResult==5) snprintf(info, sizeof(info), "无法连接");
  220. else if(lastLoginResult==6) snprintf(info, sizeof(info), "没有服务");
  221. else goto NEXT_STEP;
  222. GuiShowStr(0,38,info,1);
  223. }
  224. }
  225. NEXT_STEP:
  226. //-------
  227. if(++siCt>=300)siCt=0;
  228. if(Flag!=siLastFlag){//状态变化 才更新 分页
  229. siLastFlag=Flag;
  230. siCt=0;
  231. }
  232. }
  233. void UI_Init(void)
  234. {
  235. memset(&sutUIstatus,0,sizeof(SUT_UI_STATUS));
  236. UISetNextStatus(UIS_STANDBY);
  237. }
  238. /******************************************************
  239. UIShowMenuMain
  240. 显示主菜单
  241. *******************************************************/
  242. SUT_MENU sutMenuMain;
  243. void UIShowMenuMain(int update)
  244. {
  245. static const char *apcMenuMain[]={
  246. "群组选择",
  247. "成员选择",
  248. "文本消息",//"短信查阅",
  249. // "电话管理",
  250. "系统设置",
  251. "终端信息",
  252. ""
  253. };
  254. if(update){
  255. GuiClearAll();
  256. ShowCaption("主菜单",1); //0的话有点靠顶
  257. GuiDrawHLine(0,159,20,1);
  258. MenuInit(&sutMenuMain,apcMenuMain);
  259. return;
  260. }
  261. //如果有需要持续调用,则在以下添加代码
  262. }
  263. /******************************************************
  264. UIShowMenuSysSetup
  265. 系统设置菜单
  266. *******************************************************/
  267. //SUT_MENU sutMenuSysSetup;
  268. void UIShowMenuSysSetup(int update)
  269. {
  270. static const char *apcMenuSysSetup[]={
  271. "APN设置",
  272. "北斗设置",
  273. "LCD设置",
  274. //"软件版本升级",//"应用版本升级",//4G模块中,POC的TCP指令中,没有UDP指令
  275. "网络设置",
  276. //"服务器设置",
  277. "提示音设置",
  278. //"对讲版本升级",
  279. "场景模式",
  280. "快捷群组设置",
  281. ""
  282. };
  283. if(update){
  284. GuiClearAll();
  285. ShowCaption("系统设置",1); //0
  286. GuiDrawHLine(0,159,20,1);
  287. MenuInit(&sutMenuSysSetup,apcMenuSysSetup);
  288. return;
  289. }
  290. }
  291. /******************************************************
  292. UIShowGroupSel
  293. 群组选择
  294. *******************************************************/
  295. void UIShowGroupSel(int update)
  296. {
  297. char buf[30];
  298. unsigned short timeout;
  299. int i;
  300. static unsigned short susCt=0;
  301. static const char *accIconFileName[]={
  302. "Group1.bmp",
  303. "Group2.bmp",
  304. ""
  305. };
  306. static char NullGroup=0;
  307. static char *GroupsName[POC_ALL_GROUPS_NUM+1];//多一个成员,是为了当成员达到最大数目时,最后一个要设为0,ListBoxInit里面统计ITEM是以0为结尾的。
  308. static char GroupsFeatures[POC_ALL_GROUPS_NUM+1];//100
  309. if(sutPocStatus.Logined == 0)//not login
  310. {
  311. ShowMessageBox(" 请先登录... ");
  312. i=50;
  313. while(i--)
  314. OsDelayTime(1);
  315. UISetNextStatus(UIS_STANDBY);
  316. return;
  317. }
  318. if(update){
  319. ////////////////////////////////////////
  320. sutPocStatus.GroupNum_Update=0;
  321. ShowMessageBox("正在获取,请稍候...");
  322. susCt=0;
  323. GuiClearAll();
  324. ShowCaption("群组选择",1); //0
  325. GuiDrawHLine(0,159,20,1);
  326. //----------------------------
  327. for(i=0;i<=POC_ALL_GROUPS_NUM;i++){
  328. GroupsName[i]=&NullGroup;
  329. GroupsFeatures[i]=0;
  330. }
  331. snprintf(buf, sizeof(buf),"Gnum=%d\r\n", sutPocStatus.GroupsNum);
  332. SlwTrace(INF, buf, 0);
  333. #if 1
  334. for(i=0;i<sutPocStatus.GroupsNum && i<POC_ALL_GROUPS_NUM;i++)
  335. {//set local user to 0 index
  336. //设置Features 将决定选择图标
  337. if(sutPocStatus.AllGroups[i].ID==sutPocStatus.LocalGroup.ID)
  338. {
  339. if(i!=0)
  340. {
  341. //#error "有时显示不出当前群组"
  342. snprintf(buf, sizeof(buf), "i:%d****", i);
  343. SlwTrace(INF, buf, 1);
  344. sutPocStatus.AllGroups[i].ID = sutPocStatus.AllGroups[0].ID;
  345. memcpy(sutPocStatus.AllGroups[i].name,sutPocStatus.AllGroups[0].name,sizeof(sutPocStatus.AllGroups[0].name));
  346. sutPocStatus.AllGroups[i].usernum=sutPocStatus.AllGroups[0].usernum;
  347. sutPocStatus.AllGroups[0].ID=sutPocStatus.LocalGroup.ID;
  348. memcpy(sutPocStatus.AllGroups[0].name,sutPocStatus.LocalGroup.name,sizeof(sutPocStatus.LocalGroup.name));
  349. sutPocStatus.AllGroups[0].usernum=sutPocStatus.LocalGroup.usernum;
  350. }
  351. i=sutPocStatus.GroupsNum;
  352. }
  353. }
  354. for(i=0;i<sutPocStatus.GroupsNum && i<POC_ALL_GROUPS_NUM;i++)
  355. {//select icon
  356. //设置Features 将决定选择图标
  357. if(sutPocStatus.AllGroups[i].ID==sutPocStatus.LocalGroup.ID)GroupsFeatures[i]=1;
  358. //添加名字列表指针
  359. GroupsName[i]=sutPocStatus.AllGroups[i].name;
  360. }
  361. #else
  362. for(i=0;i<sutPocStatus.GroupsNum && i<POC_ALL_GROUPS_NUM;i++){
  363. //设置Features 将决定选择图标
  364. if(sutPocStatus.AllGroups[i].ID==sutPocStatus.LocalGroup.ID)GroupsFeatures[i]=1;
  365. //添加名字列表指针
  366. GroupsName[i]=sutPocStatus.AllGroups[i].name;
  367. }
  368. #endif
  369. //初始化ListBox控件
  370. ListBoxInit(&sutListBox,GroupsName,0,accIconFileName,GroupsFeatures);
  371. //----------------------------
  372. GuiDrawHLine(0,159,104,1);
  373. return;
  374. }
  375. //按键提示
  376. if(susCt==0){
  377. GuiShowStr(0,110,"[上]选择 [下]选择 ",0x01);
  378. }else if(susCt==200){
  379. GuiShowStr(0,110,"[M]确定 [EXIT]退出",0x01);
  380. }
  381. if(++susCt>=400)susCt=0;
  382. }
  383. void ReFlashItem(void)
  384. {
  385. //char buf[100];
  386. static unsigned short susCt=0;
  387. static const char *accIconFileName[]={
  388. "people2.bmp",
  389. "people2.bmp",
  390. "people1.bmp",
  391. ""
  392. };
  393. int i;
  394. unsigned short timeout;
  395. static char NullUser=0;
  396. static char *UsersName[POC_ALL_USERS_NUM+1]; //5
  397. static char UserFeatures[POC_ALL_USERS_NUM+1];//5
  398. //----------------------------
  399. for(i=0;i<=POC_ALL_USERS_NUM;i++){
  400. UsersName[i]=&NullUser;
  401. UserFeatures[i]=0;
  402. }
  403. for(i=0;i<sutPocStatus.FillUserIndex;i++)
  404. {
  405. UserFeatures[i]=sutPocStatus.AllUsers[i].status-1;
  406. UsersName[i]=sutPocStatus.AllUsers[i].name;
  407. }
  408. if(sutPocStatus.UserOnLineNum==0)
  409. {
  410. UsersName[0]="空";
  411. UserFeatures[i]=0;
  412. }
  413. //初始化ListBox控件
  414. ListBoxInit(&sutListBox,UsersName,0,accIconFileName,UserFeatures);
  415. }
  416. /******************************************************
  417. UIShowUserSel
  418. 用户选择
  419. *******************************************************/
  420. void UIShowUserSel(int update)
  421. {
  422. static unsigned short susCt=0;
  423. unsigned short timeout;
  424. if(update){
  425. if(sutPocStatus.Logined == 0)//not login
  426. {
  427. ShowMessageBox(" 请先登录... ");
  428. timeout=50;
  429. while(timeout--)
  430. OsDelayTime(1);
  431. UISetNextStatus(UIS_STANDBY);
  432. return;
  433. }
  434. SimpleUserInfoScan(1, 1);
  435. susCt=0;
  436. GuiClearAll();
  437. ShowCaption("用户选择",1); //0
  438. GuiDrawHLine(0,159,20,1);
  439. ReFlashItem();
  440. GuiDrawHLine(0,159,104,1);
  441. return;
  442. }
  443. //按键提示
  444. if(susCt==0){
  445. GuiShowStr(0,110,"[上]选择 [下]选择",0x01);
  446. }else if(susCt==200){
  447. GuiShowStr(0,110,"[M]单呼 [EXIT]退出",0x01);
  448. }
  449. if(++susCt>=400)susCt=0;
  450. }
  451. /******************************************************
  452. UIShowInformation
  453. 用户选择
  454. *******************************************************/
  455. void UIShowInformation(int update)
  456. {
  457. u16 x,y;
  458. char temp[11];
  459. char buf[50];
  460. static unsigned char flag=0;
  461. if(update)
  462. {
  463. flag=0;
  464. GuiClearAll();
  465. ShowCaption("终端信息",1); //0
  466. GuiDrawHLine(0,159,20,1);
  467. }
  468. x=2,y=22;
  469. if(KEY_PANEL_UP==g_ulKeyValue ||
  470. KEY_PANEL_DOWN==g_ulKeyValue ||
  471. update)
  472. {
  473. g_ulKeyValue = 0;
  474. if(flag==0 || flag==2)
  475. {//显示PSN
  476. GuiClearRect(0,y,LCD_WIDTH-1,LCD_HEIGHT-1);
  477. //终端型号
  478. snprintf(buf, sizeof(buf),"终端型号:%s",sutProductPara.ProductName);
  479. GuiShowStr(x,y,buf,0x01);
  480. y+=20;
  481. //终端编码
  482. snprintf(buf, sizeof(buf),"终端编码:%lu",sutProductPara.PSN);
  483. GuiShowStr(x,y,buf,0x01);
  484. y+=20;
  485. //应用版本号
  486. snprintf(buf, sizeof(buf),"应用版本:V%d",sutProductPara.ProductVersion);
  487. GuiShowStr(x,y,buf,0x01);
  488. y+=20;
  489. //模块版本号
  490. snprintf(buf, sizeof(buf),"模块版本:L%d",g_iModemVer);
  491. GuiShowStr(x,y,buf,0x01);
  492. y+=20;
  493. //对讲版本号
  494. snprintf(buf, sizeof(buf),"对讲版本:V%d",g_iPocVer);
  495. GuiShowStr(x,y,buf,0x01);
  496. flag=1;
  497. }else if(flag==1)
  498. {
  499. GuiClearRect(0,y,LCD_WIDTH-1,LCD_HEIGHT-1);
  500. //校验码
  501. temp[0]=0;
  502. GetCheckCodeByPsnMEID(temp,sutProductPara.PSN,sutProductPara.HARDID);
  503. snprintf(buf, sizeof(buf),"校验码:%s",temp);
  504. GuiShowStr(x,y,buf,0x01);
  505. y+=20;
  506. //
  507. memset(buf,sizeof(buf),0);
  508. if(support_type==Un_Known) snprintf(buf,sizeof(buf),"模块类型:未知");
  509. else if(support_type==ONLY_Telecom) snprintf(buf,sizeof(buf),"模块类型:单电信版");
  510. else if(support_type==Mobile_unicom) snprintf(buf,sizeof(buf),"模块类型:移动联通版");
  511. else if(support_type==All_Netcom) snprintf(buf,sizeof(buf),"模块类型:全网通版");
  512. //snprintf(buf, sizeof(buf),"模块类型:%s",buf);
  513. GuiShowStr(x,y,buf,0x01);
  514. flag=2;
  515. }
  516. }else if(KEY_OK_DOWN_GPS == g_ulKeyValue)
  517. {
  518. g_ulKeyValue=0;
  519. if(flag==1 || flag==2)
  520. {
  521. //显示IP
  522. GuiClearRect(0,y,LCD_WIDTH-1,LCD_HEIGHT-1);
  523. //交换IP
  524. GuiShowStr(x,y,"交换服务器:",0x01);
  525. y+= 20;
  526. snprintf(buf, sizeof(buf),"%s",sutProductPara.PIP);
  527. GuiShowStr(x,y,buf,0x01);
  528. y+=20;
  529. //GPS IP
  530. GuiShowStr(x,y,"北斗服务器:",0x01);
  531. y+= 20;
  532. snprintf(buf, sizeof(buf),"%s",sutProductPara.GIP);
  533. GuiShowStr(x,y,buf,0x01);
  534. y+=20;
  535. snprintf(buf, sizeof(buf),"PORT:%d",sutProductPara.GpsPort);
  536. GuiShowStr(x,y,buf,1);
  537. flag=0;
  538. }
  539. }
  540. }
  541. /******************************************************
  542. UI_Loop
  543. UI循环调用,需要在MainTask的主循环中持续调用,及时处理状态发生变化时的UI显示
  544. 此处按下OK键显示里面内容
  545. *******************************************************/
  546. void UI_Loop(void)
  547. {
  548. int StatusUpdate;
  549. if(fota_update.NewPocFlag==1)
  550. {
  551. //显示正在升级;
  552. UISetNextStatus(UIS_UPDATA_SHOW);
  553. }
  554. if(sutUIstatus.Status!=sutUIstatus.NextStatus){//状态发生变更
  555. sutUIstatus.LastStatus=sutUIstatus.Status;
  556. sutUIstatus.Status=sutUIstatus.NextStatus;
  557. StatusUpdate=1;
  558. }else{//状态没有发生变更
  559. StatusUpdate=0;
  560. }
  561. switch(sutUIstatus.Status){
  562. case UIS_STANDBY:
  563. UIShowMainInterface(StatusUpdate);
  564. break;
  565. case UIS_MENU_MAIN:
  566. UIShowMenuMain(StatusUpdate);
  567. break;
  568. case UIS_MENU_USER_SEL:
  569. UIShowUserSel(StatusUpdate);
  570. break;
  571. case UIS_MENU_GROUP_SEL:
  572. UIShowGroupSel(StatusUpdate);
  573. break;
  574. case UIS_MAIL_BOX:
  575. UIShowMailBox(StatusUpdate);
  576. break;
  577. case UIS_MENU_SYS_SET:
  578. UIShowMenuSysSetup(StatusUpdate);
  579. break;
  580. case UIS_MENU_INFO:
  581. UIShowInformation(StatusUpdate);
  582. break;
  583. case UIS_CALL_PHONE:
  584. CallPhoneShow(StatusUpdate);
  585. break;
  586. case UIS_CALL_PHONE_OPTION:
  587. CallPhoneOptionShow(StatusUpdate);
  588. break;
  589. case UIS_CALL_PHONE_INPUT:
  590. CallPhoneInputNumShow(StatusUpdate);
  591. break;
  592. case UIS_CALL_PHONE_MODIFY:
  593. CallPhoneInputNewNumShow(StatusUpdate);
  594. break;
  595. case UIS_CALL_PHONE_DELETE:
  596. CallPhoneDeleteNumShow(StatusUpdate);
  597. //CallPhoneInputNewNumShow(StatusUpdate);
  598. break;
  599. case UIS_MESSAGE_OPTION:
  600. MessageOptionShow(StatusUpdate);
  601. break;
  602. case UIS_MESSAGE_READ:
  603. MessageReadShow(StatusUpdate);
  604. break;
  605. case UIS_CALL_TO_PHONE:
  606. CallToPhoneNum(StatusUpdate);
  607. break;
  608. case UIS_MESSAGE_DELE:
  609. MessageDeletShow(StatusUpdate);
  610. break;
  611. case UIS_MESSAGE_FORMAT:
  612. MessageFormatShow(StatusUpdate);
  613. break;
  614. case UIS_SET_APN:
  615. SetAPNShow(StatusUpdate);
  616. break;
  617. case UIS_APN_DETAIL:
  618. SetApnDetailShow(StatusUpdate);
  619. break;
  620. case UIS_SET_GPS:
  621. SetGPSShow(StatusUpdate);
  622. break;
  623. case UIS_SET_LCD:
  624. SetLCDShow(StatusUpdate);
  625. break;
  626. ////////////////////////////
  627. case UIS_SET_NET:
  628. SetNetShow(StatusUpdate);
  629. break;
  630. ///////////////////////////
  631. case UIS_UP_APPRICATION_VER:
  632. SetUpAppricationVerShow(StatusUpdate);
  633. break;
  634. case UIS_UP_APP_PENDING:
  635. SetUpAppricationVerPending();
  636. break;
  637. case UIS_UP_INTERCOM_VER:
  638. SetUpIntercomVerShow(StatusUpdate);
  639. break;
  640. case UIS_UPDATA_SHOW:
  641. Fota_Update_Show(StatusUpdate);
  642. break;
  643. // case UIS_SERVER_SHOW:
  644. //
  645. // SetServerShow(StatusUpdate);
  646. // break;
  647. case UIS_SET_KEYSound:
  648. SetKeySoundShow(StatusUpdate);
  649. break;
  650. case UIS_SET_SOUNDMODE:
  651. SetSoundModeShow(StatusUpdate);
  652. break;
  653. case UIS_SET_QUICK_GROUP:
  654. SetQuickGroupShow(StatusUpdate);
  655. break;
  656. }
  657. }
  658. /******************************************************
  659. UI_Key
  660. 按键处理
  661. *******************************************************/
  662. void UI_Key(void)
  663. {
  664. char buf[100];
  665. unsigned long key;
  666. int i,temp;
  667. static unsigned char lastOption=0;//向下
  668. switch(sutUIstatus.Status){
  669. case UIS_STANDBY://----待机界面---
  670. switch(g_ulKeyValue){
  671. case KEY_PANEL_MENU:
  672. if(m_GroupSwitch==0)
  673. UISetNextStatus(UIS_MENU_MAIN);
  674. break;
  675. case KEY_PANEL_EXIT:
  676. UISetNextStatus(UIS_MAIL_BOX);
  677. break;
  678. // case KEY_PANEL_P1:
  679. // UISetNextStatus(UIS_MENU_GROUP_SEL);
  680. // break;
  681. // case KEY_PANEL_P2:
  682. // UISetNextStatus(UIS_MENU_USER_SEL);
  683. // break;
  684. // case KEY_PANEL_P3:
  685. // UISetNextStatus(UIS_CALL_PHONE);//UIS_CALL_PHONE_INPUT
  686. // break;
  687. }
  688. break;
  689. case UIS_MENU_MAIN://----主菜单----
  690. key=MenuResponse(&sutMenuMain);
  691. if(KEY_PANEL_MENU==key){
  692. switch(sutMenuMain.handle){
  693. case 0://群组选择
  694. UISetNextStatus(UIS_MENU_GROUP_SEL);
  695. break;
  696. case 1://成员选择
  697. UISetNextStatus(UIS_MENU_USER_SEL);
  698. break;
  699. case 2://信箱查阅
  700. UISetNextStatus(UIS_MAIL_BOX);
  701. break;
  702. #if 0
  703. case 3://电话管理
  704. UISetNextStatus(UIS_CALL_PHONE);//UIS_CALL_PHONE_INPUT UIS_CALL_PHONE
  705. break;
  706. case 4://系统设置
  707. UISetNextStatus(UIS_MENU_SYS_SET);
  708. break;
  709. case 5://终端信息
  710. UISetNextStatus(UIS_MENU_INFO);
  711. break;
  712. #else
  713. case 3://系统设置
  714. UISetNextStatus(UIS_MENU_SYS_SET);
  715. break;
  716. case 4://终端信息
  717. UISetNextStatus(UIS_MENU_INFO);
  718. break;
  719. #endif
  720. }
  721. }
  722. // else if(KEY_PANEL_MENU==key){
  723. // UISetNextStatus(UIS_STANDBY);
  724. // }
  725. else if(KEY_PANEL_EXIT==key){
  726. UISetNextStatus(UIS_STANDBY);
  727. }
  728. break;
  729. case UIS_MENU_GROUP_SEL://-----群组选择-----
  730. key=ListBoxResponse(&sutListBox);
  731. if(!QuickGroupSelect){
  732. if(KEY_PANEL_EXIT==key)UISetNextStatus(sutUIstatus.LastStatus);
  733. //else if(KEY_PANEL_MENU==key)UISetNextStatus(UIS_MENU_MAIN);
  734. else if(KEY_PANEL_MENU==key){
  735. //进入群组AT+POC=09000000000001
  736. snprintf(buf, sizeof(buf),"AT+POC=090000%08x\r\n",sutPocStatus.AllGroups[sutListBox.handle].ID);
  737. g_ucEnterGroupFlag=1;
  738. //保存name
  739. for(i=0;i <sizeof(sutPocStatus.AllGroups[sutListBox.handle].name);i++) //strlen你就悲剧了
  740. g_cGroupName[i] = sutPocStatus.AllGroups[sutListBox.handle].name[i];
  741. g_ulGroupID=sutPocStatus.AllGroups[sutListBox.handle].ID;
  742. ModemSendAT((u8 *)buf);
  743. UISetNextStatus(UIS_STANDBY);
  744. ////////////////////////////
  745. //防止当优先级高的群组用户讲话,当前机子从同群组切到默认组时,出现一直显示播报却没有声音的问题
  746. //逻辑应该是切换了群组就得重新拉才有播报
  747. sutPocStatus.Speaker=0;
  748. SpeakerDisable();
  749. ////////////////////////////
  750. }
  751. }else {
  752. if(KEY_PANEL_EXIT==key)UISetNextStatus(UIS_SET_QUICK_GROUP);
  753. //else if(KEY_PANEL_MENU==key)UISetNextStatus(UIS_MENU_MAIN);
  754. else if(KEY_PANEL_MENU==key){
  755. sutProductPara.QuickGroupId[QuickGrouPIndex]=sutPocStatus.AllGroups[sutListBox.handle].ID;
  756. UISetNextStatus(UIS_SET_QUICK_GROUP);
  757. }
  758. }
  759. break;
  760. case UIS_MENU_USER_SEL://-----成员选择-----
  761. if(sutListBox.handle==0 && KEY_PANEL_UP==g_ulKeyValue)
  762. {
  763. if(sutPocStatus.handleIndex >=5) sutPocStatus.handleIndex -=5;
  764. else if(sutPocStatus.handleIndex==0) sutPocStatus.handleIndex=sutPocStatus.UserOnLineNum-1;
  765. SimpleUserInfoScan(0,0);
  766. ReFlashItem();//指针会被重置到0位置
  767. lastOption=1;
  768. //reload up
  769. break;
  770. }else if((sutListBox.handle+1) == sutListBox.itemnum && (KEY_PANEL_DOWN==g_ulKeyValue))
  771. {
  772. if(lastOption)
  773. {
  774. sutPocStatus.handleIndex += sutListBox.itemnum;
  775. }
  776. if(sutPocStatus.handleIndex+1>=sutPocStatus.UserOnLineNum) sutPocStatus.handleIndex=0;
  777. SimpleUserInfoScan(0,1);
  778. ReFlashItem();//指针会被重置到0位置
  779. lastOption=0;
  780. //reload down
  781. break;
  782. }
  783. key=ListBoxResponse(&sutListBox);
  784. if(KEY_PANEL_EXIT==g_ulKeyValue)
  785. {
  786. lastOption=0;
  787. UISetNextStatus(sutUIstatus.LastStatus);
  788. }
  789. // else if(KEY_PANEL_MENU==g_ulKeyValue)
  790. // {
  791. // lastOption=0;
  792. // UISetNextStatus(UIS_MENU_MAIN);
  793. // }
  794. else if(KEY_PANEL_MENU==key){
  795. //单呼成员 AT+POC=AT+POC=0A0000xxxxxxxx
  796. ///////////////////////////////////////
  797. if(0 == sutPocStatus.UserOnLineNum)
  798. {
  799. // sprintf(buf, "无法呼叫自己");
  800. // ShowMessageBox(buf);
  801. // OsDelayTime(200);
  802. // UISetNextStatus(sutUIstatus.LastStatus);
  803. break;
  804. }
  805. ///////////////////////////////////////
  806. snprintf(buf, sizeof(buf),"AT+POC=0A0000%08x\r\n",sutPocStatus.AllUsers[sutListBox.handle].ID);
  807. ModemSendAT(buf);
  808. snprintf(buf, sizeof(buf),"呼叫:%s",sutPocStatus.AllUsers[sutListBox.handle].name);
  809. ShowMessageBox(buf);
  810. OsDelayTime(200);
  811. UISetNextStatus(UIS_STANDBY);
  812. }
  813. break;
  814. case UIS_MAIL_BOX://-----短信查阅-----
  815. MessageResponse();
  816. break;
  817. case UIS_CALL_PHONE://-----电话管理----
  818. CallPhoneResponse();
  819. break;
  820. case UIS_MENU_SYS_SET://-----系统设置-----
  821. SetSYSResponse(); //名字没取好,实际上是系统
  822. break;
  823. case UIS_MENU_INFO://-----终端信息-----
  824. if(KEY_PANEL_EXIT==g_ulKeyValue){
  825. UISetNextStatus(sutUIstatus.LastStatus);//UIS_STANDBY
  826. }
  827. //else if(KEY_PANEL_MENU==g_ulKeyValue)UISetNextStatus(UIS_MENU_MAIN);
  828. break;
  829. case UIS_CALL_PHONE_OPTION:
  830. CallPhoneOptionResponse();
  831. break;
  832. case UIS_CALL_PHONE_INPUT: //-----电话设置----
  833. CallPhoneInputNumResponse();
  834. break;
  835. case UIS_CALL_PHONE_MODIFY:
  836. CallPhoneInputNewNumResponse();
  837. break;
  838. case UIS_CALL_PHONE_DELETE:
  839. CallPhoneInputDeleNumResponse();
  840. break;
  841. case UIS_MESSAGE_OPTION:
  842. MessageOptionResponse();
  843. break;
  844. case UIS_MESSAGE_READ:
  845. MessageReadResponse();
  846. break;
  847. case UIS_MESSAGE_FORMAT:
  848. MessageFormatResponse();
  849. break;
  850. case UIS_CALL_TO_PHONE:
  851. CallToPhoneNumResponse();
  852. break;
  853. case UIS_MESSAGE_DELE:
  854. MessageDeletResponse();
  855. break;
  856. case UIS_SET_APN: //-----系统设置-------
  857. SetAPNResponse();
  858. break;
  859. case UIS_APN_DETAIL:
  860. SetApnDetailResponse();
  861. break;
  862. case UIS_SET_GPS:
  863. SetGPSResponse();
  864. break;
  865. case UIS_SET_LCD:
  866. SetLCDResponse();
  867. break;
  868. ////////////////////////////////////
  869. case UIS_SET_NET:
  870. SetNetResponse();
  871. break;
  872. //////////////////////////////////
  873. case UIS_UP_APPRICATION_VER:
  874. SetUpAppricationVerResponse();
  875. break;
  876. case UIS_UP_INTERCOM_VER:
  877. SetUpIntercomVerResponse();
  878. break;
  879. // case UIS_SERVER_SHOW:
  880. // SetServerSelResponse();
  881. // break;
  882. case UIS_SET_KEYSound:
  883. SetKeysoundResponse();
  884. break;
  885. case UIS_SET_SOUNDMODE:
  886. SetSoundModeResponse();
  887. break;
  888. case UIS_SET_QUICK_GROUP:
  889. SetQuickGroupResponse();
  890. break;
  891. default:
  892. break;
  893. }
  894. }
  895. /******************************************************
  896. UISetNextStatus
  897. 设置下一个UI状态
  898. *******************************************************/
  899. void UISetNextStatus(unsigned char status)
  900. {
  901. sutUIstatus.LastStatus=sutUIstatus.NextStatus;
  902. sutUIstatus.NextStatus=status;
  903. }
  904. /******************************************************
  905. 显示开机动画
  906. 完整图片 尺寸
  907. logo.bmp 100*59
  908. 子图片 与主图片坐标偏移
  909. logo-down 2,42
  910. logo-g 38,25
  911. logo-h 4,10
  912. logo-i 29,19
  913. logo-o 59,25
  914. logo-s 77,25
  915. logo-up 2,0
  916. *******************************************************/
  917. void ShowBootAnimation(void)
  918. {
  919. int i;
  920. int x,y;
  921. int w,h;
  922. x=30;y=34;//最终整张logo图片的位置
  923. w=100;h=59;//整张图片的尺寸
  924. LCD_BL_HIGH; //改正用户体验
  925. KEY_LED(1);
  926. #if 0
  927. GuiDrawBmpMoving(x+38,0,x+38,y+25,"logo-g.bmp",5);//从上往下移动
  928. GuiDrawBmpMoving(0,y+19,x+29,y+19,"logo-i.bmp",5);//从左往右
  929. GuiShowBmp(x+38,y+25,"logo-g.bmp");
  930. GuiDrawBmpMoving(159-19,y+25,x+59,y+25,"logo-o.bmp",5);//从右往左
  931. GuiDrawBmpMoving(0,y+10,x+4,y+10,"logo-h.bmp",5);//从左往右
  932. GuiShowBmp(x+29,y+19,"logo-i.bmp");
  933. GuiShowBmp(x+38,y+25,"logo-g.bmp");
  934. IWDG_ReloadCounter();//
  935. GuiDrawBmpMoving(159-19,y+25,x+77,y+25,"logo-s.bmp",5);//从右往左
  936. GuiDrawBmpMoving(0,0,x+2,y+0,"logo-up.bmp",5);//从上往下
  937. GuiDrawBmpMoving(159-98,127-17,x+2,y+42,"logo-down.bmp",5);//从下往上
  938. GuiShowBmp(x,y,"logo.bmp");
  939. #else
  940. GuiClearAll();
  941. GuiShowBmp(0,0,"welcome.bmp");
  942. for(i=0;i<400000;i++)
  943. {
  944. if(i%100==0) IWDG_ReloadCounter();
  945. }
  946. #endif
  947. ///////////////////////////////////
  948. // LCD_BL_HIGH;
  949. // sutLcdParam.OnTimeCt=0;
  950. }
  951. /***********************************
  952. 显示信号状态
  953. **********************************/
  954. void ShowSingle(int CSQ)
  955. {
  956. if(sutGpsStatus.PPPStatus == OPEN) GuiShowBmp(0,0+2,"SingleOK.bmp");
  957. else GuiShowBmp(0,0+2,"Single.bmp");
  958. if(CSQ<1 || CSQ==99){
  959. GuiClearRect(7,4,21,14);
  960. }else if(CSQ<8){
  961. GuiDrawVLine(12,14,7,2,COLOR_DEFAULT_BLUE);
  962. GuiClearRect(11,4,21,14);
  963. }else if(CSQ<16){
  964. GuiDrawVLine(12,14,7,2,COLOR_DEFAULT_BLUE);
  965. GuiDrawVLine(9,14,11,2,COLOR_DEFAULT_BLUE);
  966. GuiClearRect(15,4,21,14);
  967. }else if(CSQ<22){
  968. GuiDrawVLine(12,14,7,2,COLOR_DEFAULT_BLUE);
  969. GuiDrawVLine(9,14,11,2,COLOR_DEFAULT_BLUE);
  970. GuiDrawVLine(7,14,15,2,COLOR_DEFAULT_BLUE);
  971. GuiClearRect(19,4,21,14);
  972. }else{
  973. GuiDrawVLine(12,14,7,2,COLOR_DEFAULT_BLUE);
  974. GuiDrawVLine(9,14,11,2,COLOR_DEFAULT_BLUE);
  975. GuiDrawVLine(7,14,15,2,COLOR_DEFAULT_BLUE);
  976. GuiDrawVLine(4,14,19,2,COLOR_DEFAULT_BLUE);
  977. }
  978. //2G-4G 显示
  979. //GuiShowBmp(28,5,"2g.bmp");
  980. }
  981. /************************************************************************
  982. 显示电量
  983. *************************************************************************/
  984. void ShowBatttery(int bat)
  985. {
  986. static unsigned int flashCnt=0;
  987. static unsigned char flag=0;
  988. int x=46;
  989. if(bat<WARN_PWR_LEVEL){//请充电
  990. if(os_time_get()< flashCnt) return;
  991. flashCnt=os_time_get()+80;
  992. if(flag==0)
  993. {
  994. GuiShowBmp(x+41,3,"VBAT1.bmp");
  995. flag=1;
  996. }else{
  997. flag=0;
  998. GuiClearRect(x+41,3,x+41+27,3+12);
  999. }
  1000. //GuiDrawVLine(5,12,64+x,2,COLOR_WARN_RED);
  1001. }
  1002. else if(bat<355){//340<x<=355 1格
  1003. GuiShowBmp(x+41,3,"VBAT1.bmp");
  1004. GuiDrawVLine(5,12,62+x,4,COLOR_DEFAULT_BLUE);
  1005. }
  1006. else if(bat<375){//355<x<=375 2格
  1007. GuiShowBmp(x+41,3,"VBAT1.bmp");
  1008. GuiDrawVLine(5,12,57+x,4,COLOR_DEFAULT_BLUE);
  1009. GuiDrawVLine(5,12,62+x,4,COLOR_DEFAULT_BLUE);
  1010. }
  1011. else if(bat<400){//375<x<=400 3格
  1012. GuiShowBmp(x+41,3,"VBAT1.bmp");
  1013. GuiDrawVLine(5,12,52+x,4,COLOR_DEFAULT_BLUE);
  1014. GuiDrawVLine(5,12,57+x,4,COLOR_DEFAULT_BLUE);
  1015. GuiDrawVLine(5,12,62+x,4,COLOR_DEFAULT_BLUE);
  1016. }
  1017. else{//>=400 4格
  1018. GuiShowBmp(x+41,3,"VBAT1.bmp");
  1019. GuiDrawVLine(5,12,47+x,4,COLOR_DEFAULT_BLUE);
  1020. GuiDrawVLine(5,12,52+x,4,COLOR_DEFAULT_BLUE);
  1021. GuiDrawVLine(5,12,57+x,4,COLOR_DEFAULT_BLUE);
  1022. GuiDrawVLine(5,12,62+x,4,COLOR_DEFAULT_BLUE);
  1023. }
  1024. }
  1025. void ShowTime(void)
  1026. {
  1027. static unsigned char TimeReNewCount;
  1028. static int lastS;
  1029. int time,h,m,s;
  1030. char buf[30];
  1031. if(sutPocStatus.FirstLogined==0) return;
  1032. time = RTC_GetCounter();
  1033. h = time/3600%24;
  1034. m = (time%3600)/60;
  1035. s=0;
  1036. if(TimeFlag)
  1037. {
  1038. s = (time%3600)%60;
  1039. if(lastS!=s)
  1040. {
  1041. g_usModeSTime++;
  1042. if(g_usModeSTime>=60)
  1043. {
  1044. g_usModeSTime=0;
  1045. g_usModeMTime++;
  1046. if(sutPocStatus.Logined)
  1047. {
  1048. if(++TimeReNewCount>=5)
  1049. {//每5分钟获取最新时间
  1050. TimeReNewCount=0;
  1051. TimeFlag=0;
  1052. }
  1053. }
  1054. }
  1055. if(g_usModeMTime>=60)
  1056. {
  1057. g_usModeMTime=0;
  1058. g_usModeHTime++;
  1059. }
  1060. if(g_usModeHTime>=24)
  1061. g_usModeHTime=0;
  1062. }
  1063. }else
  1064. {//CDMA没登陆时使用本地时间,一开机就能显示
  1065. s = time%60;
  1066. g_usModeHTime = h;
  1067. g_usModeMTime = m;
  1068. g_usModeSTime = s;
  1069. }
  1070. if(lastS!=s){
  1071. lastS=s;
  1072. snprintf(buf, sizeof(buf),"%02d:%02d",g_usModeHTime,g_usModeMTime);//-02d"g_usModeMTime,g_usModeSTime
  1073. GuiShowStr(118,0,buf,0x01);
  1074. }
  1075. }
  1076. #if 0
  1077. void ShowGPSICon(void)
  1078. {
  1079. GuiClearRect(30,0,50,20);//30
  1080. if(0== sutGpsInfo.isGpsWork) GuiClearRect(30,0,50,20);//未工作或未检测到
  1081. else
  1082. {//GPS已工作
  1083. if(0 == sutGpsInfo.isGpsValid)
  1084. {//未定位
  1085. if(sutGpsInfo.isGpsAuthOk==0)//未鉴权
  1086. {
  1087. GuiShowBmp(36,0,"GPS1.bmp");
  1088. }else//已鉴权
  1089. {
  1090. GuiShowBmp(36,0,"GPSA.bmp");//已鉴权
  1091. }
  1092. }else
  1093. {//已定位
  1094. if(sutGpsInfo.isGpsAuthOk==0)//未鉴权
  1095. {
  1096. GuiShowBmp(36,0,"GPS1.bmp");
  1097. }else//已鉴权
  1098. {
  1099. GuiShowBmp(36,0,"GPSA.bmp");//已鉴权
  1100. }
  1101. GuiShowBmp(36+10-2,0+2,"GPS2.bmp");//定位辐射放最后
  1102. }
  1103. }
  1104. }
  1105. #else
  1106. void ShowGPSICon(void)
  1107. {
  1108. GuiClearRect(45,0,50,20);//30
  1109. if(0== sutGpsInfo.isGpsWork) GuiClearRect(45,0,75,20);//未工作或未检测到
  1110. else
  1111. {
  1112. //GuiShowBmp(28,0,"3g.bmp");
  1113. //GPS已工作
  1114. if(0 == sutGpsInfo.isGpsValid)
  1115. {//未定位
  1116. if(sutGpsInfo.isGpsAuthOk==0)//未鉴权
  1117. {
  1118. GuiShowBmp(45,0,"GPS1.bmp");
  1119. }else//已鉴权
  1120. {
  1121. GuiShowBmp(45,0,"GPSA.bmp");//已鉴权
  1122. }
  1123. }else
  1124. {//已定位
  1125. if(sutGpsInfo.isGpsAuthOk==0)//未鉴权
  1126. {
  1127. GuiShowBmp(45,0,"GPS1.bmp");
  1128. }else//已鉴权
  1129. {
  1130. GuiShowBmp(45,0,"GPSA.bmp");//已鉴权
  1131. }
  1132. GuiShowBmp(45+10-2,0+2,"GPS2.bmp");//定位辐射放最后
  1133. }
  1134. }
  1135. }
  1136. #endif
  1137. /************************************************************************
  1138. ShowStatusBar
  1139. 显示状态栏
  1140. *************************************************************************/
  1141. void ShowStatusBar(int Update)
  1142. {
  1143. static char batFirstShow=0;
  1144. static uint8_t siHNS;
  1145. static int siCSQ;
  1146. static int siVbat;
  1147. unsigned short usGps;
  1148. static unsigned short susGps;
  1149. static STATUE lastPPPStatus;
  1150. static unsigned int s_netshowvalue;
  1151. if(Update){
  1152. GuiClearRect(0,0,159,15);
  1153. siCSQ=g_iCSQ;
  1154. ShowSingle(g_iCSQ);
  1155. siVbat=g_iVbat;
  1156. ShowGPSICon();
  1157. ShowBatttery(g_iVbat);
  1158. ShowMessageFlag(1);
  1159. ShowTime();
  1160. s_netshowvalue=netshowvalue;
  1161. Show_Net(s_netshowvalue);
  1162. return;
  1163. }
  1164. //2G-4G显示
  1165. if(s_netshowvalue!=netshowvalue){
  1166. s_netshowvalue=netshowvalue;
  1167. Show_Net(s_netshowvalue);
  1168. }
  1169. //信号显示
  1170. if(siCSQ!=g_iCSQ || lastPPPStatus != sutGpsStatus.PPPStatus){
  1171. lastPPPStatus=sutGpsStatus.PPPStatus;
  1172. siCSQ=g_iCSQ;
  1173. ShowSingle(g_iCSQ);
  1174. }
  1175. if(batFirstShow < 100)
  1176. {//开机大概前1秒显示50%电量,之后根据实际显示
  1177. g_iVbat=360;
  1178. batFirstShow++;
  1179. }
  1180. //电量显示
  1181. if(siVbat!=g_iVbat || g_iVbat < WARN_PWR_LEVEL){
  1182. siVbat=g_iVbat;
  1183. ShowBatttery(g_iVbat);
  1184. }
  1185. //消息显示
  1186. ShowMessageFlag(0);
  1187. //GPS显示
  1188. usGps=((unsigned short)sutGpsInfo.isGpsWork<<8) | ((unsigned short)sutGpsInfo.isGpsValid) | ((unsigned short)sutGpsInfo.isGpsAuthOk<<2);
  1189. if(susGps!=usGps ){
  1190. susGps =usGps;
  1191. ShowGPSICon();
  1192. }
  1193. //时间显示
  1194. ShowTime();
  1195. }
  1196. void ShowMessageBox(char *msg)
  1197. {
  1198. char buf[10];
  1199. u16 len,x,y;
  1200. y=LCD_HEIGHT/2;
  1201. GuiClearRect(0,y-20,159,y+20);
  1202. GuiDrawRect(2,y-18,157,y+18,1);
  1203. StrIntercept(buf,msg,18);
  1204. len=GetStrXLen(buf);
  1205. x=(LCD_WIDTH-len)/2;
  1206. GuiShowStr(x,y-8,buf,0x01);
  1207. }
  1208. void ShowNumBox(unsigned short msg)
  1209. {
  1210. char buf[10];
  1211. u16 len,x,y;
  1212. y=LCD_HEIGHT/2; //中间
  1213. GuiClearRect(0,y-20,159,y+20);
  1214. //GuiDrawRect(2,y-6,157,y+16,1); //上面显示要修改的号码 下面显示文字
  1215. GuiDrawRect(2,y-6,130,y+16,1);
  1216. // StrIntercept(buf,(char *)msg,18);
  1217. snprintf(buf, sizeof(buf),"%u",msg);
  1218. len=GetStrXLen(buf);
  1219. //x=(LCD_WIDTH-len)/2;
  1220. GuiShowStr(4,y,buf,0x01);
  1221. }
  1222. /************************************************************************
  1223. ShowButton
  1224. 显示一个按钮
  1225. *************************************************************************/
  1226. void ShowButton(u16 x,u16 y,const char *str)
  1227. {
  1228. int len;
  1229. len=GetStrXLen((char *)str);
  1230. GuiClearRect(x,y,x+len+8,y+20);
  1231. GuiShowStr(x+4,y+2,str,0x01);
  1232. GuiReverseRect(x,y,(x+len+8),(y+16+4));
  1233. }
  1234. void Show_Net(unsigned int s_netshowvalue)
  1235. {
  1236. if(s_netshowvalue==2||s_netshowvalue==3){
  1237. GuiShowBmp(24,2,"2g.bmp");
  1238. }else if(s_netshowvalue==4||s_netshowvalue==5||s_netshowvalue==8){
  1239. GuiShowBmp(24,2,"3g.bmp");
  1240. }else if(s_netshowvalue==9){
  1241. GuiShowBmp(24,2,"4g.bmp");
  1242. }else {
  1243. GuiClearRect(24,2,45,20);
  1244. }
  1245. }