-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI_Pomodoro.cpp
328 lines (302 loc) · 11.2 KB
/
GUI_Pomodoro.cpp
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#include "SmartClock.h"
void Pomodoro_StartPage()
{
DEV_Module_Init();
EPD_2IN9_Init(FULL_REFRESH);
EPD_2IN9_Display(Image_Pomodoro_StartPage);
EPD_2IN9_Sleep();
}
void Pomodoro_ExitConfirm()
{
DEV_Module_Init();
EPD_2IN9_Init(FULL_REFRESH);
EPD_2IN9_Display(Image_Pomodoro_ExitConfirm);
EPD_2IN9_Sleep();
}
void Pomodoro_HomePage_FullRefresh(UBYTE *Canvas, TimeAndDate TimeData, short battery_level, short PomodoroStatus, short time_remaining, float temper, short humidity, short tomato_number)
{
DEV_Module_Init();
EPD_2IN9_Init(FULL_REFRESH);
Paint_NewImage(Canvas, EPD_2IN9_WIDTH, EPD_2IN9_HEIGHT, 90, WHITE);
Paint_SelectImage(Canvas);
Paint_Clear(WHITE);
Paint_DrawBitMap(Image_Pomodoro_HomePage);
// DrawNowTime
char t_hour[5];
char t_min[5];
TransNumberToStandNumberChar(t_hour, TimeData.hour);
TransNumberToStandNumberChar(t_min, TimeData.minute);
Paint_DrawString_EN(129, 3, t_hour, &Font12, BLACK, WHITE);
Paint_DrawString_EN(144, 3, ":", &Font12, BLACK, WHITE);
Paint_DrawString_EN(152, 3, t_min, &Font12, BLACK, WHITE);
// DrawBatteryLevel
switch (battery_level)
{
case 4:
Paint_DrawImage(REVERSE_BatteryIcon_4, 117, (280 - 1), 16, 16); // Y轴坐标为1
break;
case 3:
Paint_DrawImage(REVERSE_BatteryIcon_3, 117, (280 - 1), 16, 16); // Y轴坐标为1
break;
case 2:
Paint_DrawImage(REVERSE_BatteryIcon_2, 117, (280 - 1), 16, 16); // Y轴坐标为1
break;
case 1:
Paint_DrawImage(REVERSE_BatteryIcon_1, 117, (280 - 1), 16, 16); // Y轴坐标为1
break;
case 0:
Paint_DrawImage(REVERSE_BatteryIcon_0, 117, (280 - 1), 16, 16); // Y轴坐标为1
break;
}
// DrawSlogan
if (PomodoroStatus == STATUS_WORKING && time_remaining >= 20)
{
Paint_DrawString_CN(60, 21, "良好的开始是成功的一半", &Font16CN, BLACK, WHITE);
}
else if (PomodoroStatus == STATUS_WORKING && time_remaining > 5)
{
Paint_DrawString_CN(52, 21, "从来没有一种坚持会被辜负", &Font16CN, BLACK, WHITE);
}
else if (PomodoroStatus == STATUS_WORKING)
{
Paint_DrawString_CN(108, 21, "快要成功啦~", &Font16CN, BLACK, WHITE);
}
else if (PomodoroStatus == STATUS_REST_LESS5)
{
Paint_DrawString_CN(108, 21, "休息一下吧~", &Font16CN, BLACK, WHITE);
}
else if (PomodoroStatus == STATUS_REST_5)
{
Paint_DrawString_CN(10, 21, "连续完成", &Font16CN, BLACK, WHITE);
Paint_DrawString_EN(75, 21, "5", &Font20, BLACK, WHITE);
Paint_DrawString_CN(90, 21, "个番茄时钟了,休息一下吧~", &Font16CN, BLACK, WHITE);
}
// DrawTimeRemaining
char c_timeremaining[5];
TransNumberToStandNumberChar(c_timeremaining, time_remaining);
// DrawMin1
switch (c_timeremaining[0])
{
case '0':
Paint_DrawImage(Pomodoro_Num_0, 35, (114 - 1), 56, 35); // Y轴坐标为41
break;
case '1':
Paint_DrawImage(Pomodoro_Num_1, 35, (114 - 1), 56, 35); // Y轴坐标为41
break;
case '2':
Paint_DrawImage(Pomodoro_Num_2, 35, (114 - 1), 56, 35); // Y轴坐标为41
break;
}
// DrawMin2
switch (c_timeremaining[1])
{
case '0':
Paint_DrawImage(Pomodoro_Num_0, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '1':
Paint_DrawImage(Pomodoro_Num_1, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '2':
Paint_DrawImage(Pomodoro_Num_2, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '3':
Paint_DrawImage(Pomodoro_Num_3, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '4':
Paint_DrawImage(Pomodoro_Num_4, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '5':
Paint_DrawImage(Pomodoro_Num_5, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '6':
Paint_DrawImage(Pomodoro_Num_6, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '7':
Paint_DrawImage(Pomodoro_Num_7, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '8':
Paint_DrawImage(Pomodoro_Num_8, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '9':
Paint_DrawImage(Pomodoro_Num_9, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
}
// DrawTimeRemainingBar
if ((PomodoroStatus == STATUS_WORKING || PomodoroStatus == STATUS_REST_5) && time_remaining < 25)
{
Paint_DrawLine(89, 104, 85 + 5 * (25 - time_remaining), 104, BLACK, DOT_PIXEL_3X3, LINE_STYLE_SOLID);
}
else if (time_remaining < 5)
{
Paint_DrawLine(89, 104, 85 + 25 * (5 - time_remaining), 104, BLACK, DOT_PIXEL_3X3, LINE_STYLE_SOLID);
}
// DrawTemper
char c_temp[10];
String s_temp = String(temper, 1);
strcpy(c_temp, s_temp.c_str());
short temp_str_len = strlen(c_temp);
Paint_DrawString_EN(36, 115, c_temp, &Font12, BLACK, WHITE);
Paint_DrawString_CN(36 + 7 * temp_str_len + 1, 115, "℃", &Font12CN, BLACK, WHITE);
// DrawHumidity
char c_humidity[5];
itoa(humidity, c_humidity, 10);
short humidity_str_len = strlen(c_humidity);
Paint_DrawString_EN(146, 115, c_humidity, &Font12, BLACK, WHITE);
Paint_DrawString_EN(146 + 7 * humidity_str_len + 1, 115, "%", &Font12, BLACK, WHITE);
// DrawTomatoNumber
char c_TomatoNumber[5];
itoa(tomato_number, c_TomatoNumber, 10);
Paint_DrawString_EN(237, 115, c_TomatoNumber, &Font12, BLACK, WHITE);
EPD_2IN9_Display(Canvas);
EPD_2IN9_Sleep();
}
void Pomodoro_HomePage_PartRefresh_ExceptTomatoNumber(UBYTE *Canvas, TimeAndDate TimeData, short battery_level, short PomodoroStatus, short time_remaining, float temper, short humidity)
{
DEV_Module_Init();
EPD_2IN9_Init(PART_REFRESH);
Paint_SelectImage(Canvas);
// DrawNowTime
Paint_ClearWindows(128, 2, 168, 16, WHITE);
char t_hour[5];
char t_min[5];
TransNumberToStandNumberChar(t_hour, TimeData.hour);
TransNumberToStandNumberChar(t_min, TimeData.minute);
Paint_DrawString_EN(129, 3, t_hour, &Font12, BLACK, WHITE);
Paint_DrawString_EN(144, 3, ":", &Font12, BLACK, WHITE);
Paint_DrawString_EN(152, 3, t_min, &Font12, BLACK, WHITE);
// DrawBatteryLevel
Paint_ClearWindows(278, 1, 296, 16, WHITE);
switch (battery_level)
{
case 4:
Paint_DrawImage(REVERSE_BatteryIcon_4, 117, (280 - 1), 16, 16); // Y轴坐标为1
break;
case 3:
Paint_DrawImage(REVERSE_BatteryIcon_3, 117, (280 - 1), 16, 16); // Y轴坐标为1
break;
case 2:
Paint_DrawImage(REVERSE_BatteryIcon_2, 117, (280 - 1), 16, 16); // Y轴坐标为1
break;
case 1:
Paint_DrawImage(REVERSE_BatteryIcon_1, 117, (280 - 1), 16, 16); // Y轴坐标为1
break;
case 0:
Paint_DrawImage(REVERSE_BatteryIcon_0, 117, (280 - 1), 16, 16); // Y轴坐标为1
break;
}
// DrawSlogan
Paint_ClearWindows(1, 20, 295, 38, WHITE);
if (PomodoroStatus == STATUS_WORKING && time_remaining >= 20)
{
Paint_DrawString_CN(60, 21, "良好的开始是成功的一半", &Font16CN, BLACK, WHITE);
}
else if (PomodoroStatus == STATUS_WORKING && time_remaining > 5)
{
Paint_DrawString_CN(52, 21, "从来没有一种坚持会被辜负", &Font16CN, BLACK, WHITE);
}
else if (PomodoroStatus == STATUS_WORKING)
{
Paint_DrawString_CN(108, 21, "快要成功啦~", &Font16CN, BLACK, WHITE);
}
else if (PomodoroStatus == STATUS_REST_LESS5)
{
Paint_DrawString_CN(108, 21, "休息一下吧~", &Font16CN, BLACK, WHITE);
}
else if (PomodoroStatus == STATUS_REST_5)
{
Paint_DrawString_CN(10, 21, "连续完成", &Font16CN, BLACK, WHITE);
Paint_DrawString_EN(75, 21, "5", &Font20, BLACK, WHITE);
Paint_DrawString_CN(90, 21, "个番茄时钟了,休息一下吧~", &Font16CN, BLACK, WHITE);
}
// DrawTimeRemaining
Paint_ClearWindows(113, 40, 186, 98, WHITE);
char c_timeremaining[5];
TransNumberToStandNumberChar(c_timeremaining, time_remaining);
// DrawMin1
switch (c_timeremaining[0])
{
case '0':
Paint_DrawImage(Pomodoro_Num_0, 35, (114 - 1), 56, 35); // Y轴坐标为41
break;
case '1':
Paint_DrawImage(Pomodoro_Num_1, 35, (114 - 1), 56, 35); // Y轴坐标为41
break;
case '2':
Paint_DrawImage(Pomodoro_Num_2, 35, (114 - 1), 56, 35); // Y轴坐标为41
break;
}
// DrawMin2
switch (c_timeremaining[1])
{
case '0':
Paint_DrawImage(Pomodoro_Num_0, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '1':
Paint_DrawImage(Pomodoro_Num_1, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '2':
Paint_DrawImage(Pomodoro_Num_2, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '3':
Paint_DrawImage(Pomodoro_Num_3, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '4':
Paint_DrawImage(Pomodoro_Num_4, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '5':
Paint_DrawImage(Pomodoro_Num_5, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '6':
Paint_DrawImage(Pomodoro_Num_6, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '7':
Paint_DrawImage(Pomodoro_Num_7, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '8':
Paint_DrawImage(Pomodoro_Num_8, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
case '9':
Paint_DrawImage(Pomodoro_Num_9, 35, (150 - 1), 56, 35); // Y轴坐标为41
break;
}
// DrawTimeRemainingBar
Paint_ClearWindows(87, 102, 210, 105, WHITE);
if ((PomodoroStatus == STATUS_WORKING || PomodoroStatus == STATUS_REST_5) && time_remaining < 25)
{
Paint_DrawLine(89, 104, 85 + 5 * (25 - time_remaining), 104, BLACK, DOT_PIXEL_3X3, LINE_STYLE_SOLID);
}
else if (time_remaining < 5)
{
Paint_DrawLine(89, 104, 85 + 25 * (5 - time_remaining), 104, BLACK, DOT_PIXEL_3X3, LINE_STYLE_SOLID);
}
// DrawTemper
Paint_ClearWindows(35, 114, 105, 128, WHITE);
char c_temp[10];
String s_temp = String(temper, 1);
strcpy(c_temp, s_temp.c_str());
short temp_str_len = strlen(c_temp);
Paint_DrawString_EN(36, 115, c_temp, &Font12, BLACK, WHITE);
Paint_DrawString_CN(36 + 7 * temp_str_len + 1, 115, "℃", &Font12CN, BLACK, WHITE);
// DrawHumidity
Paint_ClearWindows(145, 114, 208, 128, WHITE);
char c_humidity[5];
itoa(humidity, c_humidity, 10);
short humidity_str_len = strlen(c_humidity);
Paint_DrawString_EN(146, 115, c_humidity, &Font12, BLACK, WHITE);
Paint_DrawString_EN(146 + 7 * humidity_str_len + 1, 115, "%", &Font12, BLACK, WHITE);
EPD_2IN9_Display(Canvas);
EPD_2IN9_Sleep();
}
void Pomodoro_HomePage_PartRefresh_TomatoNumber(UBYTE *Canvas, short tomato_number)
{
DEV_Module_Init();
EPD_2IN9_Init(PART_REFRESH);
Paint_SelectImage(Canvas);
// DrawTomatoNumber
Paint_ClearWindows(236, 114, 295, 128, WHITE);
char c_TomatoNumber[5];
itoa(tomato_number, c_TomatoNumber, 10);
Paint_DrawString_EN(237, 115, c_TomatoNumber, &Font12, BLACK, WHITE);
EPD_2IN9_Display(Canvas);
EPD_2IN9_Sleep();
}