C51 COMPILER V9.56.0.0 MAIN 05/01/2022 13:19:20 PAGE 1 C51 COMPILER V9.56.0.0, COMPILATION OF MODULE MAIN OBJECT MODULE PLACED IN main.OBJ COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE main.c OPTIMIZE(8,SPEED) BROWSE DEBUG OBJECTEXTEND TABS(2) line level source 1 #include 2 #include"lcd.h" 3 #include"ds1302.h" 4 #include"i2c.h" 5 #include "DS18B20.h" 6 7 #include 8 #include 9 10 11 #define uchar unsigned char 12 #define uint unsigned int 13 14 sbit LED0=P2^5; 15 sbit LED1=P2^6; 16 sbit LED2=P2^1; 17 18 sbit LED3=P2^4; 19 20 sbit LED4=P2^3; 21 sbit LED5=P1^7; 22 23 sbit key1 = P1^2; 24 sbit key2 = P1^3; 25 sbit key3 = P2^2; 26 sbit key4 = P2^7; 27 28 29 sbit IN = P3^7; 30 sbit OUT = P3^6; 31 32 sbit SCL1=P1^1; 33 sbit SDA1=P1^0; 34 35 int cut = 0; 36 37 int led_num = 0; 38 39 struct Time{ 40 int hour; 41 int min; 42 int sec; 43 }; 44 45 struct UserInfo{ 46 int num; 47 int model; 48 int set; 49 int start; 50 float Light; 51 int temp; 52 struct Time time[2]; 53 }; 54 55 struct UserInfo userInfo; C51 COMPILER V9.56.0.0 MAIN 05/01/2022 13:19:20 PAGE 2 56 57 void LcdDisplay(); 58 void LcdDisplay1(); 59 void Delay10ms(void); 60 61 #define SlaveAddress 0x46 //¶¨ÒåÆ÷¼þÔÚIIC×ÜÏßÖеĴӵØÖ·,¸ù¾ÝALT ADDRESSµ -ØÖ·Òý½Å²»Í¬ÐÞ¸Ä 62 //ALT ADDRESSÒý½Å½ÓµØʱµØַΪ0x46£¬½ÓµçԴʱµØÖ -·Îª0xB8 63 typedef unsigned char BYTE; 64 typedef unsigned short WORD; 65 66 BYTE BUF[8]; //½ÓÊÕÊý¾Ý»º´æÇø 67 int dis_data; //±äÁ¿ 68 69 void delay_nms(unsigned int k); 70 void InitLcd(); 71 void Init_BH1750(void); 72 73 void WriteDataLCM(uchar dataW); 74 void WriteCommandLCM(uchar CMD,uchar Attribc); 75 void DisplayOneChar(uchar X,uchar Y,uchar DData); 76 void conversion(uint temp_data); 77 78 void Single_Write_BH1750(uchar REG_Address); //µ¥¸öдÈëÊý¾Ý 79 uchar Single_Read_BH1750(uchar REG_Address); //µ¥¸ö¶ÁÈ¡ÄÚ²¿¼Ä´æÆ÷Êý¾Ý 80 void Multiple_Read_BH1750(); //Á¬ÐøµÄ¶ÁÈ¡ÄÚ²¿¼Ä´æÆ÷Êý -¾Ý 81 //------------------------------------ 82 void Delay5us(); 83 void Delay5ms(); 84 void BH1750_Start(); //ÆðʼÐźŠ85 void BH1750_Stop(); //Í£Ö¹ÐźŠ86 void BH1750_SendACK(bit ack); //Ó¦´ðACK 87 bit BH1750_RecvACK(); //¶Áack 88 void BH1750_SendByte(BYTE dat); //IICµ¥¸ö×Ö½Úд 89 BYTE BH1750_RecvByte(); //IICµ¥¸ö×Ö½Ú¶Á 90 91 92 //ºÁÃëÑÓʱ************************** 93 void delay_nms(unsigned int k) 94 { 95 1 unsigned int i,j; 96 1 for(i=0;i= 5) led_num = 0; 348 4 }else{ 349 4 if(userInfo.set == 0) userInfo.set = 1; 350 4 else userInfo.set = 0; 351 4 cut = 0; 352 4 } 353 3 LcdWriteCom(0x01); //清屏 354 3 } 355 2 while((i<50)&&(key2==0)){ 356 3 Delay10ms(); 357 3 i++; 358 3 } 359 2 i=0; 360 2 } 361 1 362 1 if(IN==0) C51 COMPILER V9.56.0.0 MAIN 05/01/2022 13:19:20 PAGE 7 363 1 { 364 2 Delay10ms(); 365 2 if(IN==0){ 366 3 userInfo.num++; 367 3 if(userInfo.num > 99) userInfo.num = 99; 368 3 } 369 2 while((i<50)&&(IN==0)){ 370 3 Delay10ms(); 371 3 i++; 372 3 } 373 2 i=0; 374 2 } 375 1 376 1 if(OUT==0) //��ⰴ��K1�Ƿ��� 377 1 { 378 2 Delay10ms(); //�������� 379 2 if(OUT==0){ 380 3 userInfo.num--; 381 3 if(userInfo.num < 0) userInfo.num = 0; 382 3 } 383 2 while((i<50)&&(OUT==0)){ 384 3 Delay10ms(); 385 3 i++; 386 3 } 387 2 i=0; 388 2 } 389 1 390 1 if(key3==0) //��ⰴ��K1�Ƿ��� 391 1 { 392 2 Delay10ms(); //�������� 393 2 if(key3==0){ 394 3 cut++; 395 3 if(cut >= 4) cut = 0; 396 3 } 397 2 while((i<50)&&(key3==0)){ 398 3 Delay10ms(); 399 3 i++; 400 3 } 401 2 i=0; 402 2 } 403 1 404 1 if(key4==0) //��ⰴ��K1�Ƿ��� 405 1 { 406 2 Delay10ms(); //�������� 407 2 if(key4==0){ 408 3 if(cut == 0){ 409 4 userInfo.time[0].hour++; 410 4 if(userInfo.time[0].hour >= 24) userInfo.time[0].hour = 0; 411 4 }else if(cut == 1){ 412 4 userInfo.time[0].min++; 413 4 if(userInfo.time[0].min >= 59) userInfo.time[0].min = 0; 414 4 }else if(cut == 2){ 415 4 userInfo.time[1].hour++; 416 4 if(userInfo.time[1].hour >= 24) userInfo.time[1].hour = 0; 417 4 }else if(cut == 3){ 418 4 userInfo.time[1].min++; 419 4 if(userInfo.time[1].min >= 59) userInfo.time[1].min = 0; 420 4 } 421 3 while((i<50)&&(key4==0)){ 422 4 Delay10ms(); 423 4 i++; 424 4 } C51 COMPILER V9.56.0.0 MAIN 05/01/2022 13:19:20 PAGE 8 425 3 i=0; 426 3 } 427 2 } 428 1 } *** WARNING C280 IN LINE 311 OF main.c: 'num': unreferenced local variable 429 430 431 int getTimeResult() 432 { 433 1 int result = 1; 434 1 struct Time Nowtime; 435 1 436 1 Nowtime.hour = TIME[2]/16 * 10 + (TIME[2]&0x0f); 437 1 Nowtime.min = TIME[1]/16 * 10 + (TIME[1]&0x0f); 438 1 439 1 if(Nowtime.hour < userInfo.time[0].hour || Nowtime.hour > userInfo.time[1].hour) return 0; 440 1 if(Nowtime.hour == userInfo.time[0].hour && Nowtime.min < userInfo.time[0].min) return 0; 441 1 if(Nowtime.hour == userInfo.time[1].hour && Nowtime.min > userInfo.time[1].min) return 0; 442 1 443 1 return result; 444 1 } 445 446 447 void Dispose() 448 { 449 1 450 1 if(userInfo.model == 0){ 451 2 if(getTimeResult() && userInfo.Light < 100){ 452 3 if(userInfo.num < 10 && userInfo.num > 0) LED0 = 0, LED1 = 0, LED2 = 0 ,LED3 = 1; 453 3 else if(userInfo.num >= 10 && userInfo.num < 20) LED0 = 0, LED1 = 0, LED2 = 1 ,LED3 = 1; 454 3 else if(userInfo.num >= 20 && userInfo.num < 30) LED0 = 0, LED1 = 1, LED2 = 1 ,LED3 = 1; 455 3 else if(userInfo.num >= 30) LED0 = 1, LED1 = 1, LED2 = 1 ,LED3 = 1; 456 3 else LED0 = 0, LED1 = 0, LED2 = 0 ,LED3 = 0; 457 3 }else{ 458 3 LED0 = 0, LED1 = 0, LED2 = 0 ,LED3 = 0; 459 3 } 460 2 }else{ 461 2 if(led_num){ 462 3 if(led_num == 1) LED0 = 0, LED1 = 0, LED2 = 0 ,LED3 = 1; 463 3 else if(led_num == 2) LED0 = 0, LED1 = 0, LED2 = 1 ,LED3 = 1; 464 3 else if(led_num == 3) LED0 = 0, LED1 = 1, LED2 = 1 ,LED3 = 1; 465 3 else if(led_num == 4) LED0 = 1, LED1 = 1, LED2 = 1 ,LED3 = 1; 466 3 }else{ 467 3 LED0 = 0, LED1 = 0, LED2 = 0 ,LED3 = 0; 468 3 } 469 2 } 470 1 LED4 = userInfo.model; 471 1 } 472 473 void main() 474 { 475 1 int i = 0; 476 1 uchar str[10]; 477 1 Ds1302Init(); 478 1 Uart_Init(); 479 1 LcdInit(); 480 1 481 1 userInfo.time[0].hour = 18; 482 1 userInfo.time[0].min = 0; 483 1 userInfo.time[0].sec = 0; 484 1 485 1 userInfo.time[1].hour = 23; C51 COMPILER V9.56.0.0 MAIN 05/01/2022 13:19:20 PAGE 9 486 1 userInfo.time[1].min = 30; 487 1 userInfo.time[1].sec = 0; 488 1 489 1 while(1) 490 1 { 491 2 Ds1302ReadTime(); 492 2 LcdDisplay(); 493 2 Detection(); 494 2 Dispose(); 495 2 sprintf(str, "%d\r\n", userInfo.temp); 496 2 Bluetooth_Set(str); 497 2 } 498 1 } 499 500 void LcdDisplay() 501 { 502 1 uint temp_data; 503 1 if(userInfo.set == 0){ 504 2 // TODO 显示时间 505 2 LcdWriteCom(0x80); 506 2 LcdWriteData('0'+TIME[4]/16); //月 507 2 LcdWriteData('0'+(TIME[4]&0x0f)); 508 2 LcdWriteData('-'); 509 2 LcdWriteData('0'+TIME[3]/16); //日 510 2 LcdWriteData('0'+(TIME[3]&0x0f)); 511 2 LcdWriteData(' '); 512 2 513 2 LcdWriteData('0'+TIME[2]/16); //时 514 2 LcdWriteData('0'+(TIME[2]&0x0f)); 515 2 LcdWriteData(':'); 516 2 LcdWriteData('0'+TIME[1]/16); //分 517 2 LcdWriteData('0'+(TIME[1]&0x0f)); 518 2 LcdWriteData(':'); 519 2 LcdWriteData('0'+TIME[0]/16); //秒 520 2 LcdWriteData('0'+(TIME[0]&0x0f)); 521 2 522 2 LcdWriteData(' '); 523 2 LcdWriteData('0'+(TIME[5]&0x0f)); 524 2 525 2 LcdWriteCom(0x80 + 0x40); 526 2 temp_data = userInfo.Light; 527 2 temp_data=temp_data%10000; 528 2 LcdWriteData(temp_data/1000+0x30); 529 2 temp_data=temp_data%1000; 530 2 LcdWriteData(temp_data/100+0x30); 531 2 temp_data=temp_data%100; 532 2 LcdWriteData(temp_data/10+0x30); 533 2 temp_data=temp_data%10; 534 2 LcdWriteData(temp_data+0x30); 535 2 LcdWriteData('L'); 536 2 LcdWriteData('x'); 537 2 LcdWriteData(' '); 538 2 LcdWriteData(userInfo.temp / 10 + 0x30); 539 2 LcdWriteData(userInfo.temp % 10 + 0x30); 540 2 LcdWriteData('C'); 541 2 542 2 LcdWriteData(' '); 543 2 LcdWriteData(userInfo.num / 10 % 10 + 0x30); 544 2 LcdWriteData(userInfo.num % 10 + 0x30); 545 2 }else{ 546 2 LcdWriteCom(0x80); 547 2 LcdWriteData('0'+ userInfo.time[0].hour/10); //时 C51 COMPILER V9.56.0.0 MAIN 05/01/2022 13:19:20 PAGE 10 548 2 LcdWriteData('0'+ userInfo.time[0].hour% 10); 549 2 LcdWriteData(':'); 550 2 LcdWriteData('0'+userInfo.time[0].min/10); //分 551 2 LcdWriteData('0'+ userInfo.time[0].min % 10); 552 2 LcdWriteData(':'); 553 2 LcdWriteData('0'+userInfo.time[0].sec / 10); //秒 554 2 LcdWriteData('0'+userInfo.time[0].sec % 10); 555 2 LcdWriteData(' '); 556 2 557 2 LcdWriteData('0'+cut); 558 2 559 2 LcdWriteCom(0x80 + 0x40); 560 2 LcdWriteData('0'+ userInfo.time[1].hour/10); //时 561 2 LcdWriteData('0'+ userInfo.time[1].hour% 10); 562 2 LcdWriteData(':'); 563 2 LcdWriteData('0'+userInfo.time[1].min/10); //分 564 2 LcdWriteData('0'+ userInfo.time[1].min % 10); 565 2 LcdWriteData(':'); 566 2 LcdWriteData('0'+userInfo.time[1].sec / 10); //秒 567 2 LcdWriteData('0'+userInfo.time[1].sec % 10); 568 2 } 569 1 } 570 571 572 void Delay10ms(void) //��� 0us 573 { 574 1 unsigned char a,b,c; 575 1 for(c=1;c>0;c--) 576 1 for(b=38;b>0;b--) 577 1 for(a=130;a>0;a--); 578 1 } MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 2082 ---- CONSTANT SIZE = 5 ---- XDATA SIZE = ---- ---- PDATA SIZE = ---- ---- DATA SIZE = 42 22 IDATA SIZE = ---- ---- BIT SIZE = ---- 1 END OF MODULE INFORMATION. C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)