@@ -17,6 +17,106 @@ namespace {
17
17
auto * screen = static_cast <WatchFaceInfineat*>(obj->user_data );
18
18
screen->UpdateSelected (obj, event);
19
19
}
20
+
21
+ enum class colors {
22
+ orange,
23
+ blue,
24
+ green,
25
+ rainbow,
26
+ gray,
27
+ nordBlue,
28
+ nordGreen,
29
+ };
30
+
31
+ constexpr int nColors = 7 ; // must match number of colors in InfineatColors
32
+
33
+ constexpr int nLines = WatchFaceInfineat::nLines;
34
+
35
+ constexpr std::array<lv_color_t , nLines> orangeColors = {LV_COLOR_MAKE (0xfd , 0x87 , 0x2b ),
36
+ LV_COLOR_MAKE (0xdb , 0x33 , 0x16 ),
37
+ LV_COLOR_MAKE (0x6f , 0x10 , 0x00 ),
38
+ LV_COLOR_MAKE (0xfd , 0x7a , 0x0a ),
39
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
40
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
41
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
42
+ LV_COLOR_MAKE (0xe8 , 0x51 , 0x02 ),
43
+ LV_COLOR_MAKE (0xea , 0x1c , 0x00 )};
44
+ constexpr std::array<lv_color_t , nLines> blueColors = {LV_COLOR_MAKE (0xe7 , 0xf8 , 0xff ),
45
+ LV_COLOR_MAKE (0x22 , 0x32 , 0xd0 ),
46
+ LV_COLOR_MAKE (0x18 , 0x2a , 0x8b ),
47
+ LV_COLOR_MAKE (0xe7 , 0xf8 , 0xff ),
48
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
49
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
50
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
51
+ LV_COLOR_MAKE (0x59 , 0x91 , 0xff ),
52
+ LV_COLOR_MAKE (0x16 , 0x36 , 0xff )};
53
+ constexpr std::array<lv_color_t , nLines> greenColors = {LV_COLOR_MAKE (0xb8 , 0xff , 0x9b ),
54
+ LV_COLOR_MAKE (0x08 , 0x86 , 0x08 ),
55
+ LV_COLOR_MAKE (0x00 , 0x4a , 0x00 ),
56
+ LV_COLOR_MAKE (0xb8 , 0xff , 0x9b ),
57
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
58
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
59
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
60
+ LV_COLOR_MAKE (0x62 , 0xd5 , 0x15 ),
61
+ LV_COLOR_MAKE (0x00 , 0x74 , 0x00 )};
62
+ constexpr std::array<lv_color_t , nLines> rainbowColors = {LV_COLOR_MAKE (0x2d , 0xa4 , 0x00 ),
63
+ LV_COLOR_MAKE (0xac , 0x09 , 0xc4 ),
64
+ LV_COLOR_MAKE (0xfe , 0x03 , 0x03 ),
65
+ LV_COLOR_MAKE (0x0d , 0x57 , 0xff ),
66
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
67
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
68
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
69
+ LV_COLOR_MAKE (0xe0 , 0xb9 , 0x00 ),
70
+ LV_COLOR_MAKE (0xe8 , 0x51 , 0x02 )};
71
+ constexpr std::array<lv_color_t , nLines> grayColors = {LV_COLOR_MAKE (0xee , 0xee , 0xee ),
72
+ LV_COLOR_MAKE (0x98 , 0x95 , 0x9b ),
73
+ LV_COLOR_MAKE (0x19 , 0x19 , 0x19 ),
74
+ LV_COLOR_MAKE (0xee , 0xee , 0xee ),
75
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
76
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
77
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
78
+ LV_COLOR_MAKE (0x91 , 0x91 , 0x91 ),
79
+ LV_COLOR_MAKE (0x3a , 0x3a , 0x3a )};
80
+ constexpr std::array<lv_color_t , nLines> nordBlueColors = {LV_COLOR_MAKE (0xc3 , 0xda , 0xf2 ),
81
+ LV_COLOR_MAKE (0x4d , 0x78 , 0xce ),
82
+ LV_COLOR_MAKE (0x15 , 0x34 , 0x51 ),
83
+ LV_COLOR_MAKE (0xc3 , 0xda , 0xf2 ),
84
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
85
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
86
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
87
+ LV_COLOR_MAKE (0x5d , 0x8a , 0xd2 ),
88
+ LV_COLOR_MAKE (0x21 , 0x51 , 0x8a )};
89
+ constexpr std::array<lv_color_t , nLines> nordGreenColors = {LV_COLOR_MAKE (0xd5 , 0xf0 , 0xe9 ),
90
+ LV_COLOR_MAKE (0x23 , 0x83 , 0x73 ),
91
+ LV_COLOR_MAKE (0x1d , 0x41 , 0x3f ),
92
+ LV_COLOR_MAKE (0xd5 , 0xf0 , 0xe9 ),
93
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
94
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
95
+ LV_COLOR_MAKE (0xff , 0xff , 0xff ),
96
+ LV_COLOR_MAKE (0x2f , 0xb8 , 0xa2 ),
97
+ LV_COLOR_MAKE (0x11 , 0x70 , 0x5a )};
98
+
99
+ constexpr const std::array<lv_color_t , nLines>* returnColor (colors color) {
100
+ if (color == colors::orange) {
101
+ return &orangeColors;
102
+ }
103
+ if (color == colors::blue) {
104
+ return &blueColors;
105
+ }
106
+ if (color == colors::green) {
107
+ return &greenColors;
108
+ }
109
+ if (color == colors::rainbow) {
110
+ return &rainbowColors;
111
+ }
112
+ if (color == colors::gray) {
113
+ return &grayColors;
114
+ }
115
+ if (color == colors::nordBlue) {
116
+ return &nordBlueColors;
117
+ }
118
+ return &nordGreenColors;
119
+ }
20
120
}
21
121
22
122
WatchFaceInfineat::WatchFaceInfineat (Controllers::DateTime& dateTimeController,
@@ -57,13 +157,12 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
57
157
58
158
static constexpr lv_style_int_t lineWidths[nLines] = {18 , 15 , 14 , 22 , 20 , 18 , 18 , 52 , 48 };
59
159
160
+ const std::array<lv_color_t , nLines>* colors = returnColor (static_cast <enum colors>(settingsController.GetInfineatColorIndex ()));
60
161
for (int i = 0 ; i < nLines; i++) {
61
162
lines[i] = lv_line_create (lv_scr_act (), nullptr );
62
163
lv_obj_set_style_local_line_width (lines[i], LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lineWidths[i]);
63
- lv_obj_set_style_local_line_color (lines[i],
64
- LV_LINE_PART_MAIN,
65
- LV_STATE_DEFAULT,
66
- lv_color_hex (infineatColors.orange [settingsController.GetInfineatColorIndex () * nLines + i]));
164
+ lv_color_t color = (*colors)[i];
165
+ lv_obj_set_style_local_line_color (lines[i], LV_LINE_PART_MAIN, LV_STATE_DEFAULT, color);
67
166
lv_line_set_points (lines[i], linePoints[i], 2 );
68
167
}
69
168
@@ -73,21 +172,15 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
73
172
74
173
lineBattery = lv_line_create (lv_scr_act (), nullptr );
75
174
lv_obj_set_style_local_line_width (lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 24 );
76
- lv_obj_set_style_local_line_color (lineBattery,
77
- LV_LINE_PART_MAIN,
78
- LV_STATE_DEFAULT,
79
- lv_color_hex (infineatColors.orange [settingsController.GetInfineatColorIndex () * nLines + 4 ]));
175
+ lv_obj_set_style_local_line_color (lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, (*colors)[4 ]);
80
176
lv_obj_set_style_local_line_opa (lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 190 );
81
177
lineBatteryPoints[0 ] = {27 , 105 };
82
178
lineBatteryPoints[1 ] = {27 , 106 };
83
179
lv_line_set_points (lineBattery, lineBatteryPoints, 2 );
84
180
lv_obj_move_foreground (lineBattery);
85
181
86
182
notificationIcon = lv_obj_create (lv_scr_act (), nullptr );
87
- lv_obj_set_style_local_bg_color (notificationIcon,
88
- LV_BTN_PART_MAIN,
89
- LV_STATE_DEFAULT,
90
- lv_color_hex (infineatColors.orange [settingsController.GetInfineatColorIndex () * nLines + 7 ]));
183
+ lv_obj_set_style_local_bg_color (notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, (*colors)[7 ]);
91
184
lv_obj_set_style_local_radius (notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
92
185
lv_obj_set_size (notificationIcon, 13 , 13 );
93
186
lv_obj_set_hidden (notificationIcon, true );
@@ -125,25 +218,26 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
125
218
lv_obj_set_size (dateContainer, 60 , 30 );
126
219
lv_obj_align (dateContainer, lv_scr_act (), LV_ALIGN_IN_RIGHT_MID, 0 , 5 );
127
220
221
+ static constexpr lv_color_t grayColor = LV_COLOR_MAKE (0x99 , 0x99 , 0x99 );
128
222
labelDate = lv_label_create (lv_scr_act (), nullptr );
129
- lv_obj_set_style_local_text_color (labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex ( 0x999999 ) );
223
+ lv_obj_set_style_local_text_color (labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor );
130
224
lv_obj_set_style_local_text_font (labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
131
225
lv_obj_align (labelDate, dateContainer, LV_ALIGN_IN_TOP_MID, 0 , 0 );
132
226
lv_label_set_text_static (labelDate, " Mon 01" );
133
227
134
228
bleIcon = lv_label_create (lv_scr_act (), nullptr );
135
- lv_obj_set_style_local_text_color (bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex ( 0x999999 ) );
229
+ lv_obj_set_style_local_text_color (bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor );
136
230
lv_label_set_text_static (bleIcon, Symbols::bluetooth);
137
231
lv_obj_align (bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0 , 0 );
138
232
139
233
stepValue = lv_label_create (lv_scr_act (), nullptr );
140
- lv_obj_set_style_local_text_color (stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex ( 0x999999 ) );
234
+ lv_obj_set_style_local_text_color (stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor );
141
235
lv_obj_set_style_local_text_font (stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
142
236
lv_obj_align (stepValue, lv_scr_act (), LV_ALIGN_IN_BOTTOM_RIGHT, 10 , 0 );
143
237
lv_label_set_text_static (stepValue, " 0" );
144
238
145
239
stepIcon = lv_label_create (lv_scr_act (), nullptr );
146
- lv_obj_set_style_local_text_color (stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex ( 0x999999 ) );
240
+ lv_obj_set_style_local_text_color (stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor );
147
241
lv_label_set_text_static (stepIcon, Symbols::shoe);
148
242
lv_obj_align (stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5 , 0 );
149
243
@@ -285,20 +379,13 @@ void WatchFaceInfineat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
285
379
settingsController.SetInfineatColorIndex (colorIndex);
286
380
}
287
381
if (object == btnNextColor || object == btnPrevColor) {
382
+ const std::array<lv_color_t , nLines>* colors = returnColor (static_cast <enum colors>(settingsController.GetInfineatColorIndex ()));
288
383
for (int i = 0 ; i < nLines; i++) {
289
- lv_obj_set_style_local_line_color (lines[i],
290
- LV_LINE_PART_MAIN,
291
- LV_STATE_DEFAULT,
292
- lv_color_hex (infineatColors.orange [colorIndex * nLines + i]));
384
+ lv_color_t color = (*colors)[i];
385
+ lv_obj_set_style_local_line_color (lines[i], LV_LINE_PART_MAIN, LV_STATE_DEFAULT, color);
293
386
}
294
- lv_obj_set_style_local_line_color (lineBattery,
295
- LV_LINE_PART_MAIN,
296
- LV_STATE_DEFAULT,
297
- lv_color_hex (infineatColors.orange [colorIndex * nLines + 4 ]));
298
- lv_obj_set_style_local_bg_color (notificationIcon,
299
- LV_BTN_PART_MAIN,
300
- LV_STATE_DEFAULT,
301
- lv_color_hex (infineatColors.orange [colorIndex * nLines + 7 ]));
387
+ lv_obj_set_style_local_line_color (lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, (*colors)[4 ]);
388
+ lv_obj_set_style_local_bg_color (notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, (*colors)[7 ]);
302
389
}
303
390
}
304
391
}
@@ -420,14 +507,9 @@ void WatchFaceInfineat::ToggleBatteryIndicatorColor(bool showSideCover) {
420
507
lv_obj_set_style_local_bg_color (notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
421
508
} else {
422
509
lv_obj_set_style_local_image_recolor_opa (logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
423
- lv_obj_set_style_local_line_color (lineBattery,
424
- LV_LINE_PART_MAIN,
425
- LV_STATE_DEFAULT,
426
- lv_color_hex (infineatColors.orange [settingsController.GetInfineatColorIndex () * nLines + 4 ]));
427
- lv_obj_set_style_local_bg_color (notificationIcon,
428
- LV_BTN_PART_MAIN,
429
- LV_STATE_DEFAULT,
430
- lv_color_hex (infineatColors.orange [settingsController.GetInfineatColorIndex () * nLines + 7 ]));
510
+ const std::array<lv_color_t , nLines>* colors = returnColor (static_cast <enum colors>(settingsController.GetInfineatColorIndex ()));
511
+ lv_obj_set_style_local_line_color (lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, (*colors)[4 ]);
512
+ lv_obj_set_style_local_bg_color (notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, (*colors)[7 ]);
431
513
}
432
514
}
433
515
0 commit comments