diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.cpp b/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.cpp index 7126532..817dc0a 100644 --- a/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.cpp +++ b/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.cpp @@ -1,26 +1,16 @@ #include "DisplaySettings.hpp" #include "BrightnessSlider.hpp" +#include "Label.hpp" using namespace UI::Page; DisplaySettings::DisplaySettings(std::shared_ptr aDisplay) : Base(UI::ID::Pages::DisplaySettings), mDisplay(aDisplay), mBrightnessSlider(AddElement( - std::make_unique(mDisplay))), - mScreenTimeOutDropDown(AddElement>( - std::make_unique>([this](int aTimeout) { - - }))) { + std::make_unique(mDisplay))) { SetBgColor(Color::GREY); mBrightnessSlider->SetWidth(GetContentWidth()); mBrightnessSlider->SetHeight(80); mBrightnessSlider->AlignTo(this, LV_ALIGN_TOP_MID); - - mScreenTimeOutDropDown->SetHeight(30); - mScreenTimeOutDropDown->SetWidth(GetContentWidth()); - mScreenTimeOutDropDown->AddItem("10 Seconds", 10); - mScreenTimeOutDropDown->AddItem("15 Seconds", 15); - mScreenTimeOutDropDown->AddItem("20 Seconds", 20); - mScreenTimeOutDropDown->AlignTo(mBrightnessSlider, LV_ALIGN_OUT_BOTTOM_MID); } diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.hpp b/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.hpp index 8f2406e..d398331 100644 --- a/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.hpp +++ b/Platformio/OmoteUI/UIs/BasicRefactored/page/DisplaySettings.hpp @@ -17,6 +17,5 @@ public: private: std::shared_ptr mDisplay; Widget::BrightnessSlider *mBrightnessSlider; - Widget::DropDown *mScreenTimeOutDropDown; }; } // namespace UI::Page diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.cpp b/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.cpp index 79f4721..724b48a 100644 --- a/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.cpp +++ b/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.cpp @@ -1,23 +1,27 @@ #include "SettingsPage.hpp" #include "BackgroundScreen.hpp" #include "Button.hpp" -#include "Slider.hpp" -#include "List.hpp" #include "Colors.hpp" #include "DisplaySettings.hpp" +#include "List.hpp" #include "PopUpScreen.hpp" #include "ScreenManager.hpp" +#include "Slider.hpp" +#include "SystemSettings.hpp" using namespace UI::Page; using namespace UI::Color; SettingsPage::SettingsPage(std::shared_ptr aHardware) : Base(ID::Pages::Settings), - mSettingsList(AddElement(std::make_unique())), - mHardware(aHardware) { + mSettingsList(AddElement(std::make_unique())), + mHardware(aHardware) { - mSettingsList->AddItem("Display",LV_SYMBOL_EYE_OPEN,[this] { PushDisplaySettings(); }); - mSettingsList->AddItem("Wifi",LV_SYMBOL_WIFI,[]{}); + mSettingsList->AddItem("Display", LV_SYMBOL_EYE_OPEN, + [this] { PushDisplaySettings(); }); + mSettingsList->AddItem("Wifi", LV_SYMBOL_WIFI, [] {}); + mSettingsList->AddItem("System", LV_SYMBOL_SETTINGS, + [this] { PushSystemSettings(); }); } void SettingsPage::PushDisplaySettings() { @@ -25,3 +29,7 @@ void SettingsPage::PushDisplaySettings() { std::make_unique(mHardware->display())); } +void SettingsPage::PushSystemSettings() { + UI::Screen::Manager::getInstance().pushPopUp( + std::make_unique(mHardware)); +} diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.hpp b/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.hpp index b5636f4..3bd23a8 100644 --- a/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.hpp +++ b/Platformio/OmoteUI/UIs/BasicRefactored/page/SettingsPage.hpp @@ -1,18 +1,21 @@ #include "HardwareAbstract.hpp" #include "PageBase.hpp" -namespace UI::Widget{ - class Button; - class List; -} +namespace UI::Widget { +class Button; +class List; +} // namespace UI::Widget namespace UI::Page { class SettingsPage : public Base { public: SettingsPage(std::shared_ptr aHardware = nullptr); - bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override{return false;}; + bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override { + return false; + }; void PushDisplaySettings(); + void PushSystemSettings(); protected: void OnShow() override{}; diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/page/SystemSettings.cpp b/Platformio/OmoteUI/UIs/BasicRefactored/page/SystemSettings.cpp new file mode 100644 index 0000000..c36521a --- /dev/null +++ b/Platformio/OmoteUI/UIs/BasicRefactored/page/SystemSettings.cpp @@ -0,0 +1,25 @@ +#include "SystemSettings.hpp" +#include "Label.hpp" + +using namespace UI::Page; + +SystemSettings::SystemSettings(std::shared_ptr aHardware) + : Base(ID::Pages::SystemSettings), mHardware(aHardware), + mTimeoutLabel(AddElement( + std::make_unique("TimeOut"))), + mScreenTimeOutDropDown(AddElement>( + std::make_unique>([this](int aTimeout) { + mHardware->setSleepTimeout(aTimeout); + }))) { + + mTimeoutLabel->AlignTo(this, LV_ALIGN_TOP_MID); + mTimeoutLabel->SetHeight(15); + + mScreenTimeOutDropDown->SetHeight(30); + mScreenTimeOutDropDown->SetWidth(GetContentWidth()); + mScreenTimeOutDropDown->AddItem("10 Seconds", 10000); + mScreenTimeOutDropDown->AddItem("15 Seconds", 15000); + mScreenTimeOutDropDown->AddItem("20 Seconds", 20000); + mScreenTimeOutDropDown->AlignTo(mTimeoutLabel, LV_ALIGN_OUT_BOTTOM_MID); + mScreenTimeOutDropDown->SetSelected(mHardware->getSleepTimeout()); +} \ No newline at end of file diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/page/SystemSettings.hpp b/Platformio/OmoteUI/UIs/BasicRefactored/page/SystemSettings.hpp new file mode 100644 index 0000000..ec760a1 --- /dev/null +++ b/Platformio/OmoteUI/UIs/BasicRefactored/page/SystemSettings.hpp @@ -0,0 +1,25 @@ +#pragma once +#include "DropDown.hpp" +#include "HardwareAbstract.hpp" +#include "PageBase.hpp" + +namespace UI::Widget { +class Label; +} + +namespace UI::Page { + +class SystemSettings : public Base { +public: + SystemSettings(std::shared_ptr aHardware); + +protected: + std::string GetTitle() override { return "System Settings"; } + +private: + std::shared_ptr mHardware; + Widget::Label *mTimeoutLabel; + Widget::DropDown *mScreenTimeOutDropDown; +}; + +} // namespace UI::Page \ No newline at end of file diff --git a/Platformio/OmoteUI/core/UIElementIds.hpp b/Platformio/OmoteUI/core/UIElementIds.hpp index f706c85..b46a305 100644 --- a/Platformio/OmoteUI/core/UIElementIds.hpp +++ b/Platformio/OmoteUI/core/UIElementIds.hpp @@ -26,6 +26,7 @@ public: enum class Pages { Settings = static_cast(Widgets::INVALID_WIDGET_ID) + 1, DisplaySettings, + SystemSettings, Demo, INVALID_PAGE_ID }; diff --git a/Platformio/OmoteUI/core/widget/DropDown.hpp b/Platformio/OmoteUI/core/widget/DropDown.hpp index 5f8d2c3..31e463d 100644 --- a/Platformio/OmoteUI/core/widget/DropDown.hpp +++ b/Platformio/OmoteUI/core/widget/DropDown.hpp @@ -20,6 +20,14 @@ public: LV_DROPDOWN_POS_LAST); mOptionsData.push_back(aOptionData); } + + void SetSelected(T aOptionData) { + for (int i = 0; i < mOptionsData.size(); i++) { + if (mOptionsData[i] == aOptionData) { + lv_dropdown_set_selected(LvglSelf(), i); + } + } + } // TODO Could Implement a remove Item but need to make sure // correct order is retained in data vector.