📄 keyborad.lst
字号:
C51 COMPILER V7.07 KEYBORAD 11/25/2005 20:21:59 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE KEYBORAD
OBJECT MODULE PLACED IN keyborad.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE keyborad.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*
2 * Copyright(c)2005 - 2009 danise .China
3 * All rights reserved.
4 * Redistribution and use in source and bianry forms
5 * with or without modification ,are permitted provided
6 * that following conditions are met:
7 *
8 * 1.Redistrubution of source code must retain the
9 * above copyright notice,this list of conditions and
10 * following disclaimer.
11 *
12 * 2.Redistributions in binary form must reproduce the
13 * above copyright notice,this list of conditions and
14 * following disclaimer in the documentation and /or other
15 * materials provided with the distribution.
16 *
17 * Alternately, this acknowledgment may appear in the software
18 * itself,if and wherever such third-party acknowledgements
19 * normally appear.
20 *
21 * This software is designed for key board and led display.
22 *
23
24 */
25 #include"include/keyboard.h"
26 #include "include/datatypes.h"
27 #include "include/display.h"
28 #include "include/global.h"
29 #include "include/system.h"
30 /** get key but not a safe key
31 using P0 port
32 */
33
34 UINT8 keyok = 0;
35 UINT8 keyage = 0; /* */
36 UINT8 oldkey = 0 ;
37 UINT8 Scankey(void)
38 {
39 1 UINT8 tempkeycode=0xff;
40 1 UINT8 AA;
41 1 UINT8 BB;
42 1 P0=0x0f;
43 1 AA=P0;
44 1 AA&=0x0f;
45 1 BB=AA;
46 1 P0=0x0f0;
47 1 AA=P0;
48 1 AA&=0xf0;
49 1 tempkeycode=AA|BB;
50 1 return tempkeycode;
51 1
52 1 }
53 /*
54 */
55 INT8 GetSafeKeyValue()
C51 COMPILER V7.07 KEYBORAD 11/25/2005 20:21:59 PAGE 2
56 {
57 1 UINT8 idata temp;
58 1 INT8 idata rKeyVal;
59 1 temp = Scankey();
60 1 if(0xff!=temp){
61 2 if(!( temp^oldkey )){/* if same */
62 3 oldkey = temp;
63 3 keyage ++;
64 3 if(! keyok ){ /* never response */
65 4 if( keyage == 3 ){
66 5 switch ( temp )
67 5 {
68 6 case 0x77: rKeyVal=0; break;
69 6 case 0xBD: rKeyVal=1; break;
70 6 case 0xBB: rKeyVal=2; break;
71 6 case 0xB7: rKeyVal=3; break;
72 6 case 0xED: rKeyVal=4; break;
73 6 case 0xEB: rKeyVal=5; break;
74 6 case 0xE7: rKeyVal=6; break;
75 6 case 0xDD: rKeyVal=7; break;
76 6 case 0xDB: rKeyVal=8; break;
77 6 case 0xD7: rKeyVal=9; break;
78 6 case 0x7B: rKeyVal=10; break;//"."
79 6 case 0x7D: rKeyVal=11; break;//"BACK"
80 6 case 0xDE: rKeyVal=12; break;//"CLEAR ALL"
81 6 case 0xEE: rKeyVal=13; break;//"+"
82 6 case 0xBE: rKeyVal=14; break;//"*"
83 6 case 0x7E: rKeyVal=15; break;//"enter"
84 6 default: rKeyVal=-1;
85 6 }
86 5 keyok = 1;
87 5 keyage = 0;
88 5 /* do your work ** begin **with key value */
89 5 /* clr crc save */
90 5 sreensaveclk = 0;
91 5 scrflag = 0;
92 5 return rKeyVal ;
93 5 /* ** end ** */
94 5 }
95 4 else{ /*key age is not old enough */
96 5 return (-1);
97 5 }
98 4
99 4
100 4 }
101 3 else{ /* responsed */
102 4 return (-1);
103 4 }
104 3 }
105 2 else{/* if different */
106 3 keyok = 0;
107 3 keyage = 0;
108 3 oldkey = temp;
109 3 return (-1);
110 3 }
111 2
112 2 }
113 1 else{
114 2 keyok = 0;
115 2 keyage = 0;
116 2 return (-1);
117 2 }
C51 COMPILER V7.07 KEYBORAD 11/25/2005 20:21:59 PAGE 3
118 1
119 1
120 1 }
121 void AnalyseKeyVal(UINT8 keyVal )
122 {
123 1
124 1 if (keyVal <0) return; /* no key press */
125 1 if(keyVal>=0 && keyVal<=0xa ){
126 2 /* data key value */
127 2 addKyeValHexBuf( keyVal );
128 2 }
129 1 else{//>0
130 2 /* cmd key value*/
131 2 /*
132 2 1. LEDS process
133 2 2. I2C process
134 2 */
135 2 switch ( keyVal )
136 2 {
137 3 case 11: backspace(); break;
138 3 case 12: clearallleds();break;
139 3 case 15: enter();break;
140 3
141 3 }
142 2 }
143 1
144 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 316 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 3 1
IDATA SIZE = ---- 2
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -