📄 keypad.lst
字号:
C51 COMPILER V7.06 KEYPAD 06/16/2005 10:05:41 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE KEYPAD
OBJECT MODULE PLACED IN F:\T100_C~1\HUI_CH~1\铁将军\SIMULA~2\KEYPAD.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE F:\T100_C~1\HUI_CH~1\铁将军\SIMULA~2\KEYPAD.C DB SB OE
stmt level source
1 //---------------------------------------------------------------------------
2 // Terawins Inc. Company Confidential Strictly Private
3 //
4 // $Archive: Keypad.c $
5 // $Revision: 0.01 $
6 // $Author: jwang $
7 // $Date: 2002/06/19 23:49:23 $
8 //
9 // --------------------------------------------------------------------------
10 // >>>>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
11 // --------------------------------------------------------------------------
12 // Copyright 2002 (c) Terawins Inc.
13 // This is an unpublished work.
14 // --------------------------------------------------------------------------
15 #include "reg51.h"
16 #include "common.h"
17 #include "System.h"
18 #include "Struct.h"
19 #include "Keypad.h"
20 #include "TW101Reg.h"
21 #include "OSDDraw.h"
22 #include "OSDCtrl.h"
23 #include "TwoWire.h"
24 #include "Display.h"
25 #include "T101_Util.h"
26
27 extern void CVBS_S1(void);
28 extern void CVBS_S2(void);
29 extern void CVBS_S3(void);
30 extern void CVBS_S4(void);
31 extern void SVideo_S(void);
32
33
34 #ifdef T515
void switch_T515(uCHAR);
#endif
37
38
39 #ifdef TIMER0
40 extern void Timer0Reset(void);
41 extern void Timer0Stop(void);
42 extern void Timer0Start(void);
43 #endif
44
45
46 extern bit m_bKyPowerOn;
47
48 typedef struct tag_sKEYPAD_FLD
49 {
50 uCHAR cAddress; // Address of field
51 uCHAR cMask; // Mask for field after shifted right
52 uCHAR cFlagsShift; // Flags & Shift byte:
53 // [7] Type: 1=external, 0=internal
54 // [6] Polarity: 1=high true, 0=low true
55 // [4] Shift direction: 1=left, 0=right
C51 COMPILER V7.06 KEYPAD 06/16/2005 10:05:41 PAGE 2
56 // [2:0] Shift to Right Justify
57 } sKEYPADFLD;
58
59 #define nKEYFLDS 1
60
61 sKEYPADFLD code sKeyFlds={
62 //PORT MASK FLAGS/SHIFT
63 KEYPORT2, 0x3f, 0x00
64 };
65
66 uCHAR idata m_cCurreKey;
67 uCHAR idata m_cPreKey;
68 uWORD idata m_wAccelPollCnt;
69 uCHAR idata m_cItem;
70
71 extern uCHAR idata m_cTV_Num;
72 extern bit m_bTV_Num_Bits;
73
74 extern bit m_bFactryReady;
75 extern bit m_bFactryMode;
76 extern uCHAR m_cFactryCnt;
77
78 extern bit m_bRelease;
79 extern bit m_bChipPowerOn;
80 extern bit m_bKyBlocked;
81 extern uCHAR idata m_cOSDEvent;
82 extern uCHAR idata m_cOSDFunc;
83 extern uCHAR idata m_cSource;
84
85 extern uWORD idata m_wBuff[3];
86 extern uCHAR idata m_cBuff[5];
87 extern uDWORD m_dwBuff[2];
88 extern uCHAR idata m_cScaleratio;
89 extern uWORD m_wHRes;
90 extern uWORD m_wVRes;
91 extern uWORD idata m_wVTotal;
92 extern uCHAR idata m_cStandard;
93 void kyKeypadInit(void)
94 {
95 1 m_wAccelPollCnt=0;
96 1 m_cCurreKey=m_cPreKey=0xFF;
97 1 m_cOSDEvent=0;
98 1 m_cOSDFunc=0;
99 1 m_cItem=1;
100 1 }
101
102 void kyKeypad(void)
103 {
104 1 if(kyKeypadScan())
105 1 {
106 2 Timer0Reset();
107 2 kyFindFunc ();
108 2 twdDelay (8);
109 2 }
110 1 else
111 1 {
112 2 m_cPreKey=m_cCurreKey;
113 2 }
114 1 }
115
116 bit kyKeypadScan(void)
117 {
C51 COMPILER V7.06 KEYPAD 06/16/2005 10:05:41 PAGE 3
118 1 uCHAR cTemp;
119 1 while(1)
120 1 {
121 2 cTemp=ReadPort();
122 2 m_cCurreKey=sKeyFlds.cMask&(0xFF-cTemp);
123 2 #if 1
124 2 if(m_cCurreKey==kySOURCE || m_cCurreKey==kyMENU || m_cCurreKey==kyPOWER)
125 2 {
126 3 if(!m_bRelease)
127 3 {
128 4 m_bRelease=1;
129 4 return 1;
130 4 }
131 3 }
132 2 else
133 2 {
134 3 m_bRelease=0;
135 3 if(m_cCurreKey)
136 3 return 1;
137 3 if(!m_cCurreKey) //no key pressed
138 3 return 0;
139 3 }
140 2 #else
if(m_cCurreKey==m_cPreKey)
return 0;
else
return 1;
#endif
146 2 }
147 1 }
148
149 void kyFindFunc(void)
150 {
151 1 #if 1
152 1 if(m_cCurreKey==m_cPreKey)
153 1 {
154 2 if(!kyIncPollCount())
155 2 {
156 3 if(kyFindEvent())
157 3 OSDEventMgr();
158 3 }
159 2 }
160 1 else
161 1 {
162 2 if(kyFindEvent())
163 2 {
164 3 if(m_cOSDEvent!=FUNCOUNT)
165 3 OSDEventMgr();
166 3 m_cPreKey = m_cCurreKey;
167 3 m_wAccelPollCnt = 0;
168 3 kyIncPollCount();
169 3 }
170 2 }
171 1 #else
kyFindEvent();
#endif
174 1 }
175
176 uCHAR ReadPort(void)
177 {
178 1 uCHAR cKey;
179 1 switch(sKeyFlds.cAddress){
C51 COMPILER V7.06 KEYPAD 06/16/2005 10:05:41 PAGE 4
180 2 case 0: cKey=P0; break;
181 2 case 1: cKey=P1; break;
182 2 case 2: cKey=P2; break;
183 2 case 3: cKey=P3; break;
184 2 }
185 1 return cKey;
186 1 }
187
188
189 extern bit m_bAdjRGBColor;
190
191 #define OPEN 1
192 #define CLOSE 2
193 #define MENU_SEL 3
194 #define SEL_OUT 4
195
196
197 #define SEL_ON 1
198 #define SEL_OFF 0
199
200 unsigned char Menu_Flag = CLOSE;
201
202
203
204 bit kyFindEvent(void)
205 {
206 1 if(m_cCurreKey==kySOURCE)
207 1 {
208 2 return IRSourceSelKeyCtrl();//kyEXITEvent();
209 2 }
210 1 else if(m_cCurreKey==kyMENU)
211 1 {
212 2 if(m_cOSDEvent == CLOSEMENU)
213 2 {
214 3 return kyMENUEvent();
215 3 }
216 2 else
217 2 {
218 3 if(m_cItem == 6)
219 3 {
220 4 Menu_Flag = CLOSE;
221 4 return kyMENUEvent();
222 4 }
223 3 return IRDownKeyCtrl(); //kyDECREASEEvent();
224 3 }
225 2
226 2 }
227 1 else if(m_cCurreKey==kyINCREASE)
228 1 {
229 2 return kyINCREASEEvent();
230 2 }
231 1 else if(m_cCurreKey==kyDECREASE)
232 1 {
233 2 return kyDECREASEEvent();
234 2 }
235 1 else if(m_cCurreKey==kyEXIT)
236 1 {
237 2 if(m_cOSDFunc == 0)
238 2 {
239 3 return IRNTSC_PALCtrl();
240 3 }
241 2 else
C51 COMPILER V7.06 KEYPAD 06/16/2005 10:05:41 PAGE 5
242 2 {
243 3 return IRDownKeyCtrl();
244 3 }//Kuo
245 2 //kyEXITEvent();//IRSourceSelKeyCtrl();
246 2 // return rmP_STDEvent();
247 2 }
248 1 else if(m_cCurreKey==kyPOWER)
249 1 {
250 2 return kyPOWEREvent();
251 2 }
252 1 }
253
254 //Ruby add 2004-06-07
255 bit kySCALEREvent(void)
256 {
257 1 m_cScaleratio++;
258 1 if(m_cScaleratio>=ScaleEnd)
259 1 m_cScaleratio=ScaleFULL;
260 1 IRScaleratioCtrl();
261 1 OSDShowRatio();
262 1 return 1;
263 1 }
264
265 bit kyMENUEvent(void)
266 {
267 1 if(m_bKyBlocked) return 0;
268 1 #ifdef TV
if((m_cOSDFunc&0xF0)==idTVMENU_VIDEO)
{
m_cOSDEvent = CLOSEMENU;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -