Skip to content

Commit ef9f809

Browse files
authored
Merge pull request #458 from kieranc/pinetimestyle-colorpicker
Add color picker for PineTimeStyle watchface
2 parents 2870d3a + 8ac1ae7 commit ef9f809

10 files changed

Lines changed: 465 additions & 18 deletions

File tree

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ list(APPEND SOURCE_FILES
427427
displayapp/screens/settings/SettingWakeUp.cpp
428428
displayapp/screens/settings/SettingDisplay.cpp
429429
displayapp/screens/settings/SettingSteps.cpp
430+
displayapp/screens/settings/SettingPineTimeStyle.cpp
430431

431432
## Watch faces
432433
displayapp/icons/bg_clock.c

src/components/settings/Settings.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,33 @@ namespace Pinetime {
3333
return settings.clockFace;
3434
};
3535

36+
void SetPTSColorTime(uint8_t colorTime) {
37+
if (colorTime != settings.PTSColorTime)
38+
settingsChanged = true;
39+
settings.PTSColorTime = colorTime;
40+
};
41+
uint8_t GetPTSColorTime() const {
42+
return settings.PTSColorTime;
43+
};
44+
45+
void SetPTSColorBar(uint8_t colorBar) {
46+
if (colorBar != settings.PTSColorBar)
47+
settingsChanged = true;
48+
settings.PTSColorBar = colorBar;
49+
};
50+
uint8_t GetPTSColorBar() const {
51+
return settings.PTSColorBar;
52+
};
53+
54+
void SetPTSColorBG(uint8_t colorBG) {
55+
if (colorBG != settings.PTSColorBG)
56+
settingsChanged = true;
57+
settings.PTSColorBG = colorBG;
58+
};
59+
uint8_t GetPTSColorBG() const {
60+
return settings.PTSColorBG;
61+
};
62+
3663
void SetAppMenu(uint8_t menu) {
3764
appMenu = menu;
3865
};
@@ -127,7 +154,7 @@ namespace Pinetime {
127154
private:
128155
Pinetime::Controllers::FS& fs;
129156

130-
static constexpr uint32_t settingsVersion = 0x0001;
157+
static constexpr uint32_t settingsVersion = 0x0002;
131158
struct SettingsData {
132159

133160
uint32_t version = settingsVersion;
@@ -139,6 +166,10 @@ namespace Pinetime {
139166

140167
uint8_t clockFace = 0;
141168

169+
uint8_t PTSColorTime = 11;
170+
uint8_t PTSColorBar = 11;
171+
uint8_t PTSColorBG = 3;
172+
142173
std::bitset<3> wakeUpMode {0};
143174

144175
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;

src/displayapp/Apps.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ namespace Pinetime {
3030
SettingTimeFormat,
3131
SettingDisplay,
3232
SettingWakeUp,
33-
SettingSteps
33+
SettingSteps,
34+
SettingPineTimeStyle
3435
};
3536
}
3637
}

src/displayapp/DisplayApp.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "displayapp/screens/settings/SettingWakeUp.h"
4343
#include "displayapp/screens/settings/SettingDisplay.h"
4444
#include "displayapp/screens/settings/SettingSteps.h"
45+
#include "displayapp/screens/settings/SettingPineTimeStyle.h"
4546

4647
#include "libs/lv_conf.h"
4748

@@ -370,6 +371,10 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
370371
currentScreen = std::make_unique<Screens::SettingSteps>(this, settingsController);
371372
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
372373
break;
374+
case Apps::SettingPineTimeStyle:
375+
currentScreen = std::make_unique<Screens::SettingPineTimeStyle>(this, settingsController);
376+
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
377+
break;
373378
case Apps::BatteryInfo:
374379
currentScreen = std::make_unique<Screens::BatteryInfo>(this, batteryController);
375380
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);

src/displayapp/screens/PineTimeStyle.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
5151
notificatioManager {notificatioManager},
5252
settingsController {settingsController},
5353
motionController {motionController} {
54-
/* This sets the watchface number to return to after leaving the menu */
54+
55+
// This sets the watchface number to return to after leaving the menu
5556
settingsController.SetClockFace(2);
5657

5758
displayedChar[0] = 0;
@@ -60,40 +61,40 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
6061
displayedChar[3] = 0;
6162
displayedChar[4] = 0;
6263

63-
/* Create a 200px wide background rectangle */
64+
//Create a 200px wide background rectangle
6465
timebar = lv_obj_create(lv_scr_act(), nullptr);
65-
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
66+
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBG()]);
6667
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
6768
lv_obj_set_size(timebar, 200, 240);
6869
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
6970

70-
/* Display the time */
71+
// Display the time
7172
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
7273
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
73-
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
74+
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
7475
lv_label_set_text(timeDD1, "12");
7576
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
7677

7778
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
7879
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
79-
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
80+
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
8081
lv_label_set_text(timeDD2, "34");
8182
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
8283

8384
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
84-
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
85+
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
8586
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
8687
lv_label_set_text(timeAMPM, "");
8788
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
8889

89-
/* Create a 40px wide bar down the right side of the screen */
90+
// Create a 40px wide bar down the right side of the screen
9091
sidebar = lv_obj_create(lv_scr_act(), nullptr);
91-
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
92+
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBar()]);
9293
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
9394
lv_obj_set_size(sidebar, 40, 240);
9495
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
9596

96-
/* Display icons */
97+
// Display icons
9798
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
9899
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
99100
lv_label_set_text(batteryIcon, Symbols::batteryFull);
@@ -111,7 +112,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
111112
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
112113
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 40);
113114

114-
/* Calendar icon */
115+
// Calendar icon
115116
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
116117
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
117118
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
@@ -148,7 +149,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
148149
lv_obj_set_size(calendarCrossBar2, 8, 3);
149150
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
150151

151-
/* Display date */
152+
// Display date
152153
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
153154
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
154155
lv_label_set_text(dateDayOfWeek, "THU");
@@ -184,7 +185,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
184185
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
185186
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
186187
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
187-
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
188+
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
188189
lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
189190

190191
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);

src/displayapp/screens/PineTimeStyle.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ namespace Pinetime {
6868
lv_obj_t* notificationIcon;
6969
lv_obj_t* stepGauge;
7070
lv_color_t needle_colors[1];
71+
lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK,
72+
LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE,
73+
LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL,
74+
LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE,
75+
LV_COLOR_ORANGE};
7176

7277
Controllers::DateTime& dateTimeController;
7378
Controllers::Battery& batteryController;

0 commit comments

Comments
 (0)