-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathV.cpp
99 lines (80 loc) · 2.43 KB
/
V.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
#include "V.h"
const uint8_t BATTERY_SEGMENT_WIDTH = 7;
const uint8_t BATTERY_SEGMENT_HEIGHT = 11;
const uint8_t BATTERY_SEGMENT_SPACING = 9;
RTC_DATA_ATTR uint8_t vfaceNum;
void V::drawWatchFace() {
display.fillScreen(GxEPD_BLACK);
display.setTextColor(GxEPD_WHITE);
drawTime();
drawDate();
drawBattery();
}
void V::drawTime() {
// Watchface time change structure...
if (currentTime.Minute % 60 == 0 || currentTime.Minute % 60 == 30) {
vfaceNum = (0);
} else {
vfaceNum = (1);
}
switch(vfaceNum) {
case 0:
display.drawBitmap(0, 22, V_Reaper, 80, 80, GxEPD_WHITE);
break;
case 1:
display.drawBitmap(0, 0, V_Main, 200, 200, GxEPD_WHITE);
break;
}
// Time settings...
display.setFont(&SerifBold30);
display.setCursor(35, 145);
int displayHour;
if(HOUR_12_24==12) {
displayHour = ((currentTime.Hour+11)%12)+1;
} else {
displayHour = currentTime.Hour;
}
if(displayHour < 10) {
display.print("0");
}
display.print(displayHour);
display.print(":");
if(currentTime.Minute < 10) {
display.print("0");
}
display.println(currentTime.Minute);
}
void V::drawDate() {
display.setFont(&SerifBold22);
int16_t x1, y1;
uint16_t w, h;
String monthStr = String(currentTime.Month);
String dayStr = String(currentTime.Day);
monthStr = currentTime.Month < 10 ? "" + monthStr : monthStr;
dayStr = currentTime.Day < 10 ? "" + dayStr : dayStr;
String dateStr = monthStr + "/" + dayStr;
display.getTextBounds(String(dateStr), 0, 0, &x1, &y1, &w, &h);
display.setCursor(110 - w/2, 88);
display.println(String(dateStr));
}
void V::drawBattery() {
display.drawBitmap(154, 13, battery, 37, 21, GxEPD_WHITE);
display.fillRect(159, 18, 27, BATTERY_SEGMENT_HEIGHT, GxEPD_BLACK);
int8_t batteryLevel = 0;
float VBAT = getBatteryVoltage();
if(VBAT > 4.1){
batteryLevel = 3;
}
else if(VBAT > 3.95 && VBAT <= 4.1){
batteryLevel = 2;
}
else if(VBAT > 3.80 && VBAT <= 3.95){
batteryLevel = 1;
}
else if(VBAT <= 3.80){
batteryLevel = 0;
}
for(int8_t batterySegments = 0; batterySegments < batteryLevel; batterySegments++){
display.fillRect(159 + (batterySegments * BATTERY_SEGMENT_SPACING), 18, BATTERY_SEGMENT_WIDTH, BATTERY_SEGMENT_HEIGHT, GxEPD_WHITE);
}
}