diff options
Diffstat (limited to 'src/displayapp')
| -rw-r--r-- | src/displayapp/DisplayApp.cpp | 4 | ||||
| -rw-r--r-- | src/displayapp/apps/Apps.h.in | 1 | ||||
| -rw-r--r-- | src/displayapp/fonts/fonts.json | 2 | ||||
| -rw-r--r-- | src/displayapp/screens/Symbols.h | 1 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/SettingOTA.cpp | 58 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/SettingOTA.h | 28 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/Settings.h | 3 |
7 files changed, 95 insertions, 2 deletions
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index bfd7dbed..5c50e85f 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -50,6 +50,7 @@ #include "displayapp/screens/settings/SettingChimes.h" #include "displayapp/screens/settings/SettingShakeThreshold.h" #include "displayapp/screens/settings/SettingBluetooth.h" +#include "displayapp/screens/settings/SettingOTA.h" #include "libs/lv_conf.h" #include "UserApps.h" @@ -620,6 +621,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio case Apps::SettingBluetooth: currentScreen = std::make_unique<Screens::SettingBluetooth>(this, settingsController); break; + case Apps::SettingOTA: + currentScreen = std::make_unique<Screens::SettingOTA>(this, settingsController); + break; case Apps::BatteryInfo: currentScreen = std::make_unique<Screens::BatteryInfo>(batteryController); break; diff --git a/src/displayapp/apps/Apps.h.in b/src/displayapp/apps/Apps.h.in index f6feeb7b..0e94d32a 100644 --- a/src/displayapp/apps/Apps.h.in +++ b/src/displayapp/apps/Apps.h.in @@ -43,6 +43,7 @@ namespace Pinetime { SettingChimes, SettingShakeThreshold, SettingBluetooth, + SettingOTA, Error }; diff --git a/src/displayapp/fonts/fonts.json b/src/displayapp/fonts/fonts.json index fea31605..90be1feb 100644 --- a/src/displayapp/fonts/fonts.json +++ b/src/displayapp/fonts/fonts.json @@ -7,7 +7,7 @@ }, { "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, 0xf1ec, 0xf55a" + "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, 0xf1ec, 0xf55a, 0xf3ed" } ], "bpp": 1, diff --git a/src/displayapp/screens/Symbols.h b/src/displayapp/screens/Symbols.h index 40699b3d..fb93e80e 100644 --- a/src/displayapp/screens/Symbols.h +++ b/src/displayapp/screens/Symbols.h @@ -8,6 +8,7 @@ namespace Pinetime { static constexpr const char* batteryHalf = "\xEF\x89\x82"; static constexpr const char* heartBeat = "\xEF\x88\x9E"; static constexpr const char* bluetooth = "\xEF\x8A\x94"; + static constexpr const char* shieldAlt = "\xEF\x8F\xAD"; static constexpr const char* plug = "\xEF\x87\xA6"; static constexpr const char* shoe = "\xEF\x95\x8B"; static constexpr const char* clock = "\xEF\x80\x97"; diff --git a/src/displayapp/screens/settings/SettingOTA.cpp b/src/displayapp/screens/settings/SettingOTA.cpp new file mode 100644 index 00000000..ad123dec --- /dev/null +++ b/src/displayapp/screens/settings/SettingOTA.cpp @@ -0,0 +1,58 @@ +#include "displayapp/screens/settings/SettingOTA.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 { + struct Option { + const char* name; + Pinetime::Controllers::Settings::DfuAndFsMode mode; + }; + + constexpr std::array<Option, 3> options = {{ + {"Enabled", Pinetime::Controllers::Settings::DfuAndFsMode::Enabled}, + {"Disabled", Pinetime::Controllers::Settings::DfuAndFsMode::Disabled}, + {"Till reboot", Pinetime::Controllers::Settings::DfuAndFsMode::EnabledTillReboot}, + }}; + + std::array<CheckboxList::Item, CheckboxList::MaxItems> CreateOptionArray() { + std::array<Pinetime::Applications::Screens::CheckboxList::Item, CheckboxList::MaxItems> optionArray; + for (size_t i = 0; i < CheckboxList::MaxItems; i++) { + if (i >= options.size()) { + optionArray[i].name = ""; + optionArray[i].enabled = false; + } else { + optionArray[i].name = options[i].name; + optionArray[i].enabled = true; + } + } + return optionArray; + }; +} + +SettingOTA::SettingOTA(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) + : app {app}, + settingsController {settingsController}, + checkboxList( + 0, + 1, + "Firmware & files", + Symbols::shieldAlt, + settingsController.GetDfuAndFsMode() == Pinetime::Controllers::Settings::DfuAndFsMode::Enabled ? 0 + : settingsController.GetDfuAndFsMode() == Pinetime::Controllers::Settings::DfuAndFsMode::EnabledTillReboot ? 2 + : 1, + [&settings = settingsController](uint32_t index) { + settings.SetDfuAndFsMode(options[index].mode); + }, + CreateOptionArray()) { +} + +SettingOTA::~SettingOTA() { + lv_obj_clean(lv_scr_act()); + settingsController.SaveSettings(); +} diff --git a/src/displayapp/screens/settings/SettingOTA.h b/src/displayapp/screens/settings/SettingOTA.h new file mode 100644 index 00000000..13c9a33d --- /dev/null +++ b/src/displayapp/screens/settings/SettingOTA.h @@ -0,0 +1,28 @@ +#pragma once + +#include <array> +#include <cstdint> +#include <lvgl/lvgl.h> + +#include "components/settings/Settings.h" +#include "displayapp/screens/Screen.h" +#include "displayapp/screens/CheckboxList.h" + +namespace Pinetime { + + namespace Applications { + namespace Screens { + + class SettingOTA : public Screen { + public: + SettingOTA(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); + ~SettingOTA() override; + + private: + DisplayApp* app; + Pinetime::Controllers::Settings& settingsController; + CheckboxList checkboxList; + }; + } + } +} diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h index 3722c2be..370e83f4 100644 --- a/src/displayapp/screens/settings/Settings.h +++ b/src/displayapp/screens/settings/Settings.h @@ -45,8 +45,9 @@ namespace Pinetime { {Symbols::clock, "Chimes", Apps::SettingChimes}, {Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold}, {Symbols::check, "Firmware", Apps::FirmwareValidation}, - {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}, + {Symbols::shieldAlt, "Over-the-air", Apps::SettingOTA}, + {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}, {Symbols::list, "About", Apps::SysInfo}, // {Symbols::none, "None", Apps::None}, |
