📄 key_display.lst
字号:
217 1 DELAY_1US;
218 1 DELAY_1US;
219 1 DELAY_1US;
220 1 DELAY_1US;
221 1 DELAY_1US;
222 1 DELAY_1US;
223 1 }
224 /***********键盘数字转换(0-9)******************/
225 uchar key_tran(uchar x)
226 {
227 1
228 1 uchar a;
229 1 if(x==0x78){a=1;}
230 1 if(x==0x50){a=2;}
231 1 if(x==0x58){a=3;}
232 1 if(x==0x79){a=4;}
233 1 if(x==0x51){a=5;}
234 1 if(x==0x59){a=6;}
235 1 if(x==0x7A){a=7;}
236 1 if(x==0x52){a=8;}
237 1 if(x==0x5A){a=9;}
238 1 if(x==0x7B){a=0;}
239 1 return(a);
240 1
241 1 }
C51 COMPILER V8.02 KEY_DISPLAY 09/06/2007 19:43:26 PAGE 5
242
243 /***********在数码管上0-3显示数字(包括小数点和负数)*****************/
244 void BCDdisplay_l(float n)
245 {
246 1 signed int x;
247 1 signed char a[4],b,t;
248 1 x=abs((int)n);
249 1 for(t=0;t<4;t++)
250 1 CH452_Write((CH452_DIG0+ (t<<8))|16);
251 1 //if( ( n < 0.00000001 ) || ( n > -0.00000001 ) ) CH452_Write((CH452_DIG0));
252 1 //else
253 1 //{
254 1 for(t=0;t<4;t++)
255 1 {
256 2 a[t]=x%10;
257 2 x=x/10;
258 2 if(a[t]) b=t;
259 2 }
260 1
261 1 x=abs((int)n);
262 1 if(x-(int)n)
263 1 {
264 2 x=b+1;x<<=8;
265 2 CH452_Write((CH452_DIG1+x)|18);
266 2 DELAY_1US;
267 2 DELAY_1US;
268 2 DELAY_1US;
269 2 DELAY_1US;
270 2 DELAY_1US;
271 2 }
272 1 for(t=0;t<=b;t++)
273 1 {
274 2 x=t;x<<=8;
275 2 CH452_Write((CH452_DIG1+x)|a[t]);
276 2 DELAY_1US;
277 2 DELAY_1US;
278 2 DELAY_1US;
279 2 DELAY_1US;
280 2 DELAY_1US;
281 2
282 2 }
283 1
284 1 CH452_Write(0x1F9);//写小数点
285 1 n=(n-(int)n);
286 1 t=(int)(n*10);
287 1 n=n*10-t;
288 1 t=abs(t);
289 1 if( (int)( n*10 )>=5 || (int) ( n * 10 ) <=-5 ) t++;
290 1 CH452_Write(CH452_DIG0|t);
291 1 //}
292 1 }
293 /***********在数码管上4-7显示数字(包括小数点和负数)*****************/
294 void BCDdisplay_h(float n)
295 {
296 1 signed int x;
297 1 signed char a[4],b,t;
298 1 x=abs((int)n);
299 1 for(t=4;t<8;t++)
300 1 CH452_Write((CH452_DIG0+ (t<<8))|16);
301 1 //if( ( n < 0.00000001 ) || ( n > -0.00000001 ) ) CH452_Write((CH452_DIG4));
302 1 //else
303 1 //{
C51 COMPILER V8.02 KEY_DISPLAY 09/06/2007 19:43:26 PAGE 6
304 1 for(t=0;t<4;t++)
305 1 {
306 2 a[t]=x%10;
307 2 x=x/10;
308 2 if(a[t]) b=t;
309 2 }
310 1
311 1 x=abs((int)n);
312 1 if(x-(int)n)
313 1 {
314 2 x=b+5;x<<=8;
315 2 CH452_Write((CH452_DIG1+x)|18);
316 2 DELAY_1US;
317 2 DELAY_1US;
318 2 DELAY_1US;
319 2 DELAY_1US;
320 2 DELAY_1US;
321 2 }
322 1 for(t=0;t<=b;t++)
323 1 {
324 2 x=t;x<<=8;
325 2 CH452_Write((CH452_DIG5+x)|a[t]);
326 2 DELAY_1US;
327 2 DELAY_1US;
328 2 DELAY_1US;
329 2 DELAY_1US;
330 2 DELAY_1US;
331 2
332 2 }
333 1
334 1 CH452_Write(0x1fd);//写小数点
335 1 n=(n-(int)n);
336 1 t=(int)(n*10);
337 1 n=n*10-t;
338 1 t=abs(t);
339 1 if( (int)( n*10 )>=5 || (int) ( n * 10 ) <=-5 ) t++;
340 1 CH452_Write(CH452_DIG4|t);
341 1 //}
342 1 }
343
344 /***********显示(包括数)******************/
345 void BCDdisplay1(uint n)
346 { uint x;
347 1 uchar a[8],t,b;
348 1 x=n;
349 1 //CH452_Write(CH452_RESET);
350 1 CH452_Write(CH452_SYSON2);//打开键盘显示
351 1 CH452_Write(CH452_BCD); // BCD译码,8个数码管
352 1 for(t=0;t<8;t++)
353 1 CH452_Write((CH452_DIG0+ (t<<8))|16);
354 1 if(n==0) CH452_Write((CH452_DIG0));
355 1 else
356 1 {
357 2 for(t=0;t<8;t++)
358 2 { a[t]=x%10;
359 3 x=x/10;
360 3 if(a[t]) b=t;
361 3 }
362 2
363 2 for(t=0;t<=b;t++)
364 2 {
365 3 x=t;x<<=8;
C51 COMPILER V8.02 KEY_DISPLAY 09/06/2007 19:43:26 PAGE 7
366 3 CH452_Write((CH452_DIG0+x)|a[t]);
367 3 DELAY_1US;
368 3 DELAY_1US;
369 3 DELAY_1US;
370 3 DELAY_1US;
371 3 DELAY_1US;}
372 2 }
373 1 }
374
375
376 //H_L为1,选择高四位数码管写整数;H_L为0,选择低四位数码管写整数
377 void BCD_H_L(signed int n,unsigned char H_L)
378 {
379 1 unsigned int x;
380 1 unsigned char a[4],b,t;
381 1 for(t=0;t<4;t++)
382 1 {
383 2 x=t+(H_L<<2);
384 2 x<<=8;
385 2 CH452_Write((CH452_DIG0 + x)|16);
386 2 }
387 1 x=(H_L<<2);
388 1 x<<=8;
389 1 if( n == 0 )
390 1 CH452_Write(CH452_DIG0 +x);
391 1 else
392 1 { x=abs(n);
393 2 for(t=0;t<4;t++)
394 2 {
395 3 a[t]=x%10;
396 3 x=x/10;
397 3 if(a[t]) b=t;
398 3 }
399 2
400 2 if(abs(n)-n)
401 2 {
402 3 x=b + (H_L<<2)+1;
403 3 x<<=8;
404 3 CH452_Write((CH452_DIG0+x)|18);
405 3 DELAY_1US;
406 3 DELAY_1US;
407 3 DELAY_1US;
408 3 DELAY_1US;
409 3 DELAY_1US;
410 3 }
411 2 for(t=0;t<=b;t++)
412 2 {
413 3 x=t+(H_L<<2);
414 3 CH452_Write((CH452_DIG0+ (x << 8))|a[t]);
415 3 DELAY_1US;
416 3 DELAY_1US;
417 3 DELAY_1US;
418 3 DELAY_1US;
419 3 DELAY_1US;
420 3
421 3 }
422 2 }
423 1 }
424
MODULE INFORMATION: STATIC OVERLAYABLE
C51 COMPILER V8.02 KEY_DISPLAY 09/06/2007 19:43:26 PAGE 8
CODE SIZE = 1835 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 45
IDATA SIZE = ---- ----
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 + -