forked from la3za/Multi-Face-GPS-Clock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock_custom_routines.h
158 lines (125 loc) · 7.06 KB
/
clock_custom_routines.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
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
#define NO_DK_OE_small 5
// The user may wish to customize the routines in this file according to
// desired language for day names in local time display
/////////////////////////////////////////////////////////////////////////
// Native language support for names of days of week when local time is displayed:
// additional characters for Norwegian defined in clock_Norwegian.h
// native weekday names are defined in functions nativeDay(), nativeDayLong()
//
// if LCD_NATIVE is set, day names from antiveDay() and nativeDayLong() are used
/*
From here on follows routines that the user may want to configure
*/
/////////// Change for native language day names: ////////////////////////////
void nativeDay(float j) {
/*
Print abbreviated weekday in native (= non-English language)
*/
const char* myDays[] = {"Son", "Man", "Tir", "Ons", "Tor", "Fre", "Lor"};
int addr = weekday(j) - 1;
strncpy(today, myDays[addr], 4);
if (addr == 0 | addr == 6) { // søndag, lørdag
lcd.print(today[0]);
lcd.write(NO_DK_OE_small); // ø
lcd.print(today[2]);
}
else lcd.print(today);
#ifdef FEATURE_SERIAL_MENU
Serial.println("nativeDay: ");
Serial.println(" today");
Serial.println(today);
#endif
lcd.print(" ");
}
/////////// Change for native language day names ////////////////////////////
void nativeDayLong(float j) {
/*
Print full weekday in native (= non-English language)
*/
const char* myDays[] = {"Sondag ", "Mandag ", "Tirsdag", "Onsdag ", "Torsdag", "Fredag ", "Lordag "};
int addr = weekday(j) - 1;
if (addr == 2 | addr == 4) {
strncpy(today, myDays[addr], 8);
}
else {
strncpy(today, myDays[addr], 7);
lcd.print(" ");
}
if (addr == 0 | addr == 6) { // søndag, lørdag
lcd.print(today[0]);
lcd.write(NO_DK_OE_small); // ø
lcd.print(&today[2]);
}
else lcd.print(today);
lcd.print(" ");
}
// Menu item ///////////////////////////////////////////////////////////////////////////////////////////
void TimeZones() { // local time, UTC, + many more time zones
TimeChangeRule *tcr1, *tcr2, *tcr3, *tcr4; //pointer to local time change rules, use to get TZ abbrev
time_t local1, local2, local3, local4;
char textbuffer[9];
// get global local time
local = now() + UTCoffset * 60;
Hour = hour(local);
Minute = minute(local);
Seconds = second(local);
lcd.setCursor(0, 0); // 1. line *********
sprintf(textbuffer, "%02d%c%02d", Hour, HOUR_SEP, Minute);
lcd.print(textbuffer);
lcd.print(" ");lcd.print(tcr -> abbrev);
lcd.setCursor(18,0); // end of line 1
sprintf(textbuffer, "%02d", Seconds);
lcd.print(textbuffer);
lcd.setCursor(0, 1); // 2. line *********
if (gps.time.isValid()) {
lcd.setCursor(0, 1);
sprintf(textbuffer, "%02d%c%02d UTC ", hourGPS, HOUR_SEP,minuteGPS);
lcd.print(textbuffer);
// lcd.setCursor(14, 3);
}
lcd.setCursor(0, 2); // ******** 3. line
// Indian Standard Time
TimeChangeRule inIST = {"IND", Second, Sun, Mar, 2, 330}; // Indian Standard Time = UTC - 5 hours 30 min
Timezone India(inIST, inIST);
local2 = India.toLocal(utc, &tcr2);
Hour = hour(local2);
Minute = minute(local2);
sprintf(textbuffer, "%02d%c%02d ", Hour, HOUR_SEP, Minute);
lcd.print(textbuffer);
lcd.print(tcr2 -> abbrev);
// Turkey Time
// lcd.setCursor(10, 2);
// TimeChangeRule TT = {"TUR", Second, Sun, Mar, 2, 180}; // Turkey Time = UTC - 3 hours
// Timezone Turkey(TT, TT);
// local3 = Turkey.toLocal(utc, &tcr3);
// Hour = hour(local3);
// Minute = minute(local3);
// sprintf(textbuffer, "%02d%c%02d ", Hour, HOUR_SEP, Minute);
// lcd.print(textbuffer);
// lcd.print(tcr3 -> abbrev);
lcd.setCursor(0, 3); //////// line 4
// US Eastern Time Zone (New York, Detroit)
TimeChangeRule usEDT = {"EDT", Second, Sun, Mar, 2, -240}; // Eastern Daylight Time = UTC - 4 hours
TimeChangeRule usEST = {"EST", First, Sun, Nov, 2, -300}; // Eastern Standard Time = UTC - 5 hours
Timezone usET(usEDT, usEST);
local1 = usET.toLocal(utc, &tcr1);
Hour = hour(local1);
Minute = minute(local1);
sprintf(textbuffer, "%02d%c%02d ", Hour, HOUR_SEP, Minute);
lcd.print(textbuffer);
lcd.print(tcr1 -> abbrev);
lcd.setCursor(19, 3); lcd.print(" "); // blank out rest of menu number in lower right-hand corner
// Pacific US
lcd.setCursor(10, 3);
TimeChangeRule usPDT = {"PDT", Second, Sun, Mar, 2, -420};
TimeChangeRule usPST = {"PST", First, Sun, Nov, 2, -480};
Timezone usPacific(usPDT, usPST);
local4 = usPacific.toLocal(utc, &tcr4);
Hour = hour(local4);
Minute = minute(local4);
sprintf(textbuffer, "%02d%c%02d ", Hour, HOUR_SEP, Minute);
lcd.print(textbuffer);
lcd.print(tcr4 -> abbrev);
oldminute = minuteGPS;
}
// THE END /////