?? ap_message2.s01
字號:
NAME ap_message2(17)
RSEG COM_MSG(0)
RSEG UDATA0(0)
RSEG IDATA0(0)
RSEG CDATA0(0)
PUBLIC EarProtectThreshold
EXTERN ap_get_message
PUBLIC ap_get_message_core
EXTERN ap_handle_hotkey
PUBLIC ap_handle_hotkey_core
PUBLIC ap_message_init
PUBLIC ap_sleep
PUBLIC g_EarProtect_flag
PUBLIC g_charge_counter
EXTERN g_comval
PUBLIC g_decrease_time
PUBLIC g_half_hour_counter
PUBLIC g_light_time
PUBLIC g_rtc_counter
PUBLIC g_sleep_time
PUBLIC g_standby_time
EXTERN sKY_Beep
EXTERN sKY_ChargeGetandSet
EXTERN sKY_CloseBacklight
EXTERN sKY_OpenBacklight
EXTERN ui_run_realtime
EXTERN ui_show_lock
EXTERN ?CLZ80B_4_04_L00
EXTERN ?S_MUL_L02
EXTERN ?C_V_SWITCH_L06
EXTERN ?BANK_CALL_DIRECT_L08
EXTERN ?BANK_FAST_LEAVE_L08
RSEG COM_MSG
ap_message_init:
; 1. /*
; 2. *******************************************************************************
; 3. * ACTOS AP
; 4. * ap common lib message file
; 5. *
; 6. * (c) Copyright, Actions Co,Ld.
; 7. * All Right Reserved
; 8. *
; 9. *******************************************************************************
; 10. */
; 11. #pragma codeseg(COM_MSG)
; 12.
; 13. #include "ap_common.h"
; 14. #define DEBUG
; 15.
; 16. #ifdef EAR_PROTECT
; 17. #define EarProctetTimeTick 60 //30 seconds
; 18. byte g_decrease_time = 0;
; 19. int g_half_hour_counter = 0;
; 20. //int g_autoswitch_counter = 0;
; 21. byte g_EarProtect_flag;
; 22. byte EarProtectThreshold;
; 23. //int g_autoswitch_time;
; 24. #endif
; 25. BYTE g_light_time=0; //關背光時間,0.5秒為單位
; 26. WORD g_sleep_time=0; //睡眠時間,0.5秒為單位
; 27. WORD g_standby_time=0; //自動關機時間,0.5秒為單位
; 28. WORD g_rtc_counter=0; //rtc 消息計數
; 29. BYTE g_charge_counter = 0; //檢測充電狀態的計數器,插上USB就開始檢測第一次
; 30. extern comval_t g_comval;
; 31. //WORD g_ap_event=0; //事件標志
; 32. /*
; 33. char g_ap_message[4]={0, 0, 0, 0}; //ap 消息隊列
; 34. char g_ap_message_index=0; //ap 消息隊列的讀寫指針
; 35. */
; 36.
; 37. /*
; 38. * 對于普通按鍵的處理存在隱患,如果os把普通按鍵的值定義到0x20 以上,
; 39. * ap_get_message() 將不能正確處理, 正確的做法是用9個case, 不用default
; 40. */
; 41. #if Msg_KeyEQ > 0x20 || Msg_KeyMenu > 0x20 || \
; 42. Msg_KeyNext > 0x20 || Msg_KeyLast > 0x20 || \
; 43. Msg_KeyVolAdd > 0x20 || Msg_KeyVolSub > 0x20 || \
; 44. Msg_KeyPlayPause > 0x20 || Msg_KeyREC > 0x20 || Msg_KeyLoop > 0x20
; 45.
; 46. #error os define key greater than 0x20
; 47. #endif
; 48.
; 49. /*
; 50. ********************************************************************************
; 51. * Description : 初始化消息處理
; 52. *
; 53. * Arguments : comval, 系統設定值, =null 表示只初始化內部計數器
; 54. *
; 55. * Returns :
; 56. *
; 57. * Notes :
; 58. *
; 59. ********************************************************************************
; 60. */
; 61. void ap_message_init(const comval_t *comval)
; 62. {
PUSH BC
PUSH IX
PUSH DE
POP IX
; 63.
; 64. if(comval != NULL)
LD A,E
OR D
JR Z,?0005
?0004:
; 65. {
; 66. g_light_time = comval->LightTime * 2;
LD A,(IX+9)
ADD A,A
LD (g_light_time),A
; 67.
; 68. g_sleep_time = comval->SleepTime * 60 * 2;
LD C,(IX+11)
LD B,0
LD DE,60
CALL LWRD ?S_MUL_L02
EX DE,HL
ADD HL,HL
LD (g_sleep_time),HL
; 69.
; 70. g_standby_time = comval->StandbyTime * 2;
LD L,(IX+10)
LD H,B
ADD HL,HL
LD (g_standby_time),HL
; 71. #ifdef EAR_PROTECT
; 72. g_EarProtect_flag = comval->EarProtect_flag;
LD A,(IX+24)
LD (g_EarProtect_flag),A
; 73. EarProtectThreshold = comval->EarProtectThreshold;
LD A,(IX+25)
LD (EarProtectThreshold),A
?0005:
; 74. //g_autoswitch_time = comval->auto_switchoff_time * 60 * 2;
; 75. #endif
; 76. }
; 77.
; 78. g_rtc_counter = 0;
LD HL,0
LD (g_rtc_counter),HL
; 79. }
POP IX
POP BC
JP LWRD ?BANK_FAST_LEAVE_L08
ap_get_message_core:
; 80.
; 81.
; 82. /*
; 83. ********************************************************************************
; 84. * Description : 處理系統消息, 返回按鍵消息, 同時負責開/關背光
; 85. *
; 86. * Arguments : key, 系統消息
; 87. *
; 88. * Returns : 返回ap能夠識別的消息, 如果沒有系統消息, 返回 AP_KEY_NULL
; 89. *
; 90. * Notes :
; 91.
; 92. * 按鍵時序:
; 93. * 0.....1.2....1.5........... (s)
; 94. * key long hold up (>1.2s)
; 95. * key up (<1.2s)
; 96. *
; 97. * key rate: 0.3s
; 98. *
; 99. ********************************************************************************
; 100. */
; 101. char ap_get_message_core(char key)
; 102. {
PUSH BC
PUSH IX
LD IX,0
ADD IX,SP
PUSH DE
PUSH AF
; 103. static WORD key_count=0; //當前按鍵消息發生的次數
; 104. static char key_value=Msg_KeyNull; //當前按鍵的值
; 105. #ifdef EAR_PROTECT
; 106. char tempVolume;
; 107. bool counter_flag = FALSE;
; 108.
; 109. tempVolume = input8(0x99)&0x1f;
IN A,(153)
AND 31
LD (IX-4),A
; 110. if (tempVolume > EarProtectThreshold)
LD B,A
LD A,(EarProtectThreshold)
CP B
JR NC,?0009
?0008:
; 111. {
; 112. counter_flag = TRUE;
LD (IX-3),1
; 113. }
; 114. else
JR ?0010
?0009:
; 115. {
; 116. counter_flag = FALSE;
LD (IX-3),0
?0010:
; 117. }
; 118.
; 119. if ( g_EarProtect_flag && (tempVolume > EarProtectThreshold) && (g_decrease_time == EarProctetTimeTick) )
LD A,(g_EarProtect_flag)
OR A
JR Z,?0012
LD A,(EarProtectThreshold)
CP B
JR NC,?0012
LD A,(g_decrease_time)
CP 60
JR NZ,?0012
?0014:
?0013:
?0011:
; 120. {
; 121. output8(0x99, input(0x99)&0xe0|(tempVolume-1));
LD BC,153
IN D,(C)
LD A,D
AND 224
PUSH AF
LD A,(IX-4)
ADD A,255
LD B,A
POP AF
OR B
OUT (153),A
; 122. g_decrease_time = 0;
XOR A
LD (g_decrease_time),A
?0012:
; 123. }
; 124. if ( g_EarProtect_flag && (g_half_hour_counter == 7200) )
LD A,(g_EarProtect_flag)
OR A
JR Z,?0016
LD HL,7200
LD BC,(g_half_hour_counter)
SBC HL,BC
JR NZ,?0016
?0018:
?0017:
?0015:
; 125. {
; 126. if (tempVolume > 10)
LD A,10
CP (IX-4)
JR NC,?0020
?0019:
; 127. {
; 128. output8(0x99, input(0x99)&0xe0|(tempVolume-1));
LD BC,153
IN D,(C)
LD A,D
AND 224
PUSH AF
LD A,(IX-4)
ADD A,255
LD B,A
POP AF
OR B
OUT (153),A
?0020:
; 129. }
; 130. g_half_hour_counter = 0;
LD (g_half_hour_counter),HL
?0016:
; 131. }
; 132. #endif
; 133.
; 134. //和上次的一樣
; 135. if(key == key_value)
LD A,(?0007)
LD B,A
LD A,E
CP B
JR NZ,?0022
?0021:
; 136. {
; 137. // if(g_comval.KeyTone) //key tone add by mzh 2007.3.14
; 138. // sKY_Beep(g_comval.KeyTone);
; 139. //開背光
; 140. if(g_light_time != 0) sKY_OpenBacklight();
LD A,(g_light_time)
OR A
JR Z,?0024
?0023:
CALL LWRD sKY_OpenBacklight
?0024:
; 141.
; 142. g_rtc_counter = 0;
LD HL,0
LD (g_rtc_counter),HL
; 143. key_count++;
LD HL,(?0006)
INC HL
LD (?0006),HL
; 144. //key rate: ...0.3...0.3...0.3...0.3
; 145. if(key_count == 4) key |= AP_KEY_LONG; //=1.2s
LD A,4
XOR L
OR H
JR NZ,?0026
?0025:
SET 7,(IX-2)
JP LWRD ?0089
?0026:
; 146. else if(key_count > 4) key |= AP_KEY_HOLD;
LD C,L
LD B,H
LD HL,4
SBC HL,BC
JP NC,?0089
?0028:
SET 6,(IX-2)
?0029:
?0027:
; 147. return key;
JP LWRD ?0089
; 148. }
?0022:
; 149.
; 150. switch( key )
CALL LWRD ?C_V_SWITCH_L06
DEFW 12
DEFB 0
DEFB 48
DEFB 49
DEFB 50
DEFB 52
DEFB 128
DEFB 129
DEFB 130
DEFB 145
DEFB 146
DEFB 176
DEFB 177
DEFW ?0085
DEFW ?0084
DEFW ?0083
DEFW ?0078
DEFW ?0069
DEFW ?0075
DEFW ?0032
DEFW ?0032
DEFW ?0080
DEFW ?0082
DEFW ?0031
DEFW ?0031
DEFW ?0080
?0031:
; 151. {
; 152. case Msg_KeyLongUp:
; 153. case Msg_KeyShortUp:
; 154. key_count = 0;
LD HL,0
LD (?0006),HL
; 155. g_rtc_counter = 0;
LD (g_rtc_counter),HL
; 156. key = key_value | AP_KEY_UP;
LD A,B
SET 5,A
LD (IX-2),A
; 157. key_value=key; //add by mzh 2007.3.14
LD (?0007),A
; 158. break;
JP LWRD ?0089
?0032:
; 159.
; 160.
; 161. case MSG_RTC2HZ: //rtc
; 162. case MSG_BAT_V_CHG: //charging & rtc
; 163. g_rtc_counter++;
LD HL,(g_rtc_counter)
INC HL
LD (g_rtc_counter),HL
; 164.
; 165.
; 166. if(g_comval.BatteryType != BATT_TYPE_LITHIUM)
LD A,(g_comval+15)
DEC A
DEC A
IN A,(142)
JR Z,?0034
?0033:
; 167. {
; 168. if(((input8(0x8e)&0x80)==0)&&((input8(0x8f)&0x3f)<= 0x09)) //check low battery
BIT 7,A
JR NZ,?0041
IN A,(143)
AND 63
LD B,A
LD A,9
CP B
JR C,?0041
?0038:
?0037:
?0035:
; 169. {
; 170. return AP_MSG_LOW_POWER;
JR ?0118
; 171. }
?0036:
; 172. }
; 173. else
?0034:
; 174. {
; 175. if(((input8(0x8e)&0x80)==0)&&((input8(0x8f)&0x3f)<= 0x12)) //check low battery
BIT 7,A
JR NZ,?0041
IN A,(143)
AND 63
LD B,A
LD A,18
CP B
JR NC,?0118
?0043:
?0042:
?0040:
; 176. {
; 177. return AP_MSG_LOW_POWER;
; 178. }
?0041:
?0039:
; 179. }
; 180.
; 181. #ifdef EAR_PROTECT
; 182. if (counter_flag)
XOR A
OR (IX-3)
JR Z,?0045
?0044:
; 183. {
; 184. g_decrease_time++;
LD HL,g_decrease_time
INC (HL)
?0045:
; 185. }
; 186. g_half_hour_counter++;
LD HL,(g_half_hour_counter)
INC HL
LD (g_half_hour_counter),HL
; 187. //g_autoswitch_counter++;
; 188. #endif
; 189. if((g_light_time != 0) && (g_rtc_counter >= g_light_time)) //自動關背光
LD A,(g_light_time)
OR A
JR Z,?0047
LD C,A
LD B,0
LD HL,(g_rtc_counter)
SBC HL,BC
JR C,?0047
?0049:
?0048:
?0046:
; 190. {
; 191. //關背光
; 192. sKY_CloseBacklight();
CALL LWRD sKY_CloseBacklight
?0047:
; 193. }
; 194.
; 195. if(g_sleep_time != 0 && g_rtc_counter == g_sleep_time) //睡眠
LD HL,(g_sleep_time)
LD A,L
OR H
JR Z,?0051
LD BC,(g_rtc_counter)
SBC HL,BC
JR NZ,?0051
?0053:
?0052:
?0050:
; 196. {
; 197. return AP_MSG_SLEEP;
?0118:
LD L,31
; 198. }
JP LWRD ?0090
?0051:
; 199.
; 200. if(g_standby_time != 0 && g_rtc_counter == g_standby_time) //自動關機
LD HL,(g_standby_time)
LD A,L
OR H
JR Z,?0055
LD BC,(g_rtc_counter)
SBC HL,BC
JR NZ,?0055
?0057:
?0056:
?0054:
; 201. {
; 202. return AP_MSG_STANDBY;
LD L,29
; 203. }
JP LWRD ?0090
?0055:
; 204. #ifdef EAR_PROTECT
; 205. // if(g_autoswitch_time != 0 && g_autoswitch_counter == g_autoswitch_time) //自動關機
; 206. // {
; 207. // return AP_MSG_FORCE_STANDBY;
; 208. // }
; 209. #endif
; 210.
; 211. if( (g_rtc_counter % 16) == 0 )
LD HL,(g_rtc_counter)
LD A,L
AND 15
JR NZ,?0059
?0058:
; 212. {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -