Skip to content

Commit 06014d1

Browse files
committed
Add quick access settings option
1 parent 6572b50 commit 06014d1

File tree

8 files changed

+115
-3
lines changed

8 files changed

+115
-3
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ list(APPEND SOURCE_FILES
418418
displayapp/screens/settings/SettingSetDate.cpp
419419
displayapp/screens/settings/SettingSetTime.cpp
420420
displayapp/screens/settings/SettingChimes.cpp
421+
displayapp/screens/settings/SettingQuickAccess.cpp
421422
displayapp/screens/settings/SettingShakeThreshold.cpp
422423
displayapp/screens/settings/SettingBluetooth.cpp
423424
displayapp/screens/settings/SettingOTA.cpp

src/components/settings/Settings.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ namespace Pinetime {
8787
return settings.chimesOption;
8888
};
8989

90+
void SetQuickAccessApp(Pinetime::Applications::Apps app) {
91+
if (app != settings.quickAccessApp) {
92+
settingsChanged = true;
93+
}
94+
settings.quickAccessApp = app;
95+
}
96+
97+
Pinetime::Applications::Apps GetQuickAccessApp() const {
98+
return settings.quickAccessApp;
99+
};
100+
90101
void SetPTSColorTime(Colors colorTime) {
91102
if (colorTime != settings.PTS.ColorTime)
92103
settingsChanged = true;
@@ -369,6 +380,7 @@ namespace Pinetime {
369380

370381
Pinetime::Applications::WatchFace watchFace = Pinetime::Applications::WatchFace::Digital;
371382
ChimesOption chimesOption = ChimesOption::None;
383+
Pinetime::Applications::Apps quickAccessApp = Pinetime::Applications::Apps::None;
372384

373385
PineTimeStyle PTS;
374386

src/displayapp/DisplayApp.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "displayapp/screens/settings/SettingSteps.h"
4949
#include "displayapp/screens/settings/SettingSetDateTime.h"
5050
#include "displayapp/screens/settings/SettingChimes.h"
51+
#include "displayapp/screens/settings/SettingQuickAccess.h"
5152
#include "displayapp/screens/settings/SettingHeartRate.h"
5253
#include "displayapp/screens/settings/SettingShakeThreshold.h"
5354
#include "displayapp/screens/settings/SettingBluetooth.h"
@@ -625,6 +626,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
625626
case Apps::SettingChimes:
626627
currentScreen = std::make_unique<Screens::SettingChimes>(settingsController);
627628
break;
629+
case Apps::SettingQuickAccess:
630+
currentScreen = std::make_unique<Screens::SettingQuickAccess>(settingsController);
631+
break;
628632
case Apps::SettingShakeThreshold:
629633
currentScreen = std::make_unique<Screens::SettingShakeThreshold>(settingsController, motionController, *systemTask);
630634
break;

src/displayapp/apps/Apps.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ namespace Pinetime {
4242
SettingSteps,
4343
SettingSetDateTime,
4444
SettingChimes,
45+
SettingQuickAccess,
4546
SettingShakeThreshold,
4647
SettingBluetooth,
4748
SettingOTA,

src/displayapp/fonts/fonts.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
],
1313
"bpp": 1,
1414
"size": 20,
15-
"patches": ["jetbrains_mono_bold_20.c_zero.patch", "jetbrains_mono_bold_20.c_M.patch"]
15+
"patches": [
16+
"jetbrains_mono_bold_20.c_zero.patch",
17+
"jetbrains_mono_bold_20.c_M.patch"
18+
]
1619
},
1720
"jetbrains_mono_42": {
1821
"sources": [
@@ -74,4 +77,4 @@
7477
"bpp": 1,
7578
"size": 25
7679
}
77-
}
80+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "displayapp/screens/settings/SettingQuickAccess.h"
2+
#include <lvgl/lvgl.h>
3+
#include "displayapp/DisplayApp.h"
4+
#include "displayapp/screens/Styles.h"
5+
#include "displayapp/screens/Screen.h"
6+
#include "displayapp/screens/Symbols.h"
7+
#include <array>
8+
9+
using namespace Pinetime::Applications::Screens;
10+
11+
namespace {
12+
struct Option {
13+
Pinetime::Applications::Apps app;
14+
const char* name;
15+
};
16+
17+
constexpr std::array<Option, 3> options = {{
18+
{Pinetime::Applications::Apps::Music, "Music"},
19+
{Pinetime::Applications::Apps::HeartRate, "Heart Rate"},
20+
{Pinetime::Applications::Apps::StopWatch, "Stopwatch"},
21+
}};
22+
23+
std::array<CheckboxList::Item, CheckboxList::MaxItems> CreateOptionArray() {
24+
std::array<Pinetime::Applications::Screens::CheckboxList::Item, CheckboxList::MaxItems> optionArray;
25+
for (size_t i = 0; i < CheckboxList::MaxItems; i++) {
26+
if (i >= options.size()) {
27+
optionArray[i].name = "";
28+
optionArray[i].enabled = false;
29+
} else {
30+
optionArray[i].name = options[i].name;
31+
optionArray[i].enabled = true;
32+
}
33+
}
34+
return optionArray;
35+
}
36+
37+
uint32_t GetDefaultOption(Pinetime::Applications::Apps currentApp) {
38+
for (size_t i = 0; i < options.size(); i++) {
39+
if (options[i].app == currentApp) {
40+
return i;
41+
}
42+
}
43+
return 0;
44+
}
45+
}
46+
47+
SettingQuickAccess::SettingQuickAccess(Pinetime::Controllers::Settings& settingsController)
48+
: checkboxList(
49+
0,
50+
1,
51+
"Quick Access",
52+
Symbols::list,
53+
GetDefaultOption(settingsController.GetQuickAccessApp()),
54+
[&settings = settingsController](uint32_t index) {
55+
settings.SetQuickAccessApp(options[index].app);
56+
settings.SaveSettings();
57+
},
58+
CreateOptionArray()) {
59+
}
60+
61+
SettingQuickAccess::~SettingQuickAccess() {
62+
lv_obj_clean(lv_scr_act());
63+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
#include <lvgl/lvgl.h>
5+
6+
#include "components/settings/Settings.h"
7+
#include "displayapp/screens/Screen.h"
8+
#include "displayapp/screens/CheckboxList.h"
9+
10+
namespace Pinetime {
11+
12+
namespace Applications {
13+
namespace Screens {
14+
15+
class SettingQuickAccess : public Screen {
16+
public:
17+
SettingQuickAccess(Pinetime::Controllers::Settings& settingsController);
18+
~SettingQuickAccess() override;
19+
20+
void UpdateSelected(lv_obj_t* object, lv_event_t event);
21+
22+
private:
23+
CheckboxList checkboxList;
24+
};
25+
}
26+
}
27+
}

src/displayapp/screens/settings/Settings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace Pinetime {
3434
static constexpr std::array<List::Applications, entriesPerScreen * nScreens> entries {{
3535
{Symbols::sun, "Display", Apps::SettingDisplay},
3636
{Symbols::eye, "Wake Up", Apps::SettingWakeUp},
37-
{Symbols::clock, "Time format", Apps::SettingTimeFormat},
37+
{Symbols::list, "Quick Access", Apps::SettingQuickAccess},
3838
{Symbols::home, "Watch face", Apps::SettingWatchFace},
3939

4040
{Symbols::shoe, "Steps", Apps::SettingSteps},
@@ -47,6 +47,7 @@ namespace Pinetime {
4747
{Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
4848
{Symbols::check, "Firmware", Apps::FirmwareValidation},
4949

50+
{Symbols::clock, "Time format", Apps::SettingTimeFormat},
5051
{Symbols::shieldAlt, "Over-the-air", Apps::SettingOTA},
5152
{Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth},
5253
{Symbols::list, "About", Apps::SysInfo},

0 commit comments

Comments
 (0)