mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 23:21:53 +02:00
Merge 777badf62c
into 3a0d673df4
This commit is contained in:
commit
94b4fa527f
|
@ -416,6 +416,7 @@ list(APPEND SOURCE_FILES
|
||||||
displayapp/screens/settings/SettingSetDate.cpp
|
displayapp/screens/settings/SettingSetDate.cpp
|
||||||
displayapp/screens/settings/SettingSetTime.cpp
|
displayapp/screens/settings/SettingSetTime.cpp
|
||||||
displayapp/screens/settings/SettingChimes.cpp
|
displayapp/screens/settings/SettingChimes.cpp
|
||||||
|
displayapp/screens/settings/SettingAutoOpen.cpp
|
||||||
displayapp/screens/settings/SettingShakeThreshold.cpp
|
displayapp/screens/settings/SettingShakeThreshold.cpp
|
||||||
displayapp/screens/settings/SettingBluetooth.cpp
|
displayapp/screens/settings/SettingBluetooth.cpp
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
#include "components/ble/MusicService.h"
|
#include "components/ble/MusicService.h"
|
||||||
#include "components/ble/NimbleController.h"
|
#include "components/ble/NimbleController.h"
|
||||||
|
#include "systemtask/SystemTask.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -53,7 +54,8 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pinetime::Controllers::MusicService::MusicService(Pinetime::Controllers::NimbleController& nimble) : nimble(nimble) {
|
Pinetime::Controllers::MusicService::MusicService(Pinetime::System::SystemTask& systemTask, Pinetime::Controllers::NimbleController& nimble)
|
||||||
|
: systemTask {systemTask}, nimble(nimble) {
|
||||||
characteristicDefinition[0] = {.uuid = &msEventCharUuid.u,
|
characteristicDefinition[0] = {.uuid = &msEventCharUuid.u,
|
||||||
.access_cb = MusicCallback,
|
.access_cb = MusicCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
|
@ -152,6 +154,7 @@ int Pinetime::Controllers::MusicService::OnCommand(struct ble_gatt_access_ctxt*
|
||||||
// These variables need to be updated, because the progress may not be updated immediately,
|
// These variables need to be updated, because the progress may not be updated immediately,
|
||||||
// leading to getProgress() returning an incorrect position.
|
// leading to getProgress() returning an incorrect position.
|
||||||
if (playing) {
|
if (playing) {
|
||||||
|
systemTask.PushMessage(Pinetime::System::Messages::OnMusicStarted);
|
||||||
trackProgressUpdateTime = xTaskGetTickCount();
|
trackProgressUpdateTime = xTaskGetTickCount();
|
||||||
} else {
|
} else {
|
||||||
trackProgress +=
|
trackProgress +=
|
||||||
|
|
|
@ -27,12 +27,17 @@
|
||||||
#undef min
|
#undef min
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
|
|
||||||
|
namespace System {
|
||||||
|
class SystemTask;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
class NimbleController;
|
class NimbleController;
|
||||||
|
|
||||||
class MusicService {
|
class MusicService {
|
||||||
public:
|
public:
|
||||||
explicit MusicService(NimbleController& nimble);
|
explicit MusicService(Pinetime::System::SystemTask& systemTask, NimbleController& nimble);
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
|
@ -87,6 +92,7 @@ namespace Pinetime {
|
||||||
bool repeat {false};
|
bool repeat {false};
|
||||||
bool shuffle {false};
|
bool shuffle {false};
|
||||||
|
|
||||||
|
Pinetime::System::SystemTask& systemTask;
|
||||||
NimbleController& nimble;
|
NimbleController& nimble;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "components/ble/NavigationService.h"
|
#include "components/ble/NavigationService.h"
|
||||||
|
#include "systemtask/SystemTask.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// 0001yyxx-78fc-48fe-8e23-433b3a1942d0
|
// 0001yyxx-78fc-48fe-8e23-433b3a1942d0
|
||||||
|
@ -43,7 +44,7 @@ namespace {
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Pinetime::Controllers::NavigationService::NavigationService() {
|
Pinetime::Controllers::NavigationService::NavigationService(Pinetime::System::SystemTask& systemTask) : systemTask {systemTask} {
|
||||||
characteristicDefinition[0] = {.uuid = &navFlagCharUuid.u,
|
characteristicDefinition[0] = {.uuid = &navFlagCharUuid.u,
|
||||||
.access_cb = NAVCallback,
|
.access_cb = NAVCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
|
@ -96,6 +97,7 @@ int Pinetime::Controllers::NavigationService::OnCommand(struct ble_gatt_access_c
|
||||||
} else if (ble_uuid_cmp(ctxt->chr->uuid, &navProgressCharUuid.u) == 0) {
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, &navProgressCharUuid.u) == 0) {
|
||||||
m_progress = data[0];
|
m_progress = data[0];
|
||||||
}
|
}
|
||||||
|
systemTask.PushMessage(Pinetime::System::Messages::OnNavChange);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,16 @@
|
||||||
#undef min
|
#undef min
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
|
|
||||||
|
namespace System {
|
||||||
|
class SystemTask;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
|
|
||||||
class NavigationService {
|
class NavigationService {
|
||||||
public:
|
public:
|
||||||
NavigationService();
|
explicit NavigationService(Pinetime::System::SystemTask& systemTask);
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
|
@ -53,6 +58,8 @@ namespace Pinetime {
|
||||||
std::string m_narrative;
|
std::string m_narrative;
|
||||||
std::string m_manDist;
|
std::string m_manDist;
|
||||||
int m_progress;
|
int m_progress;
|
||||||
|
|
||||||
|
Pinetime::System::SystemTask& systemTask;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,9 @@ NimbleController::NimbleController(Pinetime::System::SystemTask& systemTask,
|
||||||
anService {systemTask, notificationManager},
|
anService {systemTask, notificationManager},
|
||||||
alertNotificationClient {systemTask, notificationManager},
|
alertNotificationClient {systemTask, notificationManager},
|
||||||
currentTimeService {dateTimeController},
|
currentTimeService {dateTimeController},
|
||||||
musicService {*this},
|
musicService {systemTask, *this},
|
||||||
weatherService {dateTimeController},
|
weatherService {dateTimeController},
|
||||||
|
navService {systemTask},
|
||||||
batteryInformationService {batteryController},
|
batteryInformationService {batteryController},
|
||||||
immediateAlertService {systemTask, notificationManager},
|
immediateAlertService {systemTask, notificationManager},
|
||||||
heartRateService {*this, heartRateController},
|
heartRateService {*this, heartRateController},
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Pinetime {
|
||||||
enum class Notification : uint8_t { On, Off, Sleep };
|
enum class Notification : uint8_t { On, Off, Sleep };
|
||||||
enum class ChimesOption : uint8_t { None, Hours, HalfHours };
|
enum class ChimesOption : uint8_t { None, Hours, HalfHours };
|
||||||
enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, RaiseWrist = 2, Shake = 3, LowerWrist = 4 };
|
enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, RaiseWrist = 2, Shake = 3, LowerWrist = 4 };
|
||||||
|
enum class AutoOpen : uint8_t { Battery = 0, Music = 1, Navigation = 2 };
|
||||||
enum class Colors : uint8_t {
|
enum class Colors : uint8_t {
|
||||||
White,
|
White,
|
||||||
Silver,
|
Silver,
|
||||||
|
@ -268,6 +269,21 @@ namespace Pinetime {
|
||||||
return getWakeUpModes()[static_cast<size_t>(mode)];
|
return getWakeUpModes()[static_cast<size_t>(mode)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetAutoOpen(AutoOpen app, bool enabled) {
|
||||||
|
if (enabled != IsAutoOpenOn(app)) {
|
||||||
|
settingsChanged = true;
|
||||||
|
}
|
||||||
|
settings.autoOpen.set(static_cast<size_t>(app), enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsAutoOpenOn(const AutoOpen app) const {
|
||||||
|
return GetAutoOpen()[static_cast<size_t>(app)];
|
||||||
|
}
|
||||||
|
|
||||||
|
std::bitset<3> GetAutoOpen() const {
|
||||||
|
return settings.autoOpen;
|
||||||
|
}
|
||||||
|
|
||||||
void SetBrightness(Controllers::BrightnessController::Levels level) {
|
void SetBrightness(Controllers::BrightnessController::Levels level) {
|
||||||
if (level != settings.brightLevel) {
|
if (level != settings.brightLevel) {
|
||||||
settingsChanged = true;
|
settingsChanged = true;
|
||||||
|
@ -325,6 +341,8 @@ namespace Pinetime {
|
||||||
uint16_t shakeWakeThreshold = 150;
|
uint16_t shakeWakeThreshold = 150;
|
||||||
|
|
||||||
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
|
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium;
|
||||||
|
|
||||||
|
std::bitset<3> autoOpen {0b000};
|
||||||
};
|
};
|
||||||
|
|
||||||
SettingsData settings;
|
SettingsData settings;
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "displayapp/screens/settings/SettingSteps.h"
|
#include "displayapp/screens/settings/SettingSteps.h"
|
||||||
#include "displayapp/screens/settings/SettingSetDateTime.h"
|
#include "displayapp/screens/settings/SettingSetDateTime.h"
|
||||||
#include "displayapp/screens/settings/SettingChimes.h"
|
#include "displayapp/screens/settings/SettingChimes.h"
|
||||||
|
#include "displayapp/screens/settings/SettingAutoOpen.h"
|
||||||
#include "displayapp/screens/settings/SettingShakeThreshold.h"
|
#include "displayapp/screens/settings/SettingShakeThreshold.h"
|
||||||
#include "displayapp/screens/settings/SettingBluetooth.h"
|
#include "displayapp/screens/settings/SettingBluetooth.h"
|
||||||
|
|
||||||
|
@ -327,6 +328,22 @@ void DisplayApp::Refresh() {
|
||||||
case Messages::NewNotification:
|
case Messages::NewNotification:
|
||||||
LoadNewScreen(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down);
|
LoadNewScreen(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down);
|
||||||
break;
|
break;
|
||||||
|
case Messages::MusicStarted:
|
||||||
|
if (currentApp == Apps::Clock && AppAvailable(Apps::Music)) {
|
||||||
|
if (state != States::Running) {
|
||||||
|
PushMessageToSystemTask(System::Messages::GoToRunning);
|
||||||
|
}
|
||||||
|
LoadNewScreen(Apps::Music, DisplayApp::FullRefreshDirections::Up);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Messages::NavStarted:
|
||||||
|
if (currentApp == Apps::Clock && AppAvailable(Apps::Navigation)) {
|
||||||
|
if (state != States::Running) {
|
||||||
|
PushMessageToSystemTask(System::Messages::GoToRunning);
|
||||||
|
}
|
||||||
|
LoadNewScreen(Apps::Navigation, DisplayApp::FullRefreshDirections::Up);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case Messages::TimerDone:
|
case Messages::TimerDone:
|
||||||
if (state != States::Running) {
|
if (state != States::Running) {
|
||||||
PushMessageToSystemTask(System::Messages::GoToRunning);
|
PushMessageToSystemTask(System::Messages::GoToRunning);
|
||||||
|
@ -447,9 +464,26 @@ void DisplayApp::Refresh() {
|
||||||
break;
|
break;
|
||||||
case Messages::OnChargingEvent:
|
case Messages::OnChargingEvent:
|
||||||
RestoreBrightness();
|
RestoreBrightness();
|
||||||
|
switch (currentApp) {
|
||||||
|
case Apps::Clock:
|
||||||
|
if (batteryController.IsCharging() && settingsController.IsAutoOpenOn(Controllers::Settings::AutoOpen::Battery)) {
|
||||||
|
// Open the battery app if on the clock screen
|
||||||
|
LoadNewScreen(Apps::BatteryInfo, DisplayApp::FullRefreshDirections::None);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Apps::BatteryInfo:
|
||||||
|
if (!batteryController.IsCharging()) {
|
||||||
|
// Close the battery app after being unplugged
|
||||||
|
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Vibrate normally otherwise as to not close any open app
|
||||||
motorController.RunForDuration(15);
|
motorController.RunForDuration(15);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (touchHandler.IsTouching()) {
|
if (touchHandler.IsTouching()) {
|
||||||
|
@ -586,6 +620,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||||
case Apps::SettingChimes:
|
case Apps::SettingChimes:
|
||||||
currentScreen = std::make_unique<Screens::SettingChimes>(settingsController);
|
currentScreen = std::make_unique<Screens::SettingChimes>(settingsController);
|
||||||
break;
|
break;
|
||||||
|
case Apps::SettingAutoOpen:
|
||||||
|
currentScreen = std::make_unique<Screens::SettingAutoOpen>(settingsController);
|
||||||
|
break;
|
||||||
case Apps::SettingShakeThreshold:
|
case Apps::SettingShakeThreshold:
|
||||||
currentScreen = std::make_unique<Screens::SettingShakeThreshold>(settingsController, motionController, *systemTask);
|
currentScreen = std::make_unique<Screens::SettingShakeThreshold>(settingsController, motionController, *systemTask);
|
||||||
break;
|
break;
|
||||||
|
@ -624,6 +661,13 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||||
currentApp = app;
|
currentApp = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DisplayApp::AppAvailable(Apps app) {
|
||||||
|
const auto* d = std::find_if(userApps.begin(), userApps.end(), [app](const AppDescription& appDescription) {
|
||||||
|
return appDescription.app == app;
|
||||||
|
});
|
||||||
|
return d != userApps.end();
|
||||||
|
}
|
||||||
|
|
||||||
void DisplayApp::PushMessage(Messages msg) {
|
void DisplayApp::PushMessage(Messages msg) {
|
||||||
if (in_isr()) {
|
if (in_isr()) {
|
||||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
|
@ -131,6 +131,7 @@ namespace Pinetime {
|
||||||
DisplayApp::FullRefreshDirections nextDirection;
|
DisplayApp::FullRefreshDirections nextDirection;
|
||||||
System::BootErrors bootError;
|
System::BootErrors bootError;
|
||||||
void ApplyBrightness();
|
void ApplyBrightness();
|
||||||
|
bool AppAvailable(Apps app);
|
||||||
|
|
||||||
static constexpr size_t returnAppStackSize = 10;
|
static constexpr size_t returnAppStackSize = 10;
|
||||||
Utility::StaticStack<Apps, returnAppStackSize> returnAppStack;
|
Utility::StaticStack<Apps, returnAppStackSize> returnAppStack;
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace Pinetime {
|
||||||
ButtonLongerPressed,
|
ButtonLongerPressed,
|
||||||
ButtonDoubleClicked,
|
ButtonDoubleClicked,
|
||||||
NewNotification,
|
NewNotification,
|
||||||
|
MusicStarted,
|
||||||
|
NavStarted,
|
||||||
TimerDone,
|
TimerDone,
|
||||||
BleFirmwareUpdateStarted,
|
BleFirmwareUpdateStarted,
|
||||||
DimScreen,
|
DimScreen,
|
||||||
|
|
|
@ -40,6 +40,7 @@ namespace Pinetime {
|
||||||
SettingSteps,
|
SettingSteps,
|
||||||
SettingSetDateTime,
|
SettingSetDateTime,
|
||||||
SettingChimes,
|
SettingChimes,
|
||||||
|
SettingAutoOpen,
|
||||||
SettingShakeThreshold,
|
SettingShakeThreshold,
|
||||||
SettingBluetooth,
|
SettingBluetooth,
|
||||||
Error
|
Error
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
||||||
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743"
|
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743, 0xf0ad"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bpp": 1,
|
"bpp": 1,
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace Pinetime {
|
||||||
static constexpr const char* eye = "\xEF\x81\xAE";
|
static constexpr const char* eye = "\xEF\x81\xAE";
|
||||||
static constexpr const char* home = "\xEF\x80\x95";
|
static constexpr const char* home = "\xEF\x80\x95";
|
||||||
static constexpr const char* sleep = "\xEE\xBD\x84";
|
static constexpr const char* sleep = "\xEE\xBD\x84";
|
||||||
|
static constexpr const char* wrench = "\xEF\x82\xAD";
|
||||||
|
|
||||||
// fontawesome_weathericons.c
|
// fontawesome_weathericons.c
|
||||||
// static constexpr const char* sun = "\xEF\x86\x85";
|
// static constexpr const char* sun = "\xEF\x86\x85";
|
||||||
|
|
75
src/displayapp/screens/settings/SettingAutoOpen.cpp
Normal file
75
src/displayapp/screens/settings/SettingAutoOpen.cpp
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
#include "displayapp/screens/settings/SettingAutoOpen.h"
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
#include "displayapp/DisplayApp.h"
|
||||||
|
#include "displayapp/screens/Screen.h"
|
||||||
|
#include "displayapp/screens/Symbols.h"
|
||||||
|
|
||||||
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
constexpr std::array<SettingAutoOpen::Option, 3> SettingAutoOpen::options;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||||
|
auto* screen = static_cast<SettingAutoOpen*>(obj->user_data);
|
||||||
|
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||||
|
screen->UpdateSelected(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingAutoOpen::SettingAutoOpen(Pinetime::Controllers::Settings& settingsController) : settingsController {settingsController} {
|
||||||
|
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
|
||||||
|
|
||||||
|
lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||||
|
lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
|
||||||
|
lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
|
||||||
|
lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
|
|
||||||
|
lv_obj_set_pos(container1, 10, 35);
|
||||||
|
lv_obj_set_width(container1, LV_HOR_RES - 20);
|
||||||
|
lv_obj_set_height(container1, LV_VER_RES - 20);
|
||||||
|
lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT);
|
||||||
|
|
||||||
|
lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_text_static(title, "Auto Open");
|
||||||
|
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);
|
||||||
|
|
||||||
|
lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
|
||||||
|
lv_label_set_text_static(icon, Symbols::wrench);
|
||||||
|
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
|
||||||
|
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < options.size(); i++) {
|
||||||
|
cbOption[i] = lv_checkbox_create(container1, nullptr);
|
||||||
|
lv_checkbox_set_text(cbOption[i], options[i].name);
|
||||||
|
if (settingsController.IsAutoOpenOn(static_cast<Controllers::Settings::AutoOpen>(i))) {
|
||||||
|
lv_checkbox_set_checked(cbOption[i], true);
|
||||||
|
}
|
||||||
|
cbOption[i]->user_data = this;
|
||||||
|
lv_obj_set_event_cb(cbOption[i], event_handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingAutoOpen::~SettingAutoOpen() {
|
||||||
|
lv_obj_clean(lv_scr_act());
|
||||||
|
settingsController.SaveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingAutoOpen::UpdateSelected(lv_obj_t* object) {
|
||||||
|
// Find the index of the checkbox that triggered the event
|
||||||
|
for (size_t i = 0; i < options.size(); i++) {
|
||||||
|
if (cbOption[i] == object) {
|
||||||
|
bool currentState = settingsController.IsAutoOpenOn(options[i].app);
|
||||||
|
settingsController.SetAutoOpen(options[i].app, !currentState);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update checkbox according to current apps.
|
||||||
|
auto apps = settingsController.GetAutoOpen();
|
||||||
|
for (size_t i = 0; i < options.size(); ++i) {
|
||||||
|
lv_checkbox_set_checked(cbOption[i], apps[i]);
|
||||||
|
}
|
||||||
|
}
|
39
src/displayapp/screens/settings/SettingAutoOpen.h
Normal file
39
src/displayapp/screens/settings/SettingAutoOpen.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
|
|
||||||
|
#include "components/settings/Settings.h"
|
||||||
|
#include "displayapp/screens/Screen.h"
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
|
||||||
|
namespace Applications {
|
||||||
|
namespace Screens {
|
||||||
|
|
||||||
|
class SettingAutoOpen : public Screen {
|
||||||
|
public:
|
||||||
|
SettingAutoOpen(Pinetime::Controllers::Settings& settingsController);
|
||||||
|
~SettingAutoOpen() override;
|
||||||
|
|
||||||
|
void UpdateSelected(lv_obj_t* object);
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Option {
|
||||||
|
Controllers::Settings::AutoOpen app;
|
||||||
|
const char* name;
|
||||||
|
};
|
||||||
|
|
||||||
|
Controllers::Settings& settingsController;
|
||||||
|
static constexpr std::array<Option, 3> options = {{
|
||||||
|
{Controllers::Settings::AutoOpen::Battery, "Battery"},
|
||||||
|
{Controllers::Settings::AutoOpen::Music, "Music"},
|
||||||
|
{Controllers::Settings::AutoOpen::Navigation, "Navigation"},
|
||||||
|
}};
|
||||||
|
|
||||||
|
lv_obj_t* cbOption[options.size()];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,6 +47,7 @@ namespace Pinetime {
|
||||||
{Symbols::check, "Firmware", Apps::FirmwareValidation},
|
{Symbols::check, "Firmware", Apps::FirmwareValidation},
|
||||||
{Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth},
|
{Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth},
|
||||||
|
|
||||||
|
{Symbols::wrench, "Auto Open", Apps::SettingAutoOpen},
|
||||||
{Symbols::list, "About", Apps::SysInfo},
|
{Symbols::list, "About", Apps::SysInfo},
|
||||||
|
|
||||||
// {Symbols::none, "None", Apps::None},
|
// {Symbols::none, "None", Apps::None},
|
||||||
|
|
|
@ -24,6 +24,8 @@ namespace Pinetime {
|
||||||
OnNewHalfHour,
|
OnNewHalfHour,
|
||||||
OnChargingEvent,
|
OnChargingEvent,
|
||||||
OnPairing,
|
OnPairing,
|
||||||
|
OnMusicStarted,
|
||||||
|
OnNavChange,
|
||||||
SetOffAlarm,
|
SetOffAlarm,
|
||||||
MeasureBatteryTimerExpired,
|
MeasureBatteryTimerExpired,
|
||||||
BatteryPercentageUpdated,
|
BatteryPercentageUpdated,
|
||||||
|
|
|
@ -402,6 +402,16 @@ void SystemTask::Work() {
|
||||||
nimbleController.DisableRadio();
|
nimbleController.DisableRadio();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Messages::OnMusicStarted:
|
||||||
|
if (settingsController.IsAutoOpenOn(Controllers::Settings::AutoOpen::Music)) {
|
||||||
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::MusicStarted);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Messages::OnNavChange:
|
||||||
|
if (settingsController.IsAutoOpenOn(Controllers::Settings::AutoOpen::Navigation)) {
|
||||||
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NavStarted);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue