From 3e0974eacdad15a47c2f359cf7f02304806f5513 Mon Sep 17 00:00:00 2001 From: coxtor Date: Tue, 13 Jul 2021 22:29:23 +0200 Subject: [PATCH 1/6] Update App order --- src/CMakeLists.txt | 1 + src/components/settings/Settings.h | 14 ++++ src/displayapp/Apps.h | 3 +- src/displayapp/DisplayApp.cpp | 12 +++ src/displayapp/DisplayApp.h | 1 + .../screens/settings/SettingFavoriteApp.cpp | 74 +++++++++++++++++++ .../screens/settings/SettingFavoriteApp.h | 31 ++++++++ src/displayapp/screens/settings/Settings.cpp | 23 +++++- src/displayapp/screens/settings/Settings.h | 3 +- 9 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 src/displayapp/screens/settings/SettingFavoriteApp.cpp create mode 100644 src/displayapp/screens/settings/SettingFavoriteApp.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40e1f2a554..721e54598c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -427,6 +427,7 @@ list(APPEND SOURCE_FILES displayapp/screens/settings/SettingWakeUp.cpp displayapp/screens/settings/SettingDisplay.cpp displayapp/screens/settings/SettingSteps.cpp + displayapp/screens/settings/SettingFavoriteApp.cpp ## Watch faces displayapp/icons/bg_clock.c diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 577455ebd3..1faabee02c 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -4,6 +4,7 @@ #include "components/brightness/BrightnessController.h" #include "components/fs/FS.h" #include "drivers/Cst816s.h" +#include "displayapp/Apps.h" namespace Pinetime { namespace Controllers { @@ -18,6 +19,17 @@ namespace Pinetime { void Init(); void SaveSettings(); + void SetFavoriteApp(Applications::Apps app){ + if (app != settings.favoriteApp) { + settingsChanged = true; + } + settings.favoriteApp = app; + } + + Applications::Apps GetFavoriteApp(){ + return settings.favoriteApp; + } + void SetClockFace(uint8_t face) { if (face != settings.clockFace) { settingsChanged = true; @@ -119,6 +131,8 @@ namespace Pinetime { WakeUpMode wakeUpMode = WakeUpMode::None; Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium; + + Applications::Apps favoriteApp = Applications::Apps::None; }; SettingsData settings; diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h index 684e3a46b5..666de84892 100644 --- a/src/displayapp/Apps.h +++ b/src/displayapp/Apps.h @@ -30,7 +30,8 @@ namespace Pinetime { SettingTimeFormat, SettingDisplay, SettingWakeUp, - SettingSteps + SettingSteps, + SettingFavoriteApp }; } } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 04ebd2d328..dd9b54a571 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -42,6 +42,7 @@ #include "displayapp/screens/settings/SettingWakeUp.h" #include "displayapp/screens/settings/SettingDisplay.h" #include "displayapp/screens/settings/SettingSteps.h" +#include "displayapp/screens/settings/SettingFavoriteApp.h" using namespace Pinetime::Applications; using namespace Pinetime::Applications::Display; @@ -183,6 +184,13 @@ void DisplayApp::Refresh() { case TouchEvents::SwipeRight: LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim); break; + case TouchEvents::SwipeLeft: + favoriteApp = settingsController.GetFavoriteApp(); + if (favoriteApp == Apps::None) + LoadApp(Apps::SettingFavoriteApp, DisplayApp::FullRefreshDirections::LeftAnim); + else + LoadApp(favoriteApp, DisplayApp::FullRefreshDirections::LeftAnim); + break; case TouchEvents::DoubleTap: PushMessageToSystemTask(System::Messages::GoToSleep); break; @@ -323,6 +331,10 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) currentScreen = std::make_unique(this, settingsController); ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; + case Apps::SettingFavoriteApp: + currentScreen = std::make_unique(this, settingsController); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); + break; case Apps::BatteryInfo: currentScreen = std::make_unique(this, batteryController); ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 73a7cc36a4..eb1925c103 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -97,6 +97,7 @@ namespace Pinetime { Apps currentApp = Apps::None; Apps returnToApp = Apps::None; + Apps favoriteApp = Apps::None; FullRefreshDirections returnDirection = FullRefreshDirections::None; TouchEvents returnTouchEvent = TouchEvents::None; diff --git a/src/displayapp/screens/settings/SettingFavoriteApp.cpp b/src/displayapp/screens/settings/SettingFavoriteApp.cpp new file mode 100644 index 0000000000..d0c8dfa11f --- /dev/null +++ b/src/displayapp/screens/settings/SettingFavoriteApp.cpp @@ -0,0 +1,74 @@ +#include "SettingFavoriteApp.h" +#include +#include "displayapp/DisplayApp.h" +#include "displayapp/screens/Screen.h" +#include "displayapp/screens/Symbols.h" +#include "displayapp/Apps.h" + +using namespace Pinetime::Applications::Screens; + +namespace { + static void event_handler(lv_obj_t* obj, lv_event_t event) { + SettingFavoriteApp* screen = static_cast(obj->user_data); + screen->UpdateSelected(obj, event); + } +} + +SettingFavoriteApp::SettingFavoriteApp(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_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); + 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, "Favorite app"); + lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); + lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 10, 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::clock); + lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); + lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); + + for(optionsTotal = 0; optionsTotal < 12; optionsTotal++){ + cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + lv_checkbox_set_text_static(cbOption[optionsTotal], favoriteNames[optionsTotal]); + cbOption[optionsTotal]->user_data = this; + lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + if (settingsController.GetFavoriteApp() == favoriteOptions[optionsTotal]) { + lv_checkbox_set_checked(cbOption[optionsTotal], true); + } + } +} + +SettingFavoriteApp::~SettingFavoriteApp() { + lv_obj_clean(lv_scr_act()); + settingsController.SaveSettings(); +} + +bool SettingFavoriteApp::Refresh() { + return running; +} + +void SettingFavoriteApp::UpdateSelected(lv_obj_t* object, lv_event_t event) { + if (event == LV_EVENT_VALUE_CHANGED) { + for (int i = 0; i < optionsTotal; i++) { + lv_checkbox_set_checked(cbOption[i], false); + if (object == cbOption[i]) { + lv_checkbox_set_checked(cbOption[i], true); + settingsController.SetFavoriteApp(favoriteOptions[i]); + } + } + } +} diff --git a/src/displayapp/screens/settings/SettingFavoriteApp.h b/src/displayapp/screens/settings/SettingFavoriteApp.h new file mode 100644 index 0000000000..b6c070c927 --- /dev/null +++ b/src/displayapp/screens/settings/SettingFavoriteApp.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include "components/settings/Settings.h" +#include "displayapp/screens/Screen.h" +#include "displayapp/Apps.h" + +namespace Pinetime { + + namespace Applications { + namespace Screens { + + class SettingFavoriteApp : public Screen { + public: + SettingFavoriteApp(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); + ~SettingFavoriteApp() override; + + bool Refresh() override; + void UpdateSelected(lv_obj_t* object, lv_event_t event); + + private: + Controllers::Settings& settingsController; + uint8_t optionsTotal; + lv_obj_t* cbOption[13]; + Apps favoriteOptions[13] = {Apps::Music,Apps::Navigation,Apps::StopWatch,Apps::Timer,Apps::None,Apps::FlashLight,Apps::Paint,Apps::Paddle,Apps::Twos,Apps::HeartRate,Apps::Metronome,Apps::Motion,Apps::Steps}; + char favoriteNames[13][12] = { "Music","Navigation","Stop Watch","Timer","None","Flash Light","Paint","Paddle","Twos","Heart Rate","Metronome","Motion","Steps"}; + }; + } + } +} diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index e63a35846e..98f5058f5e 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -18,7 +18,11 @@ Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controller }, [this]() -> std::unique_ptr { return CreateScreen2(); - }}, + }, + [this]() -> std::unique_ptr { + return CreateScreen3(); + } + }, Screens::ScreenListModes::UpDown} { } @@ -46,7 +50,7 @@ std::unique_ptr Settings::CreateScreen1() { {Symbols::clock, "Watch face", Apps::SettingWatchFace}, }}; - return std::make_unique(0, 2, app, settingsController, applications); + return std::make_unique(0, 3, app, settingsController, applications); } std::unique_ptr Settings::CreateScreen2() { @@ -58,5 +62,18 @@ std::unique_ptr Settings::CreateScreen2() { {Symbols::list, "About", Apps::SysInfo}, }}; - return std::make_unique(1, 2, app, settingsController, applications); + return std::make_unique(1, 3, app, settingsController, applications); } + +std::unique_ptr Settings::CreateScreen3() { + + std::array applications {{ + {Symbols::shoe, "Favorite app", Apps::SettingFavoriteApp}, + {Symbols::batteryHalf, "", Apps::None}, + {Symbols::batteryHalf, "", Apps::None}, + {Symbols::batteryHalf, "", Apps::None}, + + }}; + + return std::make_unique(2, 3, app, settingsController, applications); +} \ No newline at end of file diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h index 711a6be6d0..12dd051460 100644 --- a/src/displayapp/screens/settings/Settings.h +++ b/src/displayapp/screens/settings/Settings.h @@ -21,10 +21,11 @@ namespace Pinetime { private: Controllers::Settings& settingsController; - ScreenList<2> screens; + ScreenList<3> screens; std::unique_ptr CreateScreen1(); std::unique_ptr CreateScreen2(); + std::unique_ptr CreateScreen3(); }; } } From d7ca217872307357200e32ad679786d8f3396ca0 Mon Sep 17 00:00:00 2001 From: Daniel Jackson Date: Sat, 25 Sep 2021 23:48:53 +0100 Subject: [PATCH 2/6] Correctly return the tick at which the RF will be fully enabled. Always returning 0 (when `MYNEWT_VAL_BLE_LL_RFMGMT_ENABLE_TIME` is not defined), rather than a time near to the current tick, causes an issue in at least one place: `ble_ll_adv_sm_start()`, where the calculation of `delta` overflows when the system timer is at 0x80000000 or above -- causing an incorrect, huge adjustment to be made to the scheduled time, ultimately stopping adverts from being sent. --- .../nimble/controller/include/controller/ble_ll_rfmgmt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/mynewt-nimble/nimble/controller/include/controller/ble_ll_rfmgmt.h b/src/libs/mynewt-nimble/nimble/controller/include/controller/ble_ll_rfmgmt.h index 37b81a88be..5e2d636ff8 100644 --- a/src/libs/mynewt-nimble/nimble/controller/include/controller/ble_ll_rfmgmt.h +++ b/src/libs/mynewt-nimble/nimble/controller/include/controller/ble_ll_rfmgmt.h @@ -51,7 +51,7 @@ static inline void ble_ll_rfmgmt_reset(void) { } static inline void ble_ll_rfmgmt_scan_changed(bool e, uint32_t n) { } static inline void ble_ll_rfmgmt_sched_changed(struct ble_ll_sched_item *f) { } static inline void ble_ll_rfmgmt_release(void) { } -static inline uint32_t ble_ll_rfmgmt_enable_now(void) { return 0; } +static inline uint32_t ble_ll_rfmgmt_enable_now(void) { return os_cputime_get32(); } static inline bool ble_ll_rfmgmt_is_enabled(void) { return true; } #endif From d03db14129b4f8cc2e691dd6f9e8d8d1ed52b7a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Sun, 26 Sep 2021 10:57:02 +0200 Subject: [PATCH 3/6] Set version to 1.5.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2402e5790..ec582fa2dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(pinetime VERSION 1.4.0 LANGUAGES C CXX ASM) +project(pinetime VERSION 1.5.0 LANGUAGES C CXX ASM) set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 14) From 7377f67e974f3b49bb00864111169c829b508861 Mon Sep 17 00:00:00 2001 From: coxtor Date: Mon, 27 Sep 2021 21:33:37 +0200 Subject: [PATCH 4/6] Fix Favorites for 1.5 --- src/displayapp/screens/settings/SettingFavoriteApp.cpp | 4 ---- src/displayapp/screens/settings/SettingFavoriteApp.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/src/displayapp/screens/settings/SettingFavoriteApp.cpp b/src/displayapp/screens/settings/SettingFavoriteApp.cpp index d0c8dfa11f..c6c0679ca0 100644 --- a/src/displayapp/screens/settings/SettingFavoriteApp.cpp +++ b/src/displayapp/screens/settings/SettingFavoriteApp.cpp @@ -57,10 +57,6 @@ SettingFavoriteApp::~SettingFavoriteApp() { settingsController.SaveSettings(); } -bool SettingFavoriteApp::Refresh() { - return running; -} - void SettingFavoriteApp::UpdateSelected(lv_obj_t* object, lv_event_t event) { if (event == LV_EVENT_VALUE_CHANGED) { for (int i = 0; i < optionsTotal; i++) { diff --git a/src/displayapp/screens/settings/SettingFavoriteApp.h b/src/displayapp/screens/settings/SettingFavoriteApp.h index b6c070c927..f3327dad48 100644 --- a/src/displayapp/screens/settings/SettingFavoriteApp.h +++ b/src/displayapp/screens/settings/SettingFavoriteApp.h @@ -15,8 +15,6 @@ namespace Pinetime { public: SettingFavoriteApp(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); ~SettingFavoriteApp() override; - - bool Refresh() override; void UpdateSelected(lv_obj_t* object, lv_event_t event); private: From 9a21d713f4244fc271840e79f2a635e641702fa3 Mon Sep 17 00:00:00 2001 From: coxtor Date: Tue, 28 Sep 2021 12:49:03 +0200 Subject: [PATCH 5/6] Select Favorite via longpress --- src/displayapp/screens/Tile.cpp | 47 +++++++++++++++++++++++++-------- src/displayapp/screens/Tile.h | 5 +++- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index 1d4f0d0ef7..e5607a56c9 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -1,6 +1,7 @@ #include "Tile.h" #include "../DisplayApp.h" #include "BatteryIcon.h" +#include "Symbols.h" using namespace Pinetime::Applications::Screens; @@ -11,12 +12,15 @@ namespace { } static void event_handler(lv_obj_t* obj, lv_event_t event) { - if (event != LV_EVENT_VALUE_CHANGED) return; - - Tile* screen = static_cast(obj->user_data); - auto* eventDataPtr = (uint32_t*) lv_event_get_data(); - uint32_t eventData = *eventDataPtr; - screen->OnValueChangedEvent(obj, eventData); + switch(event){ + case LV_EVENT_VALUE_CHANGED: + case LV_EVENT_LONG_PRESSED: + Tile* screen = static_cast(obj->user_data); + auto* eventDataPtr = (uint32_t*) lv_event_get_data(); + uint32_t eventData = *eventDataPtr; + screen->OnValueChangedEvent(obj, eventData, event); + break; + } } } @@ -27,7 +31,7 @@ Tile::Tile(uint8_t screenID, Pinetime::Controllers::Battery& batteryController, Controllers::DateTime& dateTimeController, std::array& applications) - : Screen(app), batteryController {batteryController}, dateTimeController {dateTimeController} { + : Screen(app), batteryController {batteryController}, dateTimeController {dateTimeController}, settingsController {settingsController} { settingsController.SetAppMenu(screenID); @@ -74,7 +78,12 @@ Tile::Tile(uint8_t screenID, if (applications[i].application == Apps::None) { btnmMap[btIndex] = " "; } else { - btnmMap[btIndex] = applications[i].icon; + if (applications[i].application == settingsController.GetFavoriteApp()){ + btnmMap[btIndex] = Pinetime::Applications::Screens::Symbols::eye; + } + else{ + btnmMap[btIndex] = applications[i].icon; + } } btIndex++; apps[i] = applications[i].application; @@ -123,9 +132,25 @@ void Tile::UpdateScreen() { lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining())); } -void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) { +void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId, lv_event_t event) { if(obj != btnm1) return; + switch(event){ + case LV_EVENT_VALUE_CHANGED: + if(apps[buttonId] != Pinetime::Applications::Apps::None){ + app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up); + running = false; + } + break; + case LV_EVENT_LONG_PRESSED: + currentFavoriteApp = settingsController.GetFavoriteApp(); + if(currentFavoriteApp == apps[buttonId]){ + settingsController.SetFavoriteApp(Pinetime::Applications::Apps::None); + } + else{ + settingsController.SetFavoriteApp(apps[buttonId]); + } + //motorController.RunForDuration(35); + break; + } - app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up); - running = false; } diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h index 83d3fdf5fa..95e963eab2 100644 --- a/src/displayapp/screens/Tile.h +++ b/src/displayapp/screens/Tile.h @@ -9,6 +9,7 @@ #include "components/settings/Settings.h" #include "components/datetime/DateTimeController.h" #include "components/battery/BatteryController.h" +#include "components/motor/MotorController.h" namespace Pinetime { namespace Applications { @@ -31,11 +32,12 @@ namespace Pinetime { ~Tile() override; void UpdateScreen(); - void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId); + void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId, lv_event_t event); private: Pinetime::Controllers::Battery& batteryController; Controllers::DateTime& dateTimeController; + Controllers::Settings& settingsController; lv_task_t* taskUpdate; @@ -49,6 +51,7 @@ namespace Pinetime { const char* btnmMap[8]; Pinetime::Applications::Apps apps[6]; + Pinetime::Applications::Apps currentFavoriteApp = Pinetime::Applications::Apps::None; }; } } From e9bb0b3cdd0e1b95b7bfdcfb94db5a6a0966eed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Tue, 28 Sep 2021 20:21:50 +0200 Subject: [PATCH 6/6] Set version to 1.6.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec582fa2dc..a8ecb81f02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(pinetime VERSION 1.5.0 LANGUAGES C CXX ASM) +project(pinetime VERSION 1.6.0 LANGUAGES C CXX ASM) set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 14)