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"
|
||||
|
||||
HardwareAbstract::HardwareAbstract(
|
||||
std::shared_ptr<DisplayAbstract> aDisplay,
|
||||
std::shared_ptr<BatteryInterface> aBattery,
|
||||
std::shared_ptr<wifiHandlerInterface> aWifiHandler,
|
||||
std::shared_ptr<DisplayAbstract> aDisplay
|
||||
std::shared_ptr<wifiHandlerInterface> aWifiHandler
|
||||
)
|
||||
: mBattery(std::move(aBattery)),
|
||||
mWifiHandler(std::move(aWifiHandler)),
|
||||
|
|
|
@ -15,11 +15,12 @@
|
|||
|
||||
class HardwareAbstract {
|
||||
public:
|
||||
HardwareAbstract(std::shared_ptr<BatteryInterface> aBattery = nullptr,
|
||||
std::shared_ptr<wifiHandlerInterface> aWifiHandler = nullptr,
|
||||
std::shared_ptr<DisplayAbstract> aDisplay = nullptr
|
||||
HardwareAbstract(
|
||||
std::shared_ptr<DisplayAbstract> aDisplay,
|
||||
std::shared_ptr<BatteryInterface> aBattery = nullptr,
|
||||
std::shared_ptr<wifiHandlerInterface> aWifiHandler = nullptr
|
||||
);
|
||||
|
||||
|
||||
struct batteryStatus {
|
||||
/// @brief Percent of battery remaining (0-100]
|
||||
int percentage;
|
||||
|
@ -29,25 +30,24 @@ public:
|
|||
};
|
||||
virtual std::optional<batteryStatus> getBatteryStatus();
|
||||
|
||||
/// @brief Register function to be ran when hardware notifies battery
|
||||
/// status has changed.
|
||||
/// @brief Register function to be ran when hardware notifies battery
|
||||
/// status has changed.
|
||||
/// @param onBatteryStatusChangeHandler - Callable to be ran when batter status changes
|
||||
void onBatteryChange(std::function<void(batteryStatus)> onBatteryStatusChangeHandler);
|
||||
|
||||
|
||||
/// @brief Override in order to do setup of hardware devices
|
||||
virtual void init() = 0;
|
||||
|
||||
|
||||
/// @brief Override to allow printing of a message for debugging
|
||||
/// @param message - Debug message
|
||||
virtual void debugPrint(std::string message) = 0;
|
||||
|
||||
protected:
|
||||
Notification<batteryStatus> mBatteryNotification;
|
||||
|
||||
|
||||
private:
|
||||
std::shared_ptr<BatteryInterface> mBattery;
|
||||
std::shared_ptr<wifiHandlerInterface> mWifiHandler;
|
||||
std::shared_ptr<DisplayAbstract> mDisplay;
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -53,9 +53,9 @@ void HardwareRevX::initIO() {
|
|||
|
||||
HardwareRevX::HardwareRevX():
|
||||
HardwareAbstract(
|
||||
Display::getInstance(standbyTimer),
|
||||
std::make_shared<Battery>(ADC_BAT,CRG_STAT),
|
||||
wifiHandler::getInstance(),
|
||||
Display::getInstance(standbyTimer)
|
||||
wifiHandler::getInstance()
|
||||
){}
|
||||
|
||||
HardwareRevX::WakeReason getWakeReason() {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class HardwareSimulator : public HardwareAbstract {
|
||||
public:
|
||||
HardwareSimulator() : HardwareAbstract(nullptr){};
|
||||
HardwareSimulator() : HardwareAbstract(){};
|
||||
|
||||
virtual void debugPrint(std::string message) override {
|
||||
std::cout << message;
|
||||
|
|
Loading…
Add table
Reference in a new issue