📄 keypad.lst
字号:
C51 COMPILER V7.50 KEYPAD 01/12/2006 13:31:13 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE KEYPAD
OBJECT MODULE PLACED IN .\Obj\KEYPAD.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Source\T100\KEYPAD.C BROWSE INCDIR(.\Include\;.\Source\;.\Include\Panel\;.\
-Include\GammaTable\) DEFINE(T106) DEBUG OBJECTEXTEND PRINT(.\KEYPAD.lst) OBJECT(.\Obj\KEYPAD.obj)
line 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 "TW10xReg.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 extern uWORD code ucaZoomDataP0_NTSC[];
48
49 typedef struct tag_sKEYPAD_FLD
50 {
51 uCHAR cAddress; // Address of field
52 uCHAR cMask; // Mask for field after shifted right
53 uCHAR cFlagsShift; // Flags & Shift byte:
54 // [7] Type: 1=external, 0=internal
C51 COMPILER V7.50 KEYPAD 01/12/2006 13:31:13 PAGE 2
55 // [6] Polarity: 1=high true, 0=low true
56 // [4] Shift direction: 1=left, 0=right
57 // [2:0] Shift to Right Justify
58 } sKEYPADFLD;
59
60 #define nKEYFLDS 1
61
62 sKEYPADFLD code sKeyFlds={
63 //PORT MASK FLAGS/SHIFT
64 KEYPORT2, 0x3f, 0x00
65 };
66
67 uCHAR idata m_cCurreKey;
68 uCHAR idata m_cPreKey;
69 uWORD idata m_wAccelPollCnt;
70 uCHAR idata m_cItem;
71
72 extern uCHAR idata m_cTV_Num;
73 extern bit m_bTV_Num_Bits;
74
75 extern bit m_bFactryReady;
76 extern bit m_bFactryMode;
77 extern uCHAR m_cFactryCnt;
78
79 extern bit m_bRelease;
80 extern bit m_bChipPowerOn;
81 extern bit m_bKyBlocked;
82 extern uCHAR idata m_cOSDEvent;
83 extern uCHAR idata m_cOSDFunc;
84 extern uCHAR idata m_cOSDMenu;
85 extern uCHAR idata m_cSource;
86
87 extern uWORD idata m_wBuff[3];
88 extern uCHAR idata m_cBuff[5];
89 extern uDWORD m_dwBuff[2];
90 extern uCHAR idata m_cScaleratio;
91 extern uWORD m_wHRes;
92 extern uWORD m_wVRes;
93 extern uWORD idata m_wVTotal;
94 extern uCHAR idata m_cStandard;
95 void kyKeypadInit(void)
96 {
97 1 m_wAccelPollCnt=0;
98 1 m_cCurreKey=m_cPreKey=0xFF;
99 1 m_cOSDEvent=0;
100 1 m_cOSDFunc=0;
101 1 m_cOSDMenu=idNULLMENU;
102 1 m_cItem=1;
103 1 }
104
105 void kyKeypad(void)
106 {
107 1 if(kyKeypadScan())
108 1 {
109 2 Timer0Reset();
110 2 kyFindFunc();
111 2 }
112 1 else
113 1 m_cPreKey=m_cCurreKey;
114 1 }
115
116 bit kyKeypadScan(void)
C51 COMPILER V7.50 KEYPAD 01/12/2006 13:31:13 PAGE 3
117 {
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;
C51 COMPILER V7.50 KEYPAD 01/12/2006 13:31:13 PAGE 4
179 1 switch(sKeyFlds.cAddress){
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 bit kyFindEvent(void)
191 {
192 1 if(m_cCurreKey==kySOURCE)
193 1 {
194 2 return IRSourceSelKeyCtrl();//kyEXITEvent();
195 2 }
196 1 else if(m_cCurreKey==kyMENU)
197 1 {
198 2 return kyMENUEvent();
199 2 }
200 1 else if(m_cCurreKey==kyINCREASE)
201 1 {
202 2 return kyINCREASEEvent();
203 2 }
204 1 else if(m_cCurreKey==kyDECREASE)
205 1 {
206 2 return kyDECREASEEvent();
207 2 }
208 1 else if(m_cCurreKey==kyEXIT)
209 1 {
210 2 if(m_cOSDFunc == 0)
211 2 {
212 3 return IRNTSC_PALCtrl();
213 3 }
214 2 else
215 2 {
216 3 return IRDownKeyCtrl();
217 3 }
218 2
219 2 }
220 1 else if(m_cCurreKey==kyPOWER)
221 1 {
222 2 return kyPOWEREvent();
223 2 }
224 1 }
225
226 //Ruby add 2004-06-07
227 bit kySCALEREvent(void)
228 {
229 1 uCHAR SlaveAddr,RegAddrShift;
230 1 m_cScaleratio++;
231 1 if(m_cScaleratio>=ScaleEnd)
232 1 m_cScaleratio=ScaleFULL;
233 1 #ifdef T515
if(m_cSource >= isrc_T515_CVIDEO1){
SlaveAddr=0xb8;
RegAddrShift=0x20;
}else{
SlaveAddr=0x54;
RegAddrShift=0x00;
}
C51 COMPILER V7.50 KEYPAD 01/12/2006 13:31:13 PAGE 5
#else
242 1 SlaveAddr=0x54;
243 1 RegAddrShift=0x00;
244 1 #endif
245 1
246 1 if(I2CReadByte(SlaveAddr, 0x3A+RegAddrShift)&0x06){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -