-
Notifications
You must be signed in to change notification settings - Fork 0
/
bahn.h
84 lines (68 loc) · 2.52 KB
/
bahn.h
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
void WatchyBrain::drawBahn(int variant, float batt) {
// ** SETUP **
int16_t x1, y1, lasty;
uint16_t w, h;
String textstring;
// ** DRAW **
//drawbg
display.fillScreen((variant == 0) ? GxEPD_WHITE : GxEPD_BLACK);
display.fillRoundRect(2, 2, 196, 196, 8, GxEPD_BLACK);
display.fillRoundRect(6, 6, 188, 188, 5, (variant == 0) ? GxEPD_WHITE : GxEPD_BLACK);
display.setFont(&DIN_1451_Engschrift_Regular64pt7b);
display.setTextColor((variant == 0) ? GxEPD_BLACK : GxEPD_WHITE);
display.setTextWrap(false);
//draw hours
textstring = currentTime.Hour;
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.setCursor(183 - w, 100 - 5);
display.print(textstring);
//draw minutes
if (currentTime.Minute < 10) {
textstring = "0";
} else {
textstring = "";
}
textstring += currentTime.Minute;
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.setCursor(183 - w, 100 + 3 + h);
display.print(textstring);
// draw battery
display.fillRoundRect(16, 16, 34, 12, 4, (variant == 0) ? GxEPD_BLACK : GxEPD_WHITE);
display.fillRoundRect(49, 20, 3, 4, 2, (variant == 0) ? GxEPD_BLACK : GxEPD_WHITE);
display.fillRoundRect(18, 18, 30, 8, 3, (variant == 0) ? GxEPD_WHITE : GxEPD_BLACK);
if (batt > 0) {
display.fillRoundRect(20, 20, 26 * batt, 4, 2, (variant == 0) ? GxEPD_BLACK : GxEPD_WHITE);
}
lasty = 200 - 16;
//draw steps
textstring = sensor.getCounter();
textstring += " steps";
display.setFont(&DIN_1451_Engschrift_Regular12pt7b);
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.fillRoundRect(16, lasty - h - 2, w + 7, h + 4, 2, (variant == 0) ? GxEPD_BLACK : GxEPD_WHITE);
display.setCursor(19, lasty - 3);
display.setTextColor((variant == 0) ? GxEPD_WHITE : GxEPD_BLACK);
display.print(textstring);
display.setTextColor((variant == 0) ? GxEPD_BLACK : GxEPD_WHITE);
lasty += -8 - h;
// draw year
textstring = currentTime.Year + 1970;
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.setCursor(16, lasty);
display.print(textstring);
lasty += -20;
// draw date
textstring = monthShortStr(currentTime.Month);
textstring += " ";
textstring += currentTime.Day;
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.setCursor(16, lasty);
display.print(textstring);
lasty += -20;
// draw day
textstring = dayStr(currentTime.Wday);
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.setCursor(16, lasty);
display.print(textstring);
lasty += -40;
}