Skip to content

Commit 54dcd77

Browse files
authored
Merge pull request #222 from nscooling/refactor-clock-private-statics
Moved private statics into unnamed namespace in cpp file
2 parents d22e8a4 + d34a510 commit 54dcd77

2 files changed

Lines changed: 39 additions & 39 deletions

File tree

src/displayapp/screens/Clock.cpp

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,45 @@
1515

1616
using namespace Pinetime::Applications::Screens;
1717

18+
namespace {
19+
20+
char const *DaysString[] = {
21+
"",
22+
"MONDAY",
23+
"TUESDAY",
24+
"WEDNESDAY",
25+
"THURSDAY",
26+
"FRIDAY",
27+
"SATURDAY",
28+
"SUNDAY"
29+
};
30+
31+
char const *MonthsString[] = {
32+
"",
33+
"JAN",
34+
"FEB",
35+
"MAR",
36+
"APR",
37+
"MAY",
38+
"JUN",
39+
"JUL",
40+
"AUG",
41+
"SEP",
42+
"OCT",
43+
"NOV",
44+
"DEC"
45+
};
46+
47+
const char *MonthToString(Pinetime::Controllers::DateTime::Months month) {
48+
return MonthsString[static_cast<uint8_t>(month)];
49+
}
50+
51+
const char *DayOfWeekToString(Pinetime::Controllers::DateTime::Days dayOfWeek) {
52+
return DaysString[static_cast<uint8_t>(dayOfWeek)];
53+
}
54+
55+
}
56+
1857
static void event_handler(lv_obj_t * obj, lv_event_t event) {
1958
Clock* screen = static_cast<Clock *>(obj->user_data);
2059
screen->OnObjectEvent(obj, event);
@@ -200,40 +239,6 @@ bool Clock::Refresh() {
200239
return running;
201240
}
202241

203-
const char *Clock::MonthToString(Pinetime::Controllers::DateTime::Months month) {
204-
return Clock::MonthsString[static_cast<uint8_t>(month)];
205-
}
206-
207-
const char *Clock::DayOfWeekToString(Pinetime::Controllers::DateTime::Days dayOfWeek) {
208-
return Clock::DaysString[static_cast<uint8_t>(dayOfWeek)];
209-
}
210-
211-
char const *Clock::DaysString[] = {
212-
"",
213-
"MONDAY",
214-
"TUESDAY",
215-
"WEDNESDAY",
216-
"THURSDAY",
217-
"FRIDAY",
218-
"SATURDAY",
219-
"SUNDAY"
220-
};
221-
222-
char const *Clock::MonthsString[] = {
223-
"",
224-
"JAN",
225-
"FEB",
226-
"MAR",
227-
"APR",
228-
"MAY",
229-
"JUN",
230-
"JUL",
231-
"AUG",
232-
"SEP",
233-
"OCT",
234-
"NOV",
235-
"DEC"
236-
};
237242

238243
void Clock::OnObjectEvent(lv_obj_t *obj, lv_event_t event) {
239244
if(obj == backgroundLabel) {

src/displayapp/screens/Clock.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ namespace Pinetime {
5252

5353
void OnObjectEvent(lv_obj_t *pObj, lv_event_t i);
5454
private:
55-
static const char* MonthToString(Pinetime::Controllers::DateTime::Months month);
56-
static const char* DayOfWeekToString(Pinetime::Controllers::DateTime::Days dayOfWeek);
57-
static char const *DaysString[];
58-
static char const *MonthsString[];
59-
6055
char displayedChar[5];
6156

6257
uint16_t currentYear = 1970;

0 commit comments

Comments
 (0)