-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.c
135 lines (128 loc) · 2.26 KB
/
display.c
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
124
125
126
127
128
129
130
131
132
133
134
135
#include "display.h"
#include "oled.h"
void display_year(unsigned char a,unsigned char flag)//flag为1 时,显示数据,0时对应清除屏幕
{
if(flag)
{
OLED_ShowChar(24, 0, a/10+'0',16);//年
OLED_ShowChar(32, 0, a%10+'0',16);
}
else
{
//清除年位
OLED_ClearChar(24, 0);
}
}
void display_month(unsigned char a,unsigned char flag)
{
if(flag)
{
OLED_ShowChar(56, 0, a/10+'0',16);//月
OLED_ShowChar(64, 0, a%10+'0',16);
}
else
{
//清除月位
OLED_ClearChar(56, 0);
}
}
void display_day(unsigned char a,unsigned char flag)
{
if(flag)
{
OLED_ShowChar(88, 0, a/10+'0',16);//日
OLED_ShowChar(96, 0, a%10+'0',16);
}
else
{
//清除日位
OLED_ClearChar(88, 0);
}
}
void display_hour(unsigned char a,unsigned char flag)
{
if(flag)
{
OLED_ShowChar(20, 3, a/10+'0',16);//时
OLED_ShowChar(28, 3, a%10+'0',16);
}
else
{
//清除时位
OLED_ClearChar(20, 3);
}
}
void display_min(unsigned char a,unsigned char flag)
{
if(flag)
{
OLED_ShowChar(56, 3, a/10+'0',16);//分
OLED_ShowChar(64, 3, a%10+'0',16);
}
else
{
//清除分位
OLED_ClearChar(56, 3);
}
}
void display_sec(unsigned char a,unsigned char flag)
{
if(flag)
{
OLED_ShowChar(92, 3, a/10+'0',16);//秒
OLED_ShowChar(100, 3, a%10+'0',16);
}
else
{
//清除秒位
OLED_ClearChar(92, 3);
}
}
void display_tmp(unsigned char a,unsigned char flag)
{
if(flag)
{
OLED_ShowNum(38,6,a,3,16);//显示温度
}
else
{
//清除温度位
OLED_ClearChar(38, 6);
OLED_ClearChar(46, 6);
}
}
void display_shidu(unsigned char a,unsigned char flag)
{
if(flag)
{
OLED_ShowNum(104,6,a,3,16);//显示湿度
}
else
{
//清除湿度位
OLED_ClearChar(104, 6);
OLED_ClearChar(112, 6);
}
}
void display(unsigned char a,unsigned char flag,unsigned char shift)
{
switch(shift)
{
case 0: display_sec(a,flag); break;
case 1: display_min(a,flag); break;
case 2: display_hour(a,flag); break;
case 3: display_day(a,flag); break;
case 4: display_month(a,flag); break;
case 5: display_year(a,flag); break;
default : break;
}
}
void display2(unsigned char a,unsigned char flag,unsigned char shift)
{
switch(shift)
{
case 0: display_tmp(a,flag); break;
case 1: display_shidu(a,flag); break;
default : break;
}
}