diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/BasicUI.cpp b/Platformio/OmoteUI/UIs/BasicRefactored/BasicUI.cpp new file mode 100644 index 0000000..9ccafd1 --- /dev/null +++ b/Platformio/OmoteUI/UIs/BasicRefactored/BasicUI.cpp @@ -0,0 +1,11 @@ +#include "BasicUI.hpp" +#include "HomeScreen.hpp" +#include "ScreenManager.hpp" + +using namespace UI; + +BasicUI::BasicUI(std::shared_ptr aHardware) + : UIBase(aHardware) { + Screen::Manager::getInstance().pushScreen( + std::make_unique()); +} \ No newline at end of file diff --git a/Platformio/OmoteUI/UIs/BasicRefactored/BasicUI.hpp b/Platformio/OmoteUI/UIs/BasicRefactored/BasicUI.hpp new file mode 100644 index 0000000..5bd6cb6 --- /dev/null +++ b/Platformio/OmoteUI/UIs/BasicRefactored/BasicUI.hpp @@ -0,0 +1,11 @@ +#pragma once +#include "UIBase.hpp" + +namespace UI { + +class BasicUI : public UIBase { +public: + BasicUI(std::shared_ptr aHardware); +}; + +} // namespace UI \ No newline at end of file diff --git a/Platformio/OmoteUI/UIs/UIBase.cpp b/Platformio/OmoteUI/UIs/UIBase.cpp index c21bf0f..7acb1b4 100644 --- a/Platformio/OmoteUI/UIs/UIBase.cpp +++ b/Platformio/OmoteUI/UIs/UIBase.cpp @@ -3,4 +3,9 @@ using namespace UI; UIBase::UIBase(std::shared_ptr aHardware) - : mHardware(aHardware) {} \ No newline at end of file + : mHardware(aHardware) {} + +void UIBase::loopHandler() { + lv_timer_handler(); + lv_task_handler(); +} \ No newline at end of file diff --git a/Platformio/OmoteUI/UIs/UIBase.hpp b/Platformio/OmoteUI/UIs/UIBase.hpp index e5d212c..3657393 100644 --- a/Platformio/OmoteUI/UIs/UIBase.hpp +++ b/Platformio/OmoteUI/UIs/UIBase.hpp @@ -11,6 +11,8 @@ class UIBase { public: UIBase(std::shared_ptr aHardware); + void loopHandler(); + protected: std::shared_ptr mHardware; }; diff --git a/Platformio/OmoteUI/core/UIElement.cpp b/Platformio/OmoteUI/core/UIElement.cpp index 372b96b..96000ef 100644 --- a/Platformio/OmoteUI/core/UIElement.cpp +++ b/Platformio/OmoteUI/core/UIElement.cpp @@ -6,4 +6,8 @@ UIElement::UIElement(lv_obj_t *aLvglSelf, ID aId) mLvglSelf->user_data = this; } +UIElement::SetBgColor(lv_color_t aColor, lv_style_selector_t aStyle) { + lv_obj_set_style_bg_color(mLvglSelf, aColor, aStyle); +}; + } // namespace UI diff --git a/Platformio/OmoteUI/core/UIElement.hpp b/Platformio/OmoteUI/core/UIElement.hpp index a7a199d..0d397f5 100644 --- a/Platformio/OmoteUI/core/UIElement.hpp +++ b/Platformio/OmoteUI/core/UIElement.hpp @@ -10,6 +10,8 @@ class UIElement { public: UIElement(lv_obj_t *aLvglSelf, const ID aId = ID()); + SetBgColor(lv_color_t value, lv_style_selector_t selector = LV_PART_MAIN); + protected: lv_obj_t *mLvglSelf; const ID mId; diff --git a/Platformio/OmoteUI/core/screen/HomeScreen.cpp b/Platformio/OmoteUI/core/screen/HomeScreen.cpp index 9df6b3e..7b414c3 100644 --- a/Platformio/OmoteUI/core/screen/HomeScreen.cpp +++ b/Platformio/OmoteUI/core/screen/HomeScreen.cpp @@ -2,4 +2,7 @@ using namespace UI::Screen; -HomeScreen::HomeScreen() : Base(UI::ID::Screens::Home) {} \ No newline at end of file +HomeScreen::HomeScreen() : Base(UI::ID::Screens::Home) { + + +} \ No newline at end of file diff --git a/Platformio/OmoteUI/core/screen/HomeScreen.hpp b/Platformio/OmoteUI/core/screen/HomeScreen.hpp index 93c6e55..48cc700 100644 --- a/Platformio/OmoteUI/core/screen/HomeScreen.hpp +++ b/Platformio/OmoteUI/core/screen/HomeScreen.hpp @@ -4,6 +4,7 @@ namespace UI::Screen { class HomeScreen : public Base { +public: HomeScreen(); }; diff --git a/Platformio/OmoteUI/core/screen/ScreenBase.cpp b/Platformio/OmoteUI/core/screen/ScreenBase.cpp index 6da63bd..e53d778 100644 --- a/Platformio/OmoteUI/core/screen/ScreenBase.cpp +++ b/Platformio/OmoteUI/core/screen/ScreenBase.cpp @@ -2,7 +2,7 @@ using namespace UI::Screen; -Base::Base(ID aId) : UIElement(mScreen, aId), mScreen(lv_obj_create(NULL)) {} +Base::Base(ID aId) : UIElement(lv_obj_create(NULL), aId) {} void Base::AddWidget(Widget::Base::Ptr aWidget) { mWidgets.push_back(std::move(aWidget)); diff --git a/Platformio/OmoteUI/core/screen/ScreenBase.hpp b/Platformio/OmoteUI/core/screen/ScreenBase.hpp index 85c45a8..533b2d3 100644 --- a/Platformio/OmoteUI/core/screen/ScreenBase.hpp +++ b/Platformio/OmoteUI/core/screen/ScreenBase.hpp @@ -17,7 +17,6 @@ public: void AddWidget(Widget::Base::Ptr aWidget); private: - lv_obj_t *mScreen; std::vector mWidgets; }; diff --git a/Platformio/platformio.ini b/Platformio/platformio.ini index ba9d32d..634da21 100644 --- a/Platformio/platformio.ini +++ b/Platformio/platformio.ini @@ -45,6 +45,7 @@ build_flags = -I OmoteUI/core/widget -I OmoteUI/UIs -I OmoteUI/UIs/Basic + -I OmoteUI/UIs/BasicRefactored -I HAL -I HAL/HardwareModules diff --git a/Platformio/src/simMain.cpp b/Platformio/src/simMain.cpp index 480bc7a..b791800 100644 --- a/Platformio/src/simMain.cpp +++ b/Platformio/src/simMain.cpp @@ -1,16 +1,17 @@ -#include "HardwareSimulator.hpp" -#include "omoteconfig.h" +#include "BasicUI.hpp" +#include "HardwareSimulator.hpp" #include "OmoteUI.hpp" -#include +#include "omoteconfig.h" +#include -int main(){ - auto hwSim = std::make_shared(); - hwSim->init(); +int main() { + auto hwSim = std::make_shared(); + hwSim->init(); - auto ui = UI::Basic::OmoteUI::getInstance(hwSim); - ui->layout_UI(); + auto ui = UI::BasicUI(hwSim); + // ui->layout_UI(); - while (true){ - ui->loopHandler(); - } + while (true) { + ui.loopHandler(); + } } \ No newline at end of file