-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.LST
123 lines (114 loc) · 5.07 KB
/
main.LST
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
C51 COMPILER V9.01 MAIN 03/18/2018 20:41:08 PAGE 1
C51 COMPILER V9.01, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Program Files (x86)\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include "main.h"
2 #include "TFT.h"
3 #include "stdio.h"
4 #include "DHT11.h"
5
6 /************* 用户系统配置 **************/
7
8 #define MAIN_Fosc 22118400L //定义主时钟, 延时会自动适应。5~35MHZ
9 #define D_TIMER0 1000 // 选择定时器时间us,注意不要溢出,溢出时编译会报错。
10
11 /******************************************/
12
13 #define Timer0_Reload_s ((MAIN_Fosc / 1000) * D_TIMER0 / 12000)
14 #if (Timer0_Reload_s < 65536)
15 #define Timer0_Reload (65536 - Timer0_Reload_s)
16 #endif
17 static unsigned long ms_cnt = 0;
18
19 static void ui_init(void)
20 {
21 1 dsp_single_colour(YELLOW);//白色
22 1 Fast_DrawFont_GBK16(5,10,BLUE,YELLOW, "温湿度实时监控");
23 1 Display_ASCII8X16_Color(0,26,"----------------",RED,YELLOW);
24 1 Fast_DrawFont_GBK16(5,42,BLUE,YELLOW, "温度:");
25 1 Fast_DrawFont_GBK16(95,42,RED,YELLOW, "℃");
26 1
27 1 Fast_DrawFont_GBK16(5,68,BLUE,YELLOW, "湿度:");
28 1 Display_ASCII8X16_Color(90,68,"%RH",RED,YELLOW);
29 1 Display_ASCII8X16_Color(0,84,"----------------",RED,YELLOW);
30 1 }
31
32 static void temperature_and_humidity_display(int temperature, int humidity)
33 {
34 1 char str_temperature[6];
35 1 char str_humidity[6];
36 1
37 1
38 1 sprintf(str_temperature, "%3d", temperature);
39 1 sprintf(str_humidity, "%3d", humidity);
40 1
41 1 Display_ASCII8X16_Color(53,42,str_temperature,BLACK,YELLOW);
42 1 Display_ASCII8X16_Color(53,68,str_humidity,BLACK,YELLOW);
43 1 }
44
45 static void timer_init(void)
46 {
47 1 TMOD |= 0x01; //Timer0 set as 16bit timer
48 1 TH0 = Timer0_Reload / 256;
49 1 TL0 = Timer0_Reload % 256;
50 1 ET0 = 1;
51 1 TR0 = 1;
52 1 EA = 1;
53 1 }
54
55 static void sys_time_display(unsigned long s_cnt)
C51 COMPILER V9.01 MAIN 03/18/2018 20:41:08 PAGE 2
56 {
57 1 char str_hour[10];
58 1 char str_min[3];
59 1 char str_sec[3];
60 1
61 1 sprintf(str_hour, "%3d", (int)s_cnt/3600);
62 1 sprintf(str_min, "%2d", (int)s_cnt/60);
63 1 sprintf(str_sec, "%2d", (int)s_cnt%60);
64 1
65 1 Display_ASCII8X16_Color(0,100,str_hour,BLACK,YELLOW);
66 1 Fast_DrawFont_GBK16(30,100,BLUE,YELLOW, "时");
67 1 Display_ASCII8X16_Color(50,100,str_min,BLACK,YELLOW);
68 1 Fast_DrawFont_GBK16(70,100,BLUE,YELLOW, "分");
69 1 Display_ASCII8X16_Color(90,100,str_sec,BLACK,YELLOW);
70 1 Fast_DrawFont_GBK16(110,100,BLUE,YELLOW, "秒");
71 1 }
72
73 void main(void)
74 {
75 1 lcd_initial();
76 1 ui_init();
77 1 timer_init();
78 1 DHT11_Read();
79 1 delay_ms(200);
80 1
81 1 while(1)
82 1 {
83 2 DHT11_Read();
84 2 temperature_and_humidity_display((int)TEM_Buffer_Int, (int)HUMI_Buffer_Int);
85 2 sys_time_display(ms_cnt/1000);
86 2 delay_ms(500);
87 2 }
88 1 }
89
90 void timer0 (void) interrupt 1
91 {
92 1 TR0 = 0;
93 1 TH0 = Timer0_Reload / 256;
94 1 TL0 = Timer0_Reload % 256;
95 1 TR0 = 1;
96 1
97 1 ms_cnt++;
98 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 703 ----
CONSTANT SIZE = 70 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 4 34
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)