hook.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. #include "includes.h"
  2. ASSIST_DEF uiAssist;
  3. unsigned char assistResult;
  4. void uTimerStart(unsigned int *timerId, unsigned int dlyTime){
  5. *timerId=getAppTick()+dlyTime/KEY_TIMER_TICK;
  6. }
  7. char uTimerExpired(unsigned int *timerId){
  8. return ((getAppTick()>*timerId)?1:0);
  9. }
  10. void UiassistStart(unsigned char type){
  11. uiAssist.type=type;
  12. uiAssist.machine=0;
  13. uiAssist.status=1;
  14. }
  15. void UiassistEnd(unsigned char type){
  16. uiAssist.type=type;
  17. uiAssist.machine=0;
  18. uiAssist.status=0;
  19. assistResult=0;
  20. }
  21. unsigned char getAssistResult(void){
  22. unsigned char ret=0;
  23. ret=assistResult;
  24. if(assistResult) assistResult=0;
  25. return ret;
  26. }
  27. char SimpleInfoScan(unsigned char firstIn,unsigned char direction)
  28. {
  29. static char first=1;
  30. static unsigned char machine;
  31. static unsigned int timer;
  32. char buf[60];//30
  33. char ret =0;
  34. if(firstIn && first){
  35. sutPocStatus.handleIndex=0;//渭卤?掳貌3
  36. machine=0;
  37. first=0;
  38. ret=0;
  39. }
  40. switch(machine){
  41. case 0:
  42. if(sutUIstatus.Status==UIS_MENU_GROUP_SEL){
  43. snprintf(buf, sizeof(buf),"AT+POC=0D00000000000100000000\r\n");
  44. }
  45. else if(sutUIstatus.Status==UIS_MENU_USER_SEL||sutUIstatus.Status==UIS_MENU_SZ_YAOYUN||sutUIstatus.Status==UIS_MENU_SZ_YAOYBI) {
  46. snprintf(buf, sizeof(buf),"AT+POC=3B0000%08x\r\n",sutPocStatus.LocalGroup.ID);//?猫?眉D?脳眉锚y
  47. }else if(sutUIstatus.Status==UIS_MENU_FRIEND_SEL) {
  48. snprintf(buf, sizeof(buf),"AT+POC=0D00000000000100000000\r\n");
  49. }
  50. msgAtSend(buf);
  51. MSG_INFO(1,buf);
  52. sutPocStatus.ListUpdate=0;
  53. sutPocStatus.ListFillIndex=0;
  54. sutPocStatus.ListDetailValid=0;
  55. uTimerStart(&timer, 5000);//500
  56. machine=1;
  57. break;
  58. case 1:
  59. if(sutPocStatus.ListUpdate || uTimerExpired(&timer) ){
  60. if(sutPocStatus.ListCurOnlineNum<=0){
  61. sutPocStatus.ListFillIndex=0;
  62. MSG_INFO(1,"sutPocStatus.ListUpdate==%d,ListCurOnlineNum==%d\r\n",sutPocStatus.ListUpdate,sutPocStatus.ListCurOnlineNum);
  63. goto QUIT_FUNCTION;
  64. }
  65. machine=2;
  66. }
  67. break;
  68. case 2:
  69. if(firstIn!=1){
  70. if(direction==1){
  71. sutPocStatus.handleIndex ++;
  72. if(sutPocStatus.handleIndex>sutPocStatus.ListCurOnlineNum/5){
  73. sutPocStatus.handleIndex=0;
  74. }
  75. if(sutPocStatus.ListCurOnlineNum%5==0){
  76. if(sutPocStatus.handleIndex==sutPocStatus.ListCurOnlineNum/5)sutPocStatus.handleIndex=0;
  77. }
  78. }
  79. else {
  80. if(sutPocStatus.handleIndex>0)sutPocStatus.handleIndex--;
  81. else if(sutPocStatus.handleIndex==0){
  82. if(sutPocStatus.ListCurOnlineNum%5==0)sutPocStatus.handleIndex=(sutPocStatus.ListCurOnlineNum/5)-1;
  83. else sutPocStatus.handleIndex=sutPocStatus.ListCurOnlineNum/5;
  84. MSG_INFO(1,"sutPocStatus.ListCurOnlineNum===%d,sutPocStatus.handleIndex==%d\r\n",sutPocStatus.ListCurOnlineNum,sutPocStatus.handleIndex);
  85. }
  86. }
  87. }
  88. /*
  89. ????2霉脳梅?????篓 ?陇?谩?渭sutPocStatus.ExceptionReadNum
  90. */
  91. if((sutPocStatus.handleIndex+1)*5 >sutPocStatus.ListCurOnlineNum){ //3?1y 锚脳貌3 +1
  92. snprintf(buf, sizeof(buf), "over:%d",sutPocStatus.handleIndex);
  93. MSG_INFO(1, buf);
  94. if(sutPocStatus.ListCurOnlineNum%5==0)sutPocStatus.ExceptionReadNum=5;
  95. else sutPocStatus.ExceptionReadNum=sutPocStatus.ListCurOnlineNum%5;
  96. } else{
  97. sutPocStatus.ExceptionReadNum=5; //??铆篓?茅?? 5??
  98. }
  99. sutPocStatus.ListFillIndex=0;
  100. machine=3;
  101. break;
  102. case 3:
  103. sutPocStatus.ListGetOneFlag=0;
  104. if(sutUIstatus.Status==UIS_MENU_GROUP_SEL){
  105. snprintf(buf, sizeof(buf), "AT+POC=0D000000000005%08x\r\n",sutPocStatus.handleIndex*5+1);
  106. }
  107. else if(sutUIstatus.Status==UIS_MENU_USER_SEL||sutUIstatus.Status==UIS_MENU_SZ_YAOYUN||sutUIstatus.Status==UIS_MENU_SZ_YAOYBI){
  108. snprintf(buf, sizeof(buf), "AT+POC=130000%08x00000005%08x\r\n",sutPocStatus.LocalGroup.ID,sutPocStatus.handleIndex*5);
  109. }else if(sutUIstatus.Status==UIS_MENU_FRIEND_SEL){
  110. snprintf(buf, sizeof(buf), "AT+POC=0E00000000000000000005%08x\r\n",sutPocStatus.handleIndex*5);
  111. }
  112. msgAtSend(buf);
  113. MSG_INFO(1, buf);
  114. uTimerStart(&timer, 3000);//2000
  115. machine=4;
  116. break;
  117. case 4:
  118. if(sutPocStatus.ListGetOneFlag){
  119. machine=5;
  120. }
  121. if(uTimerExpired(&timer)){
  122. machine=5;
  123. }
  124. break;
  125. case 5:
  126. QUIT_FUNCTION:
  127. first=1;
  128. //guiClearRect(0, 40, GLCD_WIDTH-1, GLCD_HEIGHT-32,guiGetBackColor());
  129. sutPocStatus.ListGetOneFlag=0;
  130. machine=0;//
  131. return 1;
  132. break;
  133. }
  134. return ret;
  135. }
  136. void HookGroupUserInfo()
  137. {
  138. if(uiAssist.status!=0){
  139. switch(uiAssist.type){
  140. case 0: //
  141. switch(uiAssist.machine){
  142. case 0:
  143. if(SimpleInfoScan(1, 2)){//
  144. //printf("??è?3é1|á?---\r\n");
  145. assistResult=1;
  146. uiAssist.status=0;
  147. }
  148. break;
  149. }
  150. break;
  151. case 1: //é?·-
  152. switch(uiAssist.machine){
  153. case 0:
  154. if(SimpleInfoScan(0,0)){
  155. assistResult=1;
  156. uiAssist.status=0;
  157. }
  158. break;
  159. }
  160. break;
  161. case 2: //??·-
  162. switch(uiAssist.machine){
  163. case 0:
  164. if(SimpleInfoScan(0,1)){
  165. assistResult=1;
  166. uiAssist.status=0;
  167. }
  168. break;
  169. }
  170. break;
  171. }
  172. }
  173. }
  174. static unsigned int volTime;
  175. static unsigned char volWorkStatus=0;
  176. #define VOL_BAR_LENGTH 100
  177. #define VOL_HAR_HEIGHT 10
  178. #define VOL_START_X ((GLCD_WIDTH-(VOL_BAR_LENGTH+2)-2)/2)
  179. #define VOL_START_Y (UI_BOTTOM_SHOW_Y-2-(VOL_HAR_HEIGHT+2)-2)
  180. #define VOL_HEIGH 16
  181. static void volTimeDlyStart(unsigned int time){
  182. uTimerStart(&volTime, time);
  183. volWorkStatus=1;
  184. }
  185. void HookVolToutCheck(void){
  186. #if 1
  187. unsigned short x=GLCD_WIDTH/2-16+3;
  188. unsigned short y=VOL_START_Y-2;//VOL_START_Y+14;
  189. if(volWorkStatus==0) return;
  190. if(uTimerExpired(&volTime)==0) return;
  191. volWorkStatus=0;
  192. if(sutUIstatus.Status!=UIS_STANDBY) return;
  193. guiClearRect(x, y, x+16+16, y+VOL_HEIGH, guiGetBackColor());
  194. #else
  195. unsigned short x=VOL_START_X;//102为音量框长度,其中100为有效长度
  196. unsigned short y=VOL_START_Y;//32为音量框高度,其中30为有效高度
  197. if(volWorkStatus==0) return;
  198. if(uTimerExpired(&volTime)==0) return;
  199. volWorkStatus=0;
  200. if(sutUIstatus.Status!=UIS_STANDBY) return;
  201. guiClearRect(x-21, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, guiGetBackColor());
  202. #endif
  203. }
  204. void volUiFlash(unsigned char lev){
  205. #if 1//使用喇叭显示
  206. unsigned short x=GLCD_WIDTH/2-16+3;
  207. unsigned short y=VOL_START_Y-2;//VOL_START_Y+14;
  208. char info[10];
  209. guiClearRect(x, y, x+16+16, y+VOL_HEIGH, guiGetBackColor());
  210. guiShowBmp(x, y, "volume.bmp");
  211. snprintf(info, sizeof(info), "%d", lev);
  212. guiShowStr(x+16, y+1, info, FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  213. volTimeDlyStart(2000);
  214. #else//使用进度条显示
  215. unsigned short x=VOL_START_X;//102为音量框长度,其中100为有效长度
  216. unsigned short y=VOL_START_Y;//32为音量框高度,其中30为有效高度
  217. char info[10];
  218. guiClearRect(x-21, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, guiGetBackColor());
  219. guiDrawRect(x, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, 1, COLOR_BLACK);
  220. x += 2;y += 2;
  221. snprintf(info, sizeof(info), "%d", lev);
  222. guiShowStr(x-strlen(info)*8-5, y-1, info, FONT_MODE_16X16, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  223. guiFillRect(x, y, x+lev*10-1, y+(VOL_HAR_HEIGHT+0),COLOR_STATUS_BAR);
  224. volTimeDlyStart(2000);
  225. #endif
  226. }