summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/settings
diff options
context:
space:
mode:
authorMax Friedrich <minacode@users.noreply.github.com>2022-04-19 00:40:29 +0200
committerGitHub <noreply@github.com>2022-04-19 00:40:29 +0200
commitf84a0a38972e6b6d9a537dc9de2e2c416312f882 (patch)
tree3ce9dab83f8b6af8e9df1c8d3aa0219f5a67acbe /src/displayapp/screens/settings
parenta1db9fca136493eef38e536abaa660dd6ce23e57 (diff)
parented91b5a9981898078ad8e4cf105b5d52c7b63dfe (diff)
Merge branch 'develop' into remove-nm-reference
Diffstat (limited to 'src/displayapp/screens/settings')
-rw-r--r--src/displayapp/screens/settings/QuickSettings.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingBluetooth.cpp93
-rw-r--r--src/displayapp/screens/settings/SettingBluetooth.h31
-rw-r--r--src/displayapp/screens/settings/SettingChimes.h2
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.cpp10
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.h1
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.cpp2
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.h2
-rw-r--r--src/displayapp/screens/settings/Settings.cpp37
-rw-r--r--src/displayapp/screens/settings/Settings.h3
10 files changed, 163 insertions, 22 deletions
diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp
index cd56c145..97faaa79 100644
--- a/src/displayapp/screens/settings/QuickSettings.cpp
+++ b/src/displayapp/screens/settings/QuickSettings.cpp
@@ -40,7 +40,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0);
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
static constexpr uint8_t barHeight = 20 + innerDistance;
@@ -124,7 +124,7 @@ QuickSettings::~QuickSettings() {
void QuickSettings::UpdateScreen() {
lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
}
void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
diff --git a/src/displayapp/screens/settings/SettingBluetooth.cpp b/src/displayapp/screens/settings/SettingBluetooth.cpp
new file mode 100644
index 00000000..ab1af223
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingBluetooth.cpp
@@ -0,0 +1,93 @@
+#include "displayapp/screens/settings/SettingBluetooth.h"
+#include <lvgl/lvgl.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/Messages.h"
+#include "displayapp/screens/Styles.h"
+#include "displayapp/screens/Screen.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ static void OnBluetoothDisabledEvent(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingBluetooth*>(obj->user_data);
+ screen->OnBluetoothDisabled(obj, event);
+ }
+
+ static void OnBluetoothEnabledEvent(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingBluetooth*>(obj->user_data);
+ screen->OnBluetoothEnabled(obj, event);
+ }
+}
+
+SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
+ : Screen(app), 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, 60);
+ lv_obj_set_width(container1, LV_HOR_RES - 20);
+ lv_obj_set_height(container1, LV_VER_RES - 50);
+ 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, "Bluetooth");
+ 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::bluetooth);
+ lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
+
+ cbEnabled = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text(cbEnabled, " Enabled");
+ cbEnabled->user_data = this;
+ lv_obj_set_event_cb(cbEnabled, OnBluetoothEnabledEvent);
+ SetRadioButtonStyle(cbEnabled);
+
+ cbDisabled = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text(cbDisabled, " Disabled");
+ cbDisabled->user_data = this;
+ lv_obj_set_event_cb(cbDisabled, OnBluetoothDisabledEvent);
+ SetRadioButtonStyle(cbDisabled);
+
+ if (settingsController.GetBleRadioEnabled()) {
+ lv_checkbox_set_checked(cbEnabled, true);
+ priorMode = true;
+ } else {
+ lv_checkbox_set_checked(cbDisabled, true);
+ priorMode = false;
+ }
+}
+
+SettingBluetooth::~SettingBluetooth() {
+ lv_obj_clean(lv_scr_act());
+ // Do not call SaveSettings - see src/components/settings/Settings.h
+ if (priorMode != settingsController.GetBleRadioEnabled()) {
+ app->PushMessage(Pinetime::Applications::Display::Messages::BleRadioEnableToggle);
+ }
+}
+
+void SettingBluetooth::OnBluetoothDisabled(lv_obj_t* object, lv_event_t event) {
+ if (event == LV_EVENT_VALUE_CHANGED) {
+ lv_checkbox_set_checked(cbEnabled, false);
+ lv_checkbox_set_checked(cbDisabled, true);
+ settingsController.SetBleRadioEnabled(false);
+ }
+}
+
+void SettingBluetooth::OnBluetoothEnabled(lv_obj_t* object, lv_event_t event) {
+ if (event == LV_EVENT_VALUE_CHANGED) {
+ lv_checkbox_set_checked(cbEnabled, true);
+ lv_checkbox_set_checked(cbDisabled, false);
+ settingsController.SetBleRadioEnabled(true);
+ }
+}
+
diff --git a/src/displayapp/screens/settings/SettingBluetooth.h b/src/displayapp/screens/settings/SettingBluetooth.h
new file mode 100644
index 00000000..12bb459a
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingBluetooth.h
@@ -0,0 +1,31 @@
+#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 SettingBluetooth : public Screen {
+ public:
+ SettingBluetooth(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
+ ~SettingBluetooth() override;
+
+ void OnBluetoothEnabled(lv_obj_t* object, lv_event_t event);
+ void OnBluetoothDisabled(lv_obj_t* object, lv_event_t event);
+
+ private:
+ Controllers::Settings& settingsController;
+ lv_obj_t* cbEnabled;
+ lv_obj_t* cbDisabled;
+ bool priorMode;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingChimes.h b/src/displayapp/screens/settings/SettingChimes.h
index 653f87f7..a251e95b 100644
--- a/src/displayapp/screens/settings/SettingChimes.h
+++ b/src/displayapp/screens/settings/SettingChimes.h
@@ -20,7 +20,7 @@ namespace Pinetime {
private:
Controllers::Settings& settingsController;
uint8_t optionsTotal;
- lv_obj_t* cbOption[2];
+ lv_obj_t* cbOption[3];
};
}
}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.cpp b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
index 1791b550..c354bdc4 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.cpp
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
@@ -1,4 +1,4 @@
-#include "SettingShakeThreshold.h"
+#include "displayapp/screens/settings/SettingShakeThreshold.h"
#include <lvgl/lvgl.h>
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/Screen.h"
@@ -57,7 +57,7 @@ SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
lv_obj_align(calButton, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_btn_set_checkable(calButton, true);
calLabel = lv_label_create(calButton, NULL);
- lv_label_set_text(calLabel, "Calibrate");
+ lv_label_set_text_static(calLabel, "Calibrate");
lv_arc_set_value(positionArc, settingsController.GetShakeThreshold());
@@ -91,7 +91,7 @@ void SettingShakeThreshold::Refresh() {
calibrating = 2;
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_RED);
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_RED);
- lv_label_set_text(calLabel, "Shake!!");
+ lv_label_set_text_static(calLabel, "Shake!");
}
}
if (calibrating == 2) {
@@ -121,14 +121,14 @@ void SettingShakeThreshold::UpdateSelected(lv_obj_t* object, lv_event_t event) {
lv_arc_set_value(positionArc, 0);
calibrating = 1;
vCalTime = xTaskGetTickCount();
- lv_label_set_text(calLabel, "Ready!");
+ lv_label_set_text_static(calLabel, "Ready!");
lv_obj_set_click(positionArc, false);
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
} else if (lv_btn_get_state(calButton) == LV_BTN_STATE_RELEASED) {
calibrating = 0;
lv_obj_set_click(positionArc, true);
- lv_label_set_text(calLabel, "Calibrate");
+ lv_label_set_text_static(calLabel, "Calibrate");
}
break;
}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.h b/src/displayapp/screens/settings/SettingShakeThreshold.h
index b9ddd8b4..37f4a65e 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.h
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.h
@@ -5,6 +5,7 @@
#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
#include <components/motion/MotionController.h>
+#include "systemtask/SystemTask.h"
namespace Pinetime {
namespace Applications {
diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp
index a24eaa15..50085925 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.cpp
+++ b/src/displayapp/screens/settings/SettingWatchFace.cpp
@@ -14,7 +14,7 @@ namespace {
}
}
-constexpr std::array<const char*, 3> SettingWatchFace::options;
+constexpr std::array<const char*, 4> SettingWatchFace::options;
SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app), settingsController {settingsController} {
diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h
index ccba7d13..62427b4f 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.h
+++ b/src/displayapp/screens/settings/SettingWatchFace.h
@@ -20,7 +20,7 @@ namespace Pinetime {
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
- static constexpr std::array<const char*, 3> options = {" Digital face", " Analog face", " PineTimeStyle"};
+ static constexpr std::array<const char*, 4> options = {" Digital face", " Analog face", " PineTimeStyle", " Terminal"};
Controllers::Settings& settingsController;
lv_obj_t* cbOption[options.size()];
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index 7bc90b47..bc7efcc2 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -21,7 +21,11 @@ Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controller
},
[this]() -> std::unique_ptr<Screen> {
return CreateScreen3();
- }},
+ },
+ [this]() -> std::unique_ptr<Screen> {
+ return CreateScreen4();
+ },
+ },
Screens::ScreenListModes::UpDown} {
}
@@ -34,7 +38,6 @@ bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
}
std::unique_ptr<Screen> Settings::CreateScreen1() {
-
std::array<Screens::List::Applications, 4> applications {{
{Symbols::sun, "Display", Apps::SettingDisplay},
{Symbols::eye, "Wake Up", Apps::SettingWakeUp},
@@ -42,17 +45,17 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
{Symbols::home, "Watch face", Apps::SettingWatchFace},
}};
- return std::make_unique<Screens::List>(0, 3, app, settingsController, applications);
+ return std::make_unique<Screens::List>(0, 4, app, settingsController, applications);
}
std::unique_ptr<Screen> Settings::CreateScreen2() {
+ std::array<Screens::List::Applications, 4> applications {{
+ {Symbols::shoe, "Steps", Apps::SettingSteps},
+ {Symbols::clock, "Set date", Apps::SettingSetDate},
+ {Symbols::clock, "Set time", Apps::SettingSetTime},
+ {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}}};
- std::array<Screens::List::Applications, 4> applications {{{Symbols::shoe, "Steps", Apps::SettingSteps},
- {Symbols::clock, "Set date", Apps::SettingSetDate},
- {Symbols::clock, "Set time", Apps::SettingSetTime},
- {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}}};
-
- return std::make_unique<Screens::List>(1, 3, app, settingsController, applications);
+ return std::make_unique<Screens::List>(1, 4, app, settingsController, applications);
}
std::unique_ptr<Screen> Settings::CreateScreen3() {
@@ -61,8 +64,20 @@ std::unique_ptr<Screen> Settings::CreateScreen3() {
{Symbols::clock, "Chimes", Apps::SettingChimes},
{Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
- {Symbols::list, "About", Apps::SysInfo}
+ {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}
+ }};
+
+ return std::make_unique<Screens::List>(2, 4, app, settingsController, applications);
+}
+
+std::unique_ptr<Screen> Settings::CreateScreen4() {
+
+ std::array<Screens::List::Applications, 4> applications {{
+ {Symbols::list, "About", Apps::SysInfo},
+ {Symbols::none, "None", Apps::None},
+ {Symbols::none, "None", Apps::None},
+ {Symbols::none, "None", Apps::None}
}};
- return std::make_unique<Screens::List>(2, 3, app, settingsController, applications);
+ return std::make_unique<Screens::List>(3, 4, app, settingsController, applications);
}
diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h
index 6c54cdeb..be090075 100644
--- a/src/displayapp/screens/settings/Settings.h
+++ b/src/displayapp/screens/settings/Settings.h
@@ -19,11 +19,12 @@ namespace Pinetime {
private:
Controllers::Settings& settingsController;
- ScreenList<3> screens;
+ ScreenList<4> screens;
std::unique_ptr<Screen> CreateScreen1();
std::unique_ptr<Screen> CreateScreen2();
std::unique_ptr<Screen> CreateScreen3();
+ std::unique_ptr<Screen> CreateScreen4();
};
}
}