hook.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. }
  30. void HookGroupUserInfo()
  31. {
  32. if(uiAssist.status!=0){
  33. switch(uiAssist.type){
  34. case 0: //
  35. switch(uiAssist.machine){
  36. case 0: //初次
  37. if(SimpleInfoScan(1, 2)){
  38. assistResult=1;
  39. uiAssist.status=0;
  40. }
  41. break;
  42. }
  43. break;
  44. case 1: //上翻
  45. switch(uiAssist.machine){
  46. case 0:
  47. if(SimpleInfoScan(0,0)){
  48. assistResult=1;
  49. uiAssist.status=0;
  50. }
  51. break;
  52. }
  53. break;
  54. case 2: //下翻
  55. switch(uiAssist.machine){
  56. case 0:
  57. if(SimpleInfoScan(0,1)){
  58. assistResult=1;
  59. uiAssist.status=0;
  60. }
  61. break;
  62. }
  63. break;
  64. }
  65. }
  66. }
  67. static unsigned int volTime;
  68. static unsigned char volWorkStatus=0;
  69. #define VOL_BAR_LENGTH 100
  70. #define VOL_HAR_HEIGHT 10
  71. #define VOL_START_X ((GLCD_WIDTH-(VOL_BAR_LENGTH+2)-2)/2)
  72. #define VOL_START_Y (UI_BOTTOM_SHOW_Y-2-(VOL_HAR_HEIGHT+2)-2)
  73. #define VOL_HEIGH 16
  74. static void volTimeDlyStart(unsigned int time){
  75. uTimerStart(&volTime, time);
  76. volWorkStatus=1;
  77. }
  78. void HookVolToutCheck(void){
  79. #if 1
  80. unsigned short x=GLCD_WIDTH/2-16;
  81. unsigned short y=VOL_START_Y+14-16;
  82. if(volWorkStatus==0) return;
  83. if(uTimerExpired(&volTime)==0) return;
  84. volWorkStatus=0;
  85. if(sutUIstatus.Status!=UIS_STANDBY) return;
  86. guiClearRect(x, y, x+16+16, y+VOL_HEIGH, guiGetBackColor());
  87. #else
  88. unsigned short x=VOL_START_X;//102为音量框长度,其中100为有效长度
  89. unsigned short y=VOL_START_Y;//32为音量框高度,其中30为有效高度
  90. if(volWorkStatus==0) return;
  91. if(uTimerExpired(&volTime)==0) return;
  92. volWorkStatus=0;
  93. if(sutUIstatus.Status!=UIS_STANDBY) return;
  94. guiClearRect(x-21, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, guiGetBackColor());
  95. #endif
  96. }
  97. void volUiFlash(unsigned char lev){
  98. #if 1//使用喇叭显示
  99. unsigned short x=GLCD_WIDTH/2-16;
  100. unsigned short y=VOL_START_Y+14-16;
  101. char info[10];
  102. guiClearRect(x, y, x+16+16, y+VOL_HEIGH, guiGetBackColor());
  103. guiShowBmp(x, y, "volume.bmp");
  104. snprintf(info, sizeof(info), "%02d", lev);
  105. guiShowStr(x+16, y+1, info, FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  106. volTimeDlyStart(2000);
  107. #else//使用进度条显示
  108. unsigned short x=VOL_START_X;//102为音量框长度,其中100为有效长度
  109. unsigned short y=VOL_START_Y;//32为音量框高度,其中30为有效高度
  110. char info[10];
  111. guiClearRect(x-21, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, guiGetBackColor());
  112. guiDrawRect(x, y, x+(VOL_BAR_LENGTH+2)+2-1, y+(VOL_HAR_HEIGHT+2)+2, 1, COLOR_BLACK);
  113. x += 2;y += 2;
  114. snprintf(info, sizeof(info), "%d", lev);
  115. guiShowStr(x-strlen(info)*8-5, y-1, info, FONT_MODE_12X12, REVERSED_NO, COLOR_BLACK, guiGetBackColor());
  116. guiFillRect(x, y, x+lev*10-1, y+(VOL_HAR_HEIGHT+0),COLOR_STATUS_BAR);
  117. volTimeDlyStart(2000);
  118. #endif
  119. }