key.lst
来自「一个基于C51开发的计价秤」· LST 代码 · 共 1,260 行 · 第 1/4 页
LST
1,260 行
46 =1 BYTE B[4];
47 =1 } UNION_FLOAT;
48 =1
49 =1 typedef union UNION_INT { // byte-addressable INT
50 =1 WORD I;
C51 COMPILER V7.50 KEY 05/27/2006 14:00:59 PAGE 6
51 =1 BYTE B[2];
52 =1 } UNION_INT;
53 =1
54 =1 /*****11.0592MHZ*****/
55 =1 #define V_TMOD 0x11
56 =1 #define V_TH0 0x4c //50ms
57 =1 #define V_TL0 0x0f
58 =1 //#define V_TH1 0xb8//20ms
59 =1 //#define V_TL1 0x00
60 =1 #define V_TH1 0xdc //10ms
61 =1 #define V_TL1 0x00
62 =1 #define V_TH2 0xff //9600 bps
63 =1 #define V_TL2 0xdb
64 =1 //#define SEC 50
65 =1 #define SEC 100
66 =1 #define N 1
67 =1
68 =1 #define LIGHT P3_7
69 =1 #define AC_DECT P1_2
70 =1 #define BAT_DECT P3_3
71 =1 #define FALSE 0
72 =1 #define TRUE 1
73 =1 #define PAND 0
74 =1 #define FOOKTIN 1
75 =1 #define LCD_MODE 0x08 //display(1:4,1/3)
76 =1 #define LCD_GLITTER 0x00 //off
77 =1 #define MAX_RECORD 0xbb8 //3000
78 =1 #define PLU_LEN 22
79 =1 #define TABLE_LEN 64
80 =1 #define RECORD_LEN 15
81 =1 /**********mode**********/
82 =1 #define Input_code_mode 1
83 =1 #define Calibration_mode 2
84 =1 #define Initialization_mode 3
85 =1 #define Sales_mode 4
86 =1 #define Total_mode 5
87 =1 #define Payback_mode 6
88 =1 #define PLU_Setup_mode 7
89 =1 #define Time_Setup_mode 8
90 =1 #define Beep_and_Light_Setup_mode 9
91 =1 #define Calculator_mode 10
92 =1 #define Reports_mode 11
93 =1 #define Download_mode 12
94 =1 #define Power_down_mode 13
95 =1 #define Print_Cancel_mode 14
96 =1 /**********state**********/
97 =1 #define WEIGHING 1
98 =1 #define NON_WEIGHING 2
99 =1 #define PAYBACK 3
100 =1
101 =1 #define PLU_EDIT 1
102 =1 #define PLU_SAVE 2
103 =1
104 =1 #define SET_BEEP 1
105 =1 #define SET_LIGHT 2
106 =1
107 =1 #define MENU_1 1
108 =1 #define MENU_1_1 11
109 =1 #define MENU_1_2 12
110 =1 #define MENU_1_2_1 121
111 =1 #define MENU_1_2_2 122
112 =1 #define MENU_1_2_2_0 1221
C51 COMPILER V7.50 KEY 05/27/2006 14:00:59 PAGE 7
113 =1 #define MENU_1_3 13
114 =1 #define MENU_1_4 14
115 =1
116 =1 #define MENU_2 2
117 =1 #define MENU_2_1 21
118 =1 #define MENU_2_2 22
119 =1 #define MENU_2_2_1 221
120 =1 #define MENU_2_2_2 222
121 =1 #define MENU_2_2_2_0 2221
122 =1 #define MENU_2_3 23
123 =1
124 =1 #define MENU_3 3
125 =1 #define MENU_3_1 31
126 =1 #define MENU_3_2 32
127 =1 #define MENU_3_2_1 321
128 =1 #define MENU_3_2_2 322
129 =1 #define MENU_3_2_2_0 3221
130 =1 #define MENU_3_3 33
131 =1
132 =1 #define EDIT_YEAR 1
133 =1 #define EDIT_MONTH 2
134 =1 #define EDIT_DAY 3
135 =1 #define EDIT_HOUR 4
136 =1 #define EDIT_MINUTE 5
137 =1 #define EDIT_SECOND 6
138 =1
139 =1 /**********sales type**********/
140 =1 #define PW 1
141 =1 #define PN 2
142 =1 #define MW 3
143 =1 #define MN 4
144 =1 #define DELE 0xaa
145 =1
146 =1 /**********print type***********/
147 =1 #define PW 1
148 =1 #define PN 2
149 =1 #define MW 3
150 =1 #define MN 4
151 =1 #define TOTAL 5
152 =1
153 =1 /**********report type**********/
154 =1 #define TOTAL_ALL_MONEY 1
155 =1 #define TOTAL_ALL_PLU_MONEY 2
156 =1 #define TOTAL_SEL_PLU_MONEY 3
157 =1 #define TOTAL_ALL_MANUL_MONEY 4
158 =1 #define TOTAL_ALL_NUMBER_MONEY 5
159 =1 #define TOTAL_ALL_WEIGHT 6
160 =1 #define TOTAL_ALL_PLU_WEIGHT 7
161 =1 #define TOTAL_SEL_PLU_WEIGHT 8
162 =1 #define TOTAL_ALL_MANUL_WEIGHT 9
163 =1 #define TOTAL_ALL_NUMBER 10
164 =1 #define TOTAL_ALL_PLU_NUMBER 11
165 =1 #define TOTAL_SEL_PLU_NUMBER 12
166 =1 #define TOTAL_ALL_MANUL_NUMBER 13
167 =1
168 =1 /********operate status********/
169 =1 #define ADD 1
170 =1 #define SUM 2
171 =1 #define PAY 3
172 =1
173 =1 /********eeprom address********/
174 =1 #define EEPROM_ID 0
C51 COMPILER V7.50 KEY 05/27/2006 14:00:59 PAGE 8
175 =1 #define Option_Param_address 2
176 =1 #define Graduation_Grade_address 3
177 =1 #define Graduation1_address 5
178 =1 #define Graduation2_address 6
179 =1 #define Max_Capacity_address 7
180 =1 #define Initial_Zero_Setting_limit_address 9
181 =1 #define Zero_Setting_and_Zero_Tracking_limit_address 10
182 =1 #define Zero_Stable_count_address 11
183 =1 #define Zero_Stable_times_address 13
184 =1 #define Weight_Stable_count_address 14
185 =1 #define Weight_Stable_times_address 16
186 =1 #define Err1_Timeout_address 17
187 =1 #define Local_Height_address 18
188 =1 #define Local_Latitude_address 20
189 =1 #define Destination_Height_address 21
190 =1 #define Destination_Latitude_address 23
191 =1 #define Soft_Ver_address 24
192 =1 #define Cal_counts_address 26
193 =1 #define Password_address 27
194 =1 #define Cal_Zero_limit_count_address 30
195 =1 #define Cal_One_count_address 36
196 =1 #define Cal_Zero_count_address 40
197 =1 #define Cal_Weight_count_address 44
198 =1 #define Logo_address 48
199 =1 #define PLU_DATA_ADR 0x40
200 =1 #define RECORD_DATA_ADR 0x2600
201 =1
202 =1 /********report save address********/
203 =1 #define PLU_no_Save_address 1
204 =1 #define Unit_Price_Save_address 3
205 =1 #define Weight_Save_address 6
206 =1 #define Quantity_Save_address 6
207 =1 #define Total_Price_Save_address 9
9 #include "KeyBoard.h"
1 =1 //Function key define
2 =1 #define PLU1 0x01
3 =1 #define PLU2 0x08
4 =1 #define PLU3 0x0f
5 =1 #define PLU4 0x16
6 =1 #define PLU5 0x1d
7 =1 #define PLU6 0x24
8 =1 #define PLU7 0x2b
9 =1 #define PLU8 0x32
10 =1 #define PLU9 0x02
11 =1 #define PLU10 0x09
12 =1 #define PLU11 0x10
13 =1 #define PLU12 0x17
14 =1 #define PLU13 0x1e
15 =1 #define PLU14 0x25
16 =1 #define PLU15 0x2c
17 =1 #define PLU16 0x33
18 =1 #define PLU17 0x03
19 =1 #define PLU18 0x0a
20 =1 #define PLU19 0x11
21 =1 #define PLU20 0x18
22 =1 #define PLU21 0x1f
23 =1 #define PLU22 0x26
24 =1 #define PLU23 0x2d
25 =1 #define PLU24 0x34
26 =1 #define PLU25 0x04
27 =1 #define PLU26 0x0b
28 =1 #define PLU27 0x12
C51 COMPILER V7.50 KEY 05/27/2006 14:00:59 PAGE 9
29 =1 #define PLU28 0x19
30 =1 #define PLU29 0x20
31 =1 #define PLU30 0x27
32 =1 #define K_ADD 0x2e
33 =1 #define K_SUB 0x35
34 =1 #define K_MUL 0x05
35 =1 #define K_DIV 0x0c
36 =1 #define K_00 0x13
37 =1 #define K_0 0x1a
38 =1 #define K_1 0x21
39 =1 #define K_2 0x28
40 =1 #define K_3 0x2f
41 =1 #define K_4 0x36
42 =1 #define K_5 0x06
43 =1 #define K_6 0x0d
44 =1 #define K_7 0x14
45 =1 #define K_8 0x1b
46 =1 #define K_9 0x22
47 =1 #define K_ENTER 0x29
48 =1 #define K_ZERO 0x30
49 =1 #define K_TARE 0x37
50 =1 #define K_CLEAR 0x07
51 =1 #define K_PRINT 0x0e
52 =1 #define K_TOTAL 0x15
53 =1 #define K_PAYBACK 0x1c
54 =1 #define K_CLOCK 0x41
55 =1 #define K_MEMORY 0x42
56 =1 #define K_ON_OFF 0x43
57 =1 //Shift key define
58 =1 #define K_SHIFT 1
59 =1 #define K_MEM 2
60 =1 #define K_MODE 3
10
11 #define SHIFT_KEY P3_2
12
13 extern BYTE mode;
14 extern BOOL keydone;
15 extern BOOL keyprocess;
16 extern BOOL memory_key_hold;
17 extern BYTE keypre[4];
18
19 BOOL Key_Short_Test()
20 {
21 1 BYTE data row=0xfe;
22 1 SHIFT_KEY=1;
23 1 P2=0xff;
24 1 while(row>0x7f)
25 1 {
26 2 P0=row;
27 2 if((P2&0x7f)!=0x7f)
28 2 return FALSE;
29 2 row=_crol_(row,1);
30 2 }
31 1 return TRUE;
32 1 }
33
34 VOID Keyscan(KEYRET *kpd) using 2
35 {
36 1 BYTE data x,y;
37 1 BYTE data row=0xfe,col;
38 1 SHIFT_KEY=1;
39 1 P2=0xff;
C51 COMPILER V7.50 KEY 05/27/2006 14:00:59 PAGE 10
40 1 _nop_();
41 1 _nop_();
42 1 _nop_();
43 1 for(x=0;x<8;x++)
44 1 {
45 2 P0=row;
46 2 if(!SHIFT_KEY&&(row==0x7f))
47 2 {
48 3 kpd->funcnt++;
49 3 kpd->funval=0x43;
50 3 }
51 2 if(!SHIFT_KEY&&(row==0xfb))
52 2 {
53 3 kpd->shiftcnt++;
54 3 kpd->modeval=1;
55 3 }
56 2 if(!SHIFT_KEY&&(row==0xfd))
57 2 {
58 3 kpd->shiftcnt++;
59 3 kpd->memval=1;
60 3 }
61 2 if(!SHIFT_KEY&&(row==0xfe))
62 2 {
63 3 kpd->shiftcnt++;
64 3 kpd->shiftval=1;
65 3 }
66 2 y=1;
67 2 col=0xfe;
68 2 while(col>0x7f)
69 2 {
70 3 if(P2==col)
71 3 {
72 4 kpd->funcnt++;
73 4 kpd->funval=x*7+y;
74 4 }
75 3 y++;
76 3 col=_crol_(col,1);
77 3 }
78 2 row=_crol_(row,1);
79 2 }
80 1 }
81
82 VOID Key() using 2
83 {
84 1 static BYTE data keycnt;
85 1 static BOOL keysec;
86 1 KEYRET keytemp={0x00,0x00,0x00,0x00,0x00,0x00};
87 1 if(keydone)
88 1 {
89 2 Keyscan(&keytemp);
90 2 if(!keytemp.funcnt&&!keytemp.shiftcnt)
91 2 {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?