Add system setting and add a timeout dropdown
This commit is contained in:
parent
8d54d37978
commit
5d0533c18a
8 changed files with 83 additions and 24 deletions
|
@ -1,26 +1,16 @@
|
||||||
#include "DisplaySettings.hpp"
|
#include "DisplaySettings.hpp"
|
||||||
#include "BrightnessSlider.hpp"
|
#include "BrightnessSlider.hpp"
|
||||||
|
#include "Label.hpp"
|
||||||
|
|
||||||
using namespace UI::Page;
|
using namespace UI::Page;
|
||||||
|
|
||||||
DisplaySettings::DisplaySettings(std::shared_ptr<DisplayAbstract> aDisplay)
|
DisplaySettings::DisplaySettings(std::shared_ptr<DisplayAbstract> aDisplay)
|
||||||
: Base(UI::ID::Pages::DisplaySettings), mDisplay(aDisplay),
|
: Base(UI::ID::Pages::DisplaySettings), mDisplay(aDisplay),
|
||||||
mBrightnessSlider(AddElement<Widget::BrightnessSlider>(
|
mBrightnessSlider(AddElement<Widget::BrightnessSlider>(
|
||||||
std::make_unique<Widget::BrightnessSlider>(mDisplay))),
|
std::make_unique<Widget::BrightnessSlider>(mDisplay))) {
|
||||||
mScreenTimeOutDropDown(AddElement<Widget::DropDown<int>>(
|
|
||||||
std::make_unique<Widget::DropDown<int>>([this](int aTimeout) {
|
|
||||||
|
|
||||||
}))) {
|
|
||||||
SetBgColor(Color::GREY);
|
SetBgColor(Color::GREY);
|
||||||
|
|
||||||
mBrightnessSlider->SetWidth(GetContentWidth());
|
mBrightnessSlider->SetWidth(GetContentWidth());
|
||||||
mBrightnessSlider->SetHeight(80);
|
mBrightnessSlider->SetHeight(80);
|
||||||
mBrightnessSlider->AlignTo(this, LV_ALIGN_TOP_MID);
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,5 @@ public:
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<DisplayAbstract> mDisplay;
|
std::shared_ptr<DisplayAbstract> mDisplay;
|
||||||
Widget::BrightnessSlider *mBrightnessSlider;
|
Widget::BrightnessSlider *mBrightnessSlider;
|
||||||
Widget::DropDown<int> *mScreenTimeOutDropDown;
|
|
||||||
};
|
};
|
||||||
} // namespace UI::Page
|
} // namespace UI::Page
|
||||||
|
|
|
@ -1,23 +1,27 @@
|
||||||
#include "SettingsPage.hpp"
|
#include "SettingsPage.hpp"
|
||||||
#include "BackgroundScreen.hpp"
|
#include "BackgroundScreen.hpp"
|
||||||
#include "Button.hpp"
|
#include "Button.hpp"
|
||||||
#include "Slider.hpp"
|
|
||||||
#include "List.hpp"
|
|
||||||
#include "Colors.hpp"
|
#include "Colors.hpp"
|
||||||
#include "DisplaySettings.hpp"
|
#include "DisplaySettings.hpp"
|
||||||
|
#include "List.hpp"
|
||||||
#include "PopUpScreen.hpp"
|
#include "PopUpScreen.hpp"
|
||||||
#include "ScreenManager.hpp"
|
#include "ScreenManager.hpp"
|
||||||
|
#include "Slider.hpp"
|
||||||
|
#include "SystemSettings.hpp"
|
||||||
|
|
||||||
using namespace UI::Page;
|
using namespace UI::Page;
|
||||||
using namespace UI::Color;
|
using namespace UI::Color;
|
||||||
|
|
||||||
SettingsPage::SettingsPage(std::shared_ptr<HardwareAbstract> aHardware)
|
SettingsPage::SettingsPage(std::shared_ptr<HardwareAbstract> aHardware)
|
||||||
: Base(ID::Pages::Settings),
|
: Base(ID::Pages::Settings),
|
||||||
mSettingsList(AddElement<Widget::List>(std::make_unique<Widget::List>())),
|
mSettingsList(AddElement<Widget::List>(std::make_unique<Widget::List>())),
|
||||||
mHardware(aHardware) {
|
mHardware(aHardware) {
|
||||||
|
|
||||||
mSettingsList->AddItem("Display",LV_SYMBOL_EYE_OPEN,[this] { PushDisplaySettings(); });
|
mSettingsList->AddItem("Display", LV_SYMBOL_EYE_OPEN,
|
||||||
mSettingsList->AddItem("Wifi",LV_SYMBOL_WIFI,[]{});
|
[this] { PushDisplaySettings(); });
|
||||||
|
mSettingsList->AddItem("Wifi", LV_SYMBOL_WIFI, [] {});
|
||||||
|
mSettingsList->AddItem("System", LV_SYMBOL_SETTINGS,
|
||||||
|
[this] { PushSystemSettings(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::PushDisplaySettings() {
|
void SettingsPage::PushDisplaySettings() {
|
||||||
|
@ -25,3 +29,7 @@ void SettingsPage::PushDisplaySettings() {
|
||||||
std::make_unique<DisplaySettings>(mHardware->display()));
|
std::make_unique<DisplaySettings>(mHardware->display()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsPage::PushSystemSettings() {
|
||||||
|
UI::Screen::Manager::getInstance().pushPopUp(
|
||||||
|
std::make_unique<SystemSettings>(mHardware));
|
||||||
|
}
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
#include "HardwareAbstract.hpp"
|
#include "HardwareAbstract.hpp"
|
||||||
#include "PageBase.hpp"
|
#include "PageBase.hpp"
|
||||||
|
|
||||||
namespace UI::Widget{
|
namespace UI::Widget {
|
||||||
class Button;
|
class Button;
|
||||||
class List;
|
class List;
|
||||||
}
|
} // namespace UI::Widget
|
||||||
namespace UI::Page {
|
namespace UI::Page {
|
||||||
class SettingsPage : public Base {
|
class SettingsPage : public Base {
|
||||||
public:
|
public:
|
||||||
SettingsPage(std::shared_ptr<HardwareAbstract> aHardware = nullptr);
|
SettingsPage(std::shared_ptr<HardwareAbstract> aHardware = nullptr);
|
||||||
|
|
||||||
bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override{return false;};
|
bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent) override {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
void PushDisplaySettings();
|
void PushDisplaySettings();
|
||||||
|
void PushSystemSettings();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void OnShow() override{};
|
void OnShow() override{};
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include "SystemSettings.hpp"
|
||||||
|
#include "Label.hpp"
|
||||||
|
|
||||||
|
using namespace UI::Page;
|
||||||
|
|
||||||
|
SystemSettings::SystemSettings(std::shared_ptr<HardwareAbstract> aHardware)
|
||||||
|
: Base(ID::Pages::SystemSettings), mHardware(aHardware),
|
||||||
|
mTimeoutLabel(AddElement<Widget::Label>(
|
||||||
|
std::make_unique<Widget::Label>("TimeOut"))),
|
||||||
|
mScreenTimeOutDropDown(AddElement<Widget::DropDown<int>>(
|
||||||
|
std::make_unique<Widget::DropDown<int>>([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());
|
||||||
|
}
|
|
@ -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<HardwareAbstract> aHardware);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::string GetTitle() override { return "System Settings"; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<HardwareAbstract> mHardware;
|
||||||
|
Widget::Label *mTimeoutLabel;
|
||||||
|
Widget::DropDown<int> *mScreenTimeOutDropDown;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace UI::Page
|
|
@ -26,6 +26,7 @@ public:
|
||||||
enum class Pages {
|
enum class Pages {
|
||||||
Settings = static_cast<int>(Widgets::INVALID_WIDGET_ID) + 1,
|
Settings = static_cast<int>(Widgets::INVALID_WIDGET_ID) + 1,
|
||||||
DisplaySettings,
|
DisplaySettings,
|
||||||
|
SystemSettings,
|
||||||
Demo,
|
Demo,
|
||||||
INVALID_PAGE_ID
|
INVALID_PAGE_ID
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,14 @@ public:
|
||||||
LV_DROPDOWN_POS_LAST);
|
LV_DROPDOWN_POS_LAST);
|
||||||
mOptionsData.push_back(aOptionData);
|
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
|
// TODO Could Implement a remove Item but need to make sure
|
||||||
// correct order is retained in data vector.
|
// correct order is retained in data vector.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue