forked from CoretechR/OMOTE
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework Mains so they are basically as identical as possible.
Create HardwareFactory which is responsible for providing the HardwareAbstract to any part of the program based on compiler defines
- Loading branch information
MatthewColvin
committed
Oct 15, 2023
1 parent
99787a6
commit efa2d4a
Showing
22 changed files
with
125 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "HardwareFactory.hpp" | ||
|
||
#if OMOTE_SIM | ||
#include "HardwareSimulator.hpp" | ||
#endif | ||
|
||
#if OMOTE_ESP32 | ||
#include "HardwareRevX.hpp" | ||
#endif | ||
|
||
#if OMOTE_SIM | ||
std::unique_ptr<HardwareAbstract> HardwareFactory::mHardware = | ||
std::make_unique<HardwareSimulator>(); | ||
#endif | ||
#if OMOTE_ESP32 | ||
std::unique_ptr<HardwareAbstract> HardwareFactory::mHardware = | ||
std::make_unique<HardwareRevX>(); | ||
#endif | ||
|
||
HardwareAbstract &HardwareFactory::getAbstract() { return *mHardware; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "HardwareAbstract.hpp" | ||
#include <memory> | ||
/** | ||
* @brief The HardwareFactory is responsible for making the | ||
*/ | ||
class HardwareFactory { | ||
public: | ||
static HardwareAbstract &getAbstract(); | ||
|
||
static std::unique_ptr<HardwareAbstract> mHardware; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
#include "BasicUI.hpp" | ||
#include "HardwareFactory.hpp" | ||
#include "HomeScreen.hpp" | ||
#include "ScreenManager.hpp" | ||
|
||
using namespace UI; | ||
|
||
BasicUI::BasicUI(std::shared_ptr<HardwareAbstract> aHardware) | ||
: UIBase(aHardware) { | ||
BasicUI::BasicUI() : UIBase() { | ||
|
||
aHardware->keys()->RegisterKeyPressHandler([](auto aKeyEvent) { | ||
return Screen::Manager::getInstance().distributeKeyEvent(aKeyEvent); | ||
// Could potentially add a check here and display that a key event was | ||
// unused. | ||
}); | ||
HardwareFactory::getAbstract().keys()->RegisterKeyPressHandler( | ||
[](auto aKeyEvent) { | ||
return Screen::Manager::getInstance().distributeKeyEvent(aKeyEvent); | ||
// Could potentially add a check here and display that a key event was | ||
// unused. | ||
}); | ||
|
||
Screen::Manager::getInstance().pushScreen( | ||
std::make_unique<Screen::HomeScreen>(aHardware)); | ||
std::make_unique<Screen::HomeScreen>()); | ||
|
||
mHardware->wifi()->begin(); | ||
HardwareFactory::getAbstract().wifi()->begin(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
#pragma once | ||
#include "PageBase.hpp" | ||
#include "HardwareAbstract.hpp" | ||
|
||
namespace UI::Page{ | ||
namespace UI::Page { | ||
|
||
class Demo : public Base{ | ||
class Demo : public Base { | ||
public: | ||
Demo(std::shared_ptr<HardwareAbstract> aHardware); | ||
Demo(); | ||
|
||
void AddSlider(); | ||
void AddSlider(); | ||
|
||
void OnShow()override{}; | ||
void OnHide()override{}; | ||
bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent); | ||
void OnShow() override{}; | ||
void OnHide() override{}; | ||
bool OnKeyEvent(KeyPressAbstract::KeyEvent aKeyEvent); | ||
|
||
private: | ||
std::shared_ptr<HardwareAbstract> mHardware; | ||
std::vector<UIElement *> sliders; | ||
std::vector<UIElement *> sliders; | ||
}; | ||
|
||
} | ||
} // namespace UI::Page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
Platformio/OmoteUI/UIs/BasicRefactored/screen/HomeScreen.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.