added initial wifi settings page
currently can scan for networks and show them but clicking does nothing.
This commit is contained in:
parent
38ec26dce7
commit
99787a69f2
9 changed files with 96 additions and 3 deletions
|
@ -15,4 +15,6 @@ BasicUI::BasicUI(std::shared_ptr<HardwareAbstract> aHardware)
|
|||
|
||||
Screen::Manager::getInstance().pushScreen(
|
||||
std::make_unique<Screen::HomeScreen>(aHardware));
|
||||
|
||||
mHardware->wifi()->begin();
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
#include "ScreenManager.hpp"
|
||||
#include "Slider.hpp"
|
||||
#include "SystemSettings.hpp"
|
||||
#include "WifiSettings.hpp"
|
||||
|
||||
using namespace UI::Page;
|
||||
using namespace UI::Color;
|
||||
|
@ -19,7 +20,8 @@ SettingsPage::SettingsPage(std::shared_ptr<HardwareAbstract> aHardware)
|
|||
|
||||
mSettingsList->AddItem("Display", LV_SYMBOL_EYE_OPEN,
|
||||
[this] { PushDisplaySettings(); });
|
||||
mSettingsList->AddItem("Wifi", LV_SYMBOL_WIFI, [] {});
|
||||
mSettingsList->AddItem("Wifi", LV_SYMBOL_WIFI,
|
||||
[this] { PushWifiSettings(); });
|
||||
mSettingsList->AddItem("System", LV_SYMBOL_SETTINGS,
|
||||
[this] { PushSystemSettings(); });
|
||||
}
|
||||
|
@ -33,3 +35,8 @@ void SettingsPage::PushSystemSettings() {
|
|||
UI::Screen::Manager::getInstance().pushPopUp(
|
||||
std::make_unique<SystemSettings>(mHardware));
|
||||
}
|
||||
|
||||
void SettingsPage::PushWifiSettings() {
|
||||
UI::Screen::Manager::getInstance().pushPopUp(
|
||||
std::make_unique<WifiSettings>(mHardware->wifi()));
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
|
||||
void PushDisplaySettings();
|
||||
void PushSystemSettings();
|
||||
void PushWifiSettings();
|
||||
|
||||
protected:
|
||||
void OnShow() override{};
|
||||
|
|
41
Platformio/OmoteUI/UIs/BasicRefactored/page/WifiSettings.cpp
Normal file
41
Platformio/OmoteUI/UIs/BasicRefactored/page/WifiSettings.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include "WifiSettings.hpp"
|
||||
#include "Label.hpp"
|
||||
#include "List.hpp"
|
||||
#include "LvglResourceManager.hpp"
|
||||
//#include <Arduino.h>
|
||||
|
||||
using namespace UI;
|
||||
using namespace UI::Page;
|
||||
|
||||
WifiSettings::WifiSettings(std::shared_ptr<wifiHandlerInterface> aWifi)
|
||||
: Base(ID::Pages::WifiSettings), mWifi(aWifi),
|
||||
mScanCompleteHandler(mWifi->ScanCompleteNotification()),
|
||||
mScanningText(AddElement<Widget::Label>(
|
||||
std::make_unique<Widget::Label>("Scanning..."))),
|
||||
mWifiNetworks(
|
||||
AddElement<Widget::List>(std::make_unique<Widget::List>())) {
|
||||
|
||||
mScanCompleteHandler = [this](auto aWifiInfos) {
|
||||
// Serial.println("populating UI");
|
||||
mScanningText->SetText("Networks Found");
|
||||
for (WifiInfo wifiInfo : aWifiInfos) {
|
||||
mWifiNetworks->AddItem(wifiInfo.ssid, LV_SYMBOL_WIFI, [] {});
|
||||
}
|
||||
};
|
||||
|
||||
mWifi->scan();
|
||||
|
||||
// mWifi->onScanDone([this](auto aWifiInfos) {
|
||||
//
|
||||
// });
|
||||
}
|
||||
|
||||
void WifiSettings::SetHeight(lv_coord_t aHeight) {
|
||||
Base::SetHeight(aHeight);
|
||||
mScanningText->AlignTo(this, LV_ALIGN_TOP_MID);
|
||||
mScanningText->SetHeight(15);
|
||||
const auto padding = 10;
|
||||
mWifiNetworks->AlignTo(mScanningText, LV_ALIGN_OUT_BOTTOM_MID, 0, padding);
|
||||
mWifiNetworks->SetHeight(GetContentHeight() - mScanningText->GetBottom() -
|
||||
padding);
|
||||
};
|
27
Platformio/OmoteUI/UIs/BasicRefactored/page/WifiSettings.hpp
Normal file
27
Platformio/OmoteUI/UIs/BasicRefactored/page/WifiSettings.hpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
#include "PageBase.hpp"
|
||||
#include "wifiHandlerInterface.h"
|
||||
|
||||
namespace UI::Widget {
|
||||
class List;
|
||||
class Label;
|
||||
} // namespace UI::Widget
|
||||
|
||||
namespace UI::Page {
|
||||
class WifiSettings : public Base {
|
||||
public:
|
||||
WifiSettings(std::shared_ptr<wifiHandlerInterface> aWifi);
|
||||
|
||||
std::string GetTitle() override { return "Wifi Settings"; };
|
||||
|
||||
void SetHeight(lv_coord_t aHeight) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<wifiHandlerInterface> mWifi;
|
||||
Handler<wifiHandlerInterface::ScanDoneDataTy> mScanCompleteHandler;
|
||||
|
||||
UI::Widget::Label *mScanningText;
|
||||
UI::Widget::List *mWifiNetworks;
|
||||
};
|
||||
|
||||
} // namespace UI::Page
|
|
@ -26,6 +26,7 @@ public:
|
|||
enum class Pages {
|
||||
Settings = static_cast<int>(Widgets::INVALID_WIDGET_ID) + 1,
|
||||
DisplaySettings,
|
||||
WifiSettings,
|
||||
SystemSettings,
|
||||
Demo,
|
||||
INVALID_PAGE_ID
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
#include "Label.hpp"
|
||||
#include "BackgroundScreen.hpp"
|
||||
#include "Colors.hpp"
|
||||
#include "LvglResourceManager.hpp"
|
||||
|
||||
using namespace UI::Widget;
|
||||
|
||||
Label::Label(std::string aText)
|
||||
: Base(lv_label_create(UI::Screen::BackgroundScreen::getLvInstance()), ID::Widgets::Label) {
|
||||
: Base(lv_label_create(UI::Screen::BackgroundScreen::getLvInstance()),
|
||||
ID::Widgets::Label) {
|
||||
SetText(aText);
|
||||
}
|
||||
|
||||
void Label::SetText(std::string aText) {
|
||||
auto lock = LvglResourceManager::GetInstance().scopeLock();
|
||||
lv_label_set_text(LvglSelf(), aText.c_str());
|
||||
}
|
|
@ -7,6 +7,8 @@ namespace UI::Widget {
|
|||
class Label : public Base {
|
||||
public:
|
||||
Label(std::string aText);
|
||||
|
||||
void SetText(std::string aText);
|
||||
};
|
||||
|
||||
} // namespace UI::Widget
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "List.hpp"
|
||||
#include "BackgroundScreen.hpp"
|
||||
#include "LvglResourceManager.hpp"
|
||||
using namespace UI;
|
||||
using namespace UI::Widget;
|
||||
|
||||
|
@ -22,7 +23,11 @@ List::List()
|
|||
|
||||
void List::AddItem(std::string aTitle, const char *aSymbol,
|
||||
std::function<void()> onItemSelected) {
|
||||
auto lvListItem = lv_list_add_btn(LvglSelf(), aSymbol, aTitle.c_str());
|
||||
lv_obj_t *lvListItem = nullptr;
|
||||
{
|
||||
auto lock = LvglResourceManager::GetInstance().scopeLock();
|
||||
lvListItem = lv_list_add_btn(LvglSelf(), aSymbol, aTitle.c_str());
|
||||
}
|
||||
mListItems.push_back(
|
||||
std::make_unique<ListItem>(lvListItem, std::move(onItemSelected)));
|
||||
mListItems.back()->SetHeight(lv_pct(20));
|
||||
|
|
Loading…
Add table
Reference in a new issue