hook.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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[40];//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=3D0000\r\n");
  44. }
  45. else {
  46. snprintf(buf, sizeof(buf),"AT+POC=3E0000\r\n");
  47. }
  48. msgAtSend(buf);
  49. MSG_INFO(1,buf);
  50. sutPocStatus.ListUpdate=0;
  51. sutPocStatus.ListFillIndex=0;
  52. sutPocStatus.ListDetailValid=0;
  53. uTimerStart(&timer, 5000);//500
  54. machine=1;
  55. break;
  56. case 1:
  57. if(sutPocStatus.ListUpdate || uTimerExpired(&timer) ){
  58. if(sutPocStatus.ListCurOnlineNum<=0){
  59. sutPocStatus.ListFillIndex=0;
  60. MSG_INFO(1,"sutPocStatus.ListUpdate==%d,ListCurOnlineNum==%d\r\n",sutPocStatus.ListUpdate,sutPocStatus.ListCurOnlineNum);
  61. goto QUIT_FUNCTION;
  62. }
  63. machine=2;
  64. }
  65. break;
  66. case 2:
  67. if(firstIn!=1){
  68. if(direction==1){
  69. sutPocStatus.handleIndex ++;
  70. if(sutPocStatus.handleIndex>sutPocStatus.ListCurOnlineNum/5){
  71. sutPocStatus.handleIndex=0;
  72. }
  73. if(sutPocStatus.ListCurOnlineNum%5==0){
  74. if(sutPocStatus.handleIndex==sutPocStatus.ListCurOnlineNum/5)sutPocStatus.handleIndex=0;
  75. }
  76. }
  77. else {
  78. if(sutPocStatus.handleIndex>0)sutPocStatus.handleIndex--;
  79. else if(sutPocStatus.handleIndex==0){
  80. if(sutPocStatus.ListCurOnlineNum%5==0)sutPocStatus.handleIndex=(sutPocStatus.ListCurOnlineNum/5)-1;
  81. else sutPocStatus.handleIndex=sutPocStatus.ListCurOnlineNum/5;
  82. MSG_INFO(1,"sutPocStatus.ListCurOnlineNum===%d,sutPocStatus.handleIndex==%d\r\n",sutPocStatus.ListCurOnlineNum,sutPocStatus.handleIndex);
  83. }
  84. }
  85. }
  86. /*
  87. ????2ù×÷?????¨ ?¤?á?μsutPocStatus.ExceptionReadNum
  88. */
  89. if((sutPocStatus.handleIndex+1)*5 >sutPocStatus.ListCurOnlineNum){ //3?1y ê×ò3 +1
  90. snprintf(buf, sizeof(buf), "over:%d",sutPocStatus.handleIndex);
  91. MSG_INFO(1, buf);
  92. if(sutPocStatus.ListCurOnlineNum%5==0)sutPocStatus.ExceptionReadNum=5;
  93. else sutPocStatus.ExceptionReadNum=sutPocStatus.ListCurOnlineNum%5;
  94. } else{
  95. sutPocStatus.ExceptionReadNum=5; //??í¨?é?? 5??
  96. }
  97. sutPocStatus.ListFillIndex=0;
  98. machine=3;
  99. break;
  100. case 3:
  101. sutPocStatus.ListGetOneFlag=0;
  102. if(sutUIstatus.Status==UIS_MENU_GROUP_SEL){
  103. snprintf(buf, sizeof(buf), "AT+POC=1D0000%04x0005\r\n",sutPocStatus.handleIndex*5);
  104. }
  105. else {
  106. snprintf(buf, sizeof(buf), "AT+POC=1E0000%04x0005\r\n",sutPocStatus.handleIndex*5);
  107. }
  108. msgAtSend(buf);
  109. uTimerStart(&timer, 2000);
  110. machine=4;
  111. break;
  112. case 4:
  113. if(sutPocStatus.ListGetOneFlag){
  114. machine=5;
  115. }
  116. if(uTimerExpired(&timer)){
  117. machine=5;
  118. }
  119. break;
  120. case 5:
  121. QUIT_FUNCTION:
  122. first=1;
  123. guiClearRect(0, 40, GLCD_WIDTH-1, GLCD_HEIGHT-32,guiGetBackColor());
  124. machine=0;//
  125. return 1;
  126. break;
  127. }
  128. return ret;
  129. }
  130. void HookGroupUserInfo()
  131. {
  132. if(uiAssist.status!=0){
  133. switch(uiAssist.type){
  134. case 0: //
  135. switch(uiAssist.machine){
  136. case 0:
  137. if(SimpleInfoScan(1, 2)){//
  138. //printf("??è?3é1|á?---\r\n");
  139. assistResult=1;
  140. uiAssist.status=0;
  141. }
  142. break;
  143. }
  144. break;
  145. case 1: //é?·-
  146. switch(uiAssist.machine){
  147. case 0:
  148. if(SimpleInfoScan(0,0)){
  149. assistResult=1;
  150. uiAssist.status=0;
  151. }
  152. break;
  153. }
  154. break;
  155. case 2: //??·-
  156. switch(uiAssist.machine){
  157. case 0:
  158. if(SimpleInfoScan(0,1)){
  159. assistResult=1;
  160. uiAssist.status=0;
  161. }
  162. break;
  163. }
  164. break;
  165. }
  166. }
  167. }
  168. static unsigned int volTime;
  169. static unsigned char volWorkStatus=0;
  170. #define VOL_BAR_LENGTH 100
  171. #define VOL_HAR_HEIGHT 10
  172. #define VOL_START_X ((GLCD_WIDTH-(VOL_BAR_LENGTH+2)-2)/2)
  173. #define VOL_START_Y (UI_BOTTOM_SHOW_Y-2-(VOL_HAR_HEIGHT+2)-2)
  174. static void volTimeDlyStart(unsigned int time){
  175. uTimerStart(&volTime, time);
  176. volWorkStatus=1;
  177. }
  178. void HookVolToutCheck(void){
  179. unsigned short x=VOL_START_X;//102为音量框长度,其中100为有效长度
  180. unsigned short y=VOL_START_Y;//32为音量框高度,其中30为有效高度
  181. if(volWorkStatus==0) return;
  182. if(uTimerExpired(&volTime)==0) return;
  183. volWorkStatus=0;
  184. if(sutUIstatus.Status!=UIS_STANDBY) return;
  185. guiClearRect(x, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, guiGetBackColor());
  186. }
  187. void volUiFlash(unsigned char lev){
  188. unsigned short x=VOL_START_X;//102为音量框长度,其中100为有效长度
  189. unsigned short y=VOL_START_Y;//32为音量框高度,其中30为有效高度
  190. guiClearRect(x, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, guiGetBackColor());
  191. guiDrawRect(x, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, 1, COLOR_BLACK);
  192. x += 2;y += 2;
  193. guiFillRect(x, y, x+lev*10-1, y+(VOL_HAR_HEIGHT+0),COLOR_STATUS_BAR);
  194. volTimeDlyStart(1000);
  195. }