move display abstract to first parameter of hardware
abstract and no longer provide a default for it.
This commit is contained in:
parent
509d71cdaa
commit
b182f0b75d
4 changed files with 15 additions and 15 deletions
|
@ -1,9 +1,9 @@
|
||||||
#include "HardwareAbstract.hpp"
|
#include "HardwareAbstract.hpp"
|
||||||
|
|
||||||
HardwareAbstract::HardwareAbstract(
|
HardwareAbstract::HardwareAbstract(
|
||||||
|
std::shared_ptr<DisplayAbstract> aDisplay,
|
||||||
std::shared_ptr<BatteryInterface> aBattery,
|
std::shared_ptr<BatteryInterface> aBattery,
|
||||||
std::shared_ptr<wifiHandlerInterface> aWifiHandler,
|
std::shared_ptr<wifiHandlerInterface> aWifiHandler
|
||||||
std::shared_ptr<DisplayAbstract> aDisplay
|
|
||||||
)
|
)
|
||||||
: mBattery(std::move(aBattery)),
|
: mBattery(std::move(aBattery)),
|
||||||
mWifiHandler(std::move(aWifiHandler)),
|
mWifiHandler(std::move(aWifiHandler)),
|
||||||
|
|
|
@ -15,11 +15,12 @@
|
||||||
|
|
||||||
class HardwareAbstract {
|
class HardwareAbstract {
|
||||||
public:
|
public:
|
||||||
HardwareAbstract(std::shared_ptr<BatteryInterface> aBattery = nullptr,
|
HardwareAbstract(
|
||||||
std::shared_ptr<wifiHandlerInterface> aWifiHandler = nullptr,
|
std::shared_ptr<DisplayAbstract> aDisplay,
|
||||||
std::shared_ptr<DisplayAbstract> aDisplay = nullptr
|
std::shared_ptr<BatteryInterface> aBattery = nullptr,
|
||||||
|
std::shared_ptr<wifiHandlerInterface> aWifiHandler = nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
struct batteryStatus {
|
struct batteryStatus {
|
||||||
/// @brief Percent of battery remaining (0-100]
|
/// @brief Percent of battery remaining (0-100]
|
||||||
int percentage;
|
int percentage;
|
||||||
|
@ -29,25 +30,24 @@ public:
|
||||||
};
|
};
|
||||||
virtual std::optional<batteryStatus> getBatteryStatus();
|
virtual std::optional<batteryStatus> getBatteryStatus();
|
||||||
|
|
||||||
/// @brief Register function to be ran when hardware notifies battery
|
/// @brief Register function to be ran when hardware notifies battery
|
||||||
/// status has changed.
|
/// status has changed.
|
||||||
/// @param onBatteryStatusChangeHandler - Callable to be ran when batter status changes
|
/// @param onBatteryStatusChangeHandler - Callable to be ran when batter status changes
|
||||||
void onBatteryChange(std::function<void(batteryStatus)> onBatteryStatusChangeHandler);
|
void onBatteryChange(std::function<void(batteryStatus)> onBatteryStatusChangeHandler);
|
||||||
|
|
||||||
/// @brief Override in order to do setup of hardware devices
|
/// @brief Override in order to do setup of hardware devices
|
||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
|
|
||||||
/// @brief Override to allow printing of a message for debugging
|
/// @brief Override to allow printing of a message for debugging
|
||||||
/// @param message - Debug message
|
/// @param message - Debug message
|
||||||
virtual void debugPrint(std::string message) = 0;
|
virtual void debugPrint(std::string message) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Notification<batteryStatus> mBatteryNotification;
|
Notification<batteryStatus> mBatteryNotification;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<BatteryInterface> mBattery;
|
std::shared_ptr<BatteryInterface> mBattery;
|
||||||
std::shared_ptr<wifiHandlerInterface> mWifiHandler;
|
std::shared_ptr<wifiHandlerInterface> mWifiHandler;
|
||||||
std::shared_ptr<DisplayAbstract> mDisplay;
|
std::shared_ptr<DisplayAbstract> mDisplay;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,9 +53,9 @@ void HardwareRevX::initIO() {
|
||||||
|
|
||||||
HardwareRevX::HardwareRevX():
|
HardwareRevX::HardwareRevX():
|
||||||
HardwareAbstract(
|
HardwareAbstract(
|
||||||
|
Display::getInstance(standbyTimer),
|
||||||
std::make_shared<Battery>(ADC_BAT,CRG_STAT),
|
std::make_shared<Battery>(ADC_BAT,CRG_STAT),
|
||||||
wifiHandler::getInstance(),
|
wifiHandler::getInstance()
|
||||||
Display::getInstance(standbyTimer)
|
|
||||||
){}
|
){}
|
||||||
|
|
||||||
HardwareRevX::WakeReason getWakeReason() {
|
HardwareRevX::WakeReason getWakeReason() {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
class HardwareSimulator : public HardwareAbstract {
|
class HardwareSimulator : public HardwareAbstract {
|
||||||
public:
|
public:
|
||||||
HardwareSimulator() : HardwareAbstract(nullptr){};
|
HardwareSimulator() : HardwareAbstract(){};
|
||||||
|
|
||||||
virtual void debugPrint(std::string message) override {
|
virtual void debugPrint(std::string message) override {
|
||||||
std::cout << message;
|
std::cout << message;
|
||||||
|
|
Loading…
Add table
Reference in a new issue