diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 64b7ffbd..3eade16b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -407,6 +407,7 @@ list(APPEND SOURCE_FILES displayapp/Colors.cpp displayapp/widgets/Counter.cpp displayapp/widgets/PageIndicator.cpp + displayapp/widgets/DotIndicator.cpp displayapp/widgets/StatusIcons.cpp ## Settings @@ -417,6 +418,7 @@ list(APPEND SOURCE_FILES displayapp/screens/settings/SettingWakeUp.cpp displayapp/screens/settings/SettingDisplay.cpp displayapp/screens/settings/SettingSteps.cpp + displayapp/screens/settings/SettingSetDateTime.cpp displayapp/screens/settings/SettingSetDate.cpp displayapp/screens/settings/SettingSetTime.cpp displayapp/screens/settings/SettingChimes.cpp @@ -616,6 +618,7 @@ set(INCLUDE_FILES displayapp/Colors.h displayapp/widgets/Counter.h displayapp/widgets/PageIndicator.h + displayapp/widgets/DotIndicator.h displayapp/widgets/StatusIcons.h drivers/St7789.h drivers/SpiNorFlash.h diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h index 8aad9535..89b05d87 100644 --- a/src/displayapp/Apps.h +++ b/src/displayapp/Apps.h @@ -34,8 +34,7 @@ namespace Pinetime { SettingDisplay, SettingWakeUp, SettingSteps, - SettingSetDate, - SettingSetTime, + SettingSetDateTime, SettingChimes, SettingShakeThreshold, SettingBluetooth, diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 69830ead..725caaf4 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -43,8 +43,7 @@ #include "displayapp/screens/settings/SettingWakeUp.h" #include "displayapp/screens/settings/SettingDisplay.h" #include "displayapp/screens/settings/SettingSteps.h" -#include "displayapp/screens/settings/SettingSetDate.h" -#include "displayapp/screens/settings/SettingSetTime.h" +#include "displayapp/screens/settings/SettingSetDateTime.h" #include "displayapp/screens/settings/SettingChimes.h" #include "displayapp/screens/settings/SettingShakeThreshold.h" #include "displayapp/screens/settings/SettingBluetooth.h" @@ -430,11 +429,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio case Apps::SettingSteps: currentScreen = std::make_unique(this, settingsController); break; - case Apps::SettingSetDate: - currentScreen = std::make_unique(this, dateTimeController); - break; - case Apps::SettingSetTime: - currentScreen = std::make_unique(this, dateTimeController, settingsController); + case Apps::SettingSetDateTime: + currentScreen = std::make_unique(this, dateTimeController, settingsController); break; case Apps::SettingChimes: currentScreen = std::make_unique(this, settingsController); diff --git a/src/displayapp/screens/settings/SettingSetDate.cpp b/src/displayapp/screens/settings/SettingSetDate.cpp index 421aef02..fd1bc9b9 100644 --- a/src/displayapp/screens/settings/SettingSetDate.cpp +++ b/src/displayapp/screens/settings/SettingSetDate.cpp @@ -1,4 +1,5 @@ #include "displayapp/screens/settings/SettingSetDate.h" +#include "displayapp/screens/settings/SettingSetDateTime.h" #include #include #include @@ -44,8 +45,11 @@ namespace { } } -SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::DateTime& dateTimeController) - : Screen(app), dateTimeController {dateTimeController} { +SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp* app, + Pinetime::Controllers::DateTime& dateTimeController, + Pinetime::Applications::Screens::SettingSetDateTime& settingSetDateTime) + : Screen(app), dateTimeController {dateTimeController}, settingSetDateTime {settingSetDateTime} { + lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(title, "Set current date"); lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); @@ -82,8 +86,6 @@ SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp* app, Pinetime lblSetTime = lv_label_create(btnSetTime, nullptr); lv_label_set_text_static(lblSetTime, "Set"); lv_obj_set_event_cb(btnSetTime, event_handler); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED); - lv_obj_set_state(lblSetTime, LV_STATE_DISABLED); } SettingSetDate::~SettingSetDate() { @@ -103,13 +105,10 @@ void SettingSetDate::HandleButtonPress() { dateTimeController.Minutes(), dateTimeController.Seconds(), nrf_rtc_counter_get(portNRF_RTC_REG)); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED); - lv_obj_set_state(lblSetTime, LV_STATE_DISABLED); + settingSetDateTime.Advance(); } void SettingSetDate::CheckDay() { const int maxDay = MaximumDayOfMonth(monthCounter.GetValue(), yearCounter.GetValue()); dayCounter.SetMax(maxDay); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED); - lv_obj_set_state(lblSetTime, LV_STATE_DEFAULT); } diff --git a/src/displayapp/screens/settings/SettingSetDate.h b/src/displayapp/screens/settings/SettingSetDate.h index a0ffc683..dfb0e0d2 100644 --- a/src/displayapp/screens/settings/SettingSetDate.h +++ b/src/displayapp/screens/settings/SettingSetDate.h @@ -5,13 +5,17 @@ #include "components/datetime/DateTimeController.h" #include "displayapp/screens/Screen.h" #include "displayapp/widgets/Counter.h" +#include "displayapp/widgets/DotIndicator.h" +#include "displayapp/screens/settings/SettingSetDateTime.h" namespace Pinetime { namespace Applications { namespace Screens { class SettingSetDate : public Screen { public: - SettingSetDate(DisplayApp* app, Pinetime::Controllers::DateTime& dateTimeController); + SettingSetDate(DisplayApp* app, + Pinetime::Controllers::DateTime& dateTimeController, + Pinetime::Applications::Screens::SettingSetDateTime& settingSetDateTime); ~SettingSetDate() override; void HandleButtonPress(); @@ -19,6 +23,7 @@ namespace Pinetime { private: Controllers::DateTime& dateTimeController; + Pinetime::Applications::Screens::SettingSetDateTime& settingSetDateTime; lv_obj_t* btnSetTime; lv_obj_t* lblSetTime; diff --git a/src/displayapp/screens/settings/SettingSetDateTime.cpp b/src/displayapp/screens/settings/SettingSetDateTime.cpp new file mode 100644 index 00000000..905a76ab --- /dev/null +++ b/src/displayapp/screens/settings/SettingSetDateTime.cpp @@ -0,0 +1,54 @@ +#include "displayapp/screens/settings/SettingSetDateTime.h" +#include "displayapp/screens/settings/SettingSetDate.h" +#include "displayapp/screens/settings/SettingSetTime.h" +#include "displayapp/DisplayApp.h" +#include "displayapp/screens/ScreenList.h" +#include "components/settings/Settings.h" +#include "displayapp/widgets/DotIndicator.h" + +using namespace Pinetime::Applications::Screens; + +bool SettingSetDateTime::OnTouchEvent(Pinetime::Applications::TouchEvents event) { + return screens.OnTouchEvent(event); +} + +SettingSetDateTime::SettingSetDateTime(Pinetime::Applications::DisplayApp* app, + Pinetime::Controllers::DateTime& dateTimeController, + Pinetime::Controllers::Settings& settingsController) + : Screen(app), + dateTimeController {dateTimeController}, + settingsController {settingsController}, + screens {app, + 0, + {[this]() -> std::unique_ptr { + return screenSetDate(); + }, + [this]() -> std::unique_ptr { + return screenSetTime(); + }}, + Screens::ScreenListModes::UpDown} { +} + +std::unique_ptr SettingSetDateTime::screenSetDate() { + Widgets::DotIndicator dotIndicator(0, 2); + dotIndicator.Create(); + return std::make_unique(app, dateTimeController, *this); +} + +std::unique_ptr SettingSetDateTime::screenSetTime() { + Widgets::DotIndicator dotIndicator(1, 2); + dotIndicator.Create(); + return std::make_unique(app, dateTimeController, settingsController, *this); +} + +SettingSetDateTime::~SettingSetDateTime() { + lv_obj_clean(lv_scr_act()); +} + +void SettingSetDateTime::Advance() { + screens.OnTouchEvent(Pinetime::Applications::TouchEvents::SwipeUp); +} + +void SettingSetDateTime::Quit() { + running = false; +} diff --git a/src/displayapp/screens/settings/SettingSetDateTime.h b/src/displayapp/screens/settings/SettingSetDateTime.h new file mode 100644 index 00000000..dea283f8 --- /dev/null +++ b/src/displayapp/screens/settings/SettingSetDateTime.h @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include "displayapp/screens/Screen.h" +#include "displayapp/screens/ScreenList.h" + +namespace Pinetime { + namespace Applications { + namespace Screens { + class SettingSetDateTime : public Screen { + public: + SettingSetDateTime(DisplayApp* app, + Pinetime::Controllers::DateTime& dateTimeController, + Pinetime::Controllers::Settings& settingsController); + ~SettingSetDateTime() override; + + bool OnTouchEvent(TouchEvents event) override; + void Advance(); + void Quit(); + + private: + Controllers::DateTime& dateTimeController; + Controllers::Settings& settingsController; + + ScreenList<2> screens; + std::unique_ptr screenSetDate(); + std::unique_ptr screenSetTime(); + }; + } + } +} diff --git a/src/displayapp/screens/settings/SettingSetTime.cpp b/src/displayapp/screens/settings/SettingSetTime.cpp index f85fe073..7fad33ae 100644 --- a/src/displayapp/screens/settings/SettingSetTime.cpp +++ b/src/displayapp/screens/settings/SettingSetTime.cpp @@ -27,8 +27,9 @@ namespace { SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::DateTime& dateTimeController, - Pinetime::Controllers::Settings& settingsController) - : Screen(app), dateTimeController {dateTimeController}, settingsController {settingsController} { + Pinetime::Controllers::Settings& settingsController, + Pinetime::Applications::Screens::SettingSetDateTime& settingSetDateTime) + : Screen(app), dateTimeController {dateTimeController}, settingsController {settingsController}, settingSetDateTime {settingSetDateTime} { lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(title, "Set current time"); @@ -75,8 +76,6 @@ SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp* app, lv_obj_set_event_cb(btnSetTime, SetTimeEventHandler); UpdateScreen(); - lv_obj_set_state(btnSetTime, LV_STATE_DISABLED); - lv_obj_set_state(lblSetTime, LV_STATE_DISABLED); } SettingSetTime::~SettingSetTime() { @@ -91,8 +90,6 @@ void SettingSetTime::UpdateScreen() { lv_label_set_text_static(lblampm, "AM"); } } - lv_obj_set_state(btnSetTime, LV_STATE_DEFAULT); - lv_obj_set_state(lblSetTime, LV_STATE_DEFAULT); } void SettingSetTime::SetTime() { @@ -107,6 +104,5 @@ void SettingSetTime::SetTime() { static_cast(minutesValue), 0, nrf_rtc_counter_get(portNRF_RTC_REG)); - lv_obj_set_state(btnSetTime, LV_STATE_DISABLED); - lv_obj_set_state(lblSetTime, LV_STATE_DISABLED); + settingSetDateTime.Quit(); } diff --git a/src/displayapp/screens/settings/SettingSetTime.h b/src/displayapp/screens/settings/SettingSetTime.h index b61962c1..edd89b16 100644 --- a/src/displayapp/screens/settings/SettingSetTime.h +++ b/src/displayapp/screens/settings/SettingSetTime.h @@ -6,6 +6,8 @@ #include "components/settings/Settings.h" #include "displayapp/widgets/Counter.h" #include "displayapp/screens/Screen.h" +#include "displayapp/widgets/DotIndicator.h" +#include "displayapp/screens/settings/SettingSetDateTime.h" namespace Pinetime { namespace Applications { @@ -14,7 +16,8 @@ namespace Pinetime { public: SettingSetTime(DisplayApp* app, Pinetime::Controllers::DateTime& dateTimeController, - Pinetime::Controllers::Settings& settingsController); + Pinetime::Controllers::Settings& settingsController, + Pinetime::Applications::Screens::SettingSetDateTime& settingSetDateTime); ~SettingSetTime() override; void SetTime(); @@ -23,6 +26,7 @@ namespace Pinetime { private: Controllers::DateTime& dateTimeController; Controllers::Settings& settingsController; + Pinetime::Applications::Screens::SettingSetDateTime& settingSetDateTime; lv_obj_t* lblampm; lv_obj_t* btnSetTime; diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h index a86db44f..b88c13b7 100644 --- a/src/displayapp/screens/settings/Settings.h +++ b/src/displayapp/screens/settings/Settings.h @@ -28,7 +28,7 @@ namespace Pinetime { static constexpr int entriesPerScreen = 4; // Increment this when more space is needed - static constexpr int nScreens = 4; + static constexpr int nScreens = 3; static constexpr std::array entries {{ {Symbols::sun, "Display", Apps::SettingDisplay}, @@ -37,19 +37,20 @@ namespace Pinetime { {Symbols::home, "Watch face", Apps::SettingWatchFace}, {Symbols::shoe, "Steps", Apps::SettingSteps}, - {Symbols::clock, "Set date", Apps::SettingSetDate}, - {Symbols::clock, "Set time", Apps::SettingSetTime}, + {Symbols::clock, "Date&Time", Apps::SettingSetDateTime}, {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}, - {Symbols::clock, "Chimes", Apps::SettingChimes}, + {Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold}, {Symbols::check, "Firmware", Apps::FirmwareValidation}, {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}, - {Symbols::list, "About", Apps::SysInfo}, - {Symbols::none, "None", Apps::None}, - {Symbols::none, "None", Apps::None}, - {Symbols::none, "None", Apps::None}, + + // {Symbols::none, "None", Apps::None}, + // {Symbols::none, "None", Apps::None}, + // {Symbols::none, "None", Apps::None}, + // {Symbols::none, "None", Apps::None}, + }}; ScreenList screens; }; diff --git a/src/displayapp/widgets/DotIndicator.cpp b/src/displayapp/widgets/DotIndicator.cpp new file mode 100644 index 00000000..209b43bd --- /dev/null +++ b/src/displayapp/widgets/DotIndicator.cpp @@ -0,0 +1,28 @@ +#include "displayapp/widgets/DotIndicator.h" +#include "displayapp/InfiniTimeTheme.h" + +using namespace Pinetime::Applications::Widgets; + +DotIndicator::DotIndicator(uint8_t nCurrentScreen, uint8_t nScreens) : nCurrentScreen {nCurrentScreen}, nScreens {nScreens} { +} + +void DotIndicator::Create() { + lv_obj_t* dotIndicator[nScreens]; + static constexpr uint8_t dotSize = 12; + + lv_obj_t* container = lv_cont_create(lv_scr_act(), nullptr); + lv_cont_set_layout(container, LV_LAYOUT_COLUMN_LEFT); + lv_cont_set_fit(container, LV_FIT_TIGHT); + lv_obj_set_style_local_pad_inner(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, dotSize); + lv_obj_set_style_local_bg_opa(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); + + for (int i = 0; i < nScreens; i++) { + dotIndicator[i] = lv_obj_create(container, nullptr); + lv_obj_set_size(dotIndicator[i], dotSize, dotSize); + lv_obj_set_style_local_bg_color(dotIndicator[i], LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + } + + lv_obj_set_style_local_bg_color(dotIndicator[nCurrentScreen], LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + + lv_obj_align(container, nullptr, LV_ALIGN_IN_RIGHT_MID, 0, 0); +} diff --git a/src/displayapp/widgets/DotIndicator.h b/src/displayapp/widgets/DotIndicator.h new file mode 100644 index 00000000..49cdca26 --- /dev/null +++ b/src/displayapp/widgets/DotIndicator.h @@ -0,0 +1,18 @@ +#pragma once +#include + +namespace Pinetime { + namespace Applications { + namespace Widgets { + class DotIndicator { + public: + DotIndicator(uint8_t nCurrentScreen, uint8_t nScreens); + void Create(); + + private: + uint8_t nCurrentScreen; + uint8_t nScreens; + }; + } + } +}