remove IR and

mqtt functions from hardwareAbstraction
This commit is contained in:
Matthew Colvin 2023-08-11 21:51:54 -05:00 committed by MatthewColvin
parent 6bbc0e5e5d
commit a4e35a2219
6 changed files with 24 additions and 28 deletions

View file

@ -52,7 +52,10 @@
"streambuf": "cpp", "streambuf": "cpp",
"cinttypes": "cpp", "cinttypes": "cpp",
"typeinfo": "cpp", "typeinfo": "cpp",
"bit": "cpp" "bit": "cpp",
"compare": "cpp",
"concepts": "cpp",
"numbers": "cpp"
}, },
"cmake.sourceDirectory": "${workspaceFolder}/.pio/libdeps/esp32/Adafruit BusIO", "cmake.sourceDirectory": "${workspaceFolder}/.pio/libdeps/esp32/Adafruit BusIO",
"editor.formatOnSave": false, "editor.formatOnSave": false,

View file

@ -22,9 +22,11 @@ public:
HardwareAbstract(std::shared_ptr<BatteryInterface> aBattery = nullptr); HardwareAbstract(std::shared_ptr<BatteryInterface> aBattery = nullptr);
/// @brief Override in order to do setup of hardware devices
virtual void init() = 0; virtual void init() = 0;
virtual void sendIR() = 0;
virtual void MQTTPublish(const char *topic, const char *payload) = 0; /// @brief Override to allow printing of a message for debugging
/// @param message - Debug message
virtual void debugPrint(std::string message) = 0; virtual void debugPrint(std::string message) = 0;
private: private:

View file

@ -89,18 +89,23 @@ void HardwareRevX::debugPrint(std::string aDebugMessage) {
Serial.print(aDebugMessage.c_str()); Serial.print(aDebugMessage.c_str());
} }
void HardwareRevX::sendIR() {} // void HardwareRevX::MQTTPublish(const char *topic, const char *payload) {
// #ifdef ENABLE_WIFI
// if (client.connected()) {
// client.publish(topic, payload);
// } else {
// debugPrint("MQTT Client Not Connected When Attempting Publish.");
// }
// #else
// debugPrint("Attempting To Publish MQTT with wifi Disabled!");
// #endif
// }
void HardwareRevX::MQTTPublish(const char *topic, const char *payload) { std::shared_ptr<HardwareRevX> HardwareRevX::getInstance(){
#ifdef ENABLE_WIFI if (!mInstance) {
if (client.connected()) { mInstance = std::shared_ptr<HardwareRevX>(new HardwareRevX());
client.publish(topic, payload);
} else {
debugPrint("MQTT Client Not Connected When Attempting Publish.");
} }
#else return mInstance;
debugPrint("Attempting To Publish MQTT with wifi Disabled!");
#endif
} }
void HardwareRevX::initLVGL() { void HardwareRevX::initLVGL() {

View file

@ -25,18 +25,11 @@ class HardwareRevX : public HardwareAbstract {
public: public:
enum class WakeReason { RESET, IMU, KEYPAD }; enum class WakeReason { RESET, IMU, KEYPAD };
static std::shared_ptr<HardwareRevX> getInstance() { static std::shared_ptr<HardwareRevX> getInstance();
if (!mInstance) {
mInstance = std::shared_ptr<HardwareRevX>(new HardwareRevX());
}
return mInstance;
}
static std::weak_ptr<HardwareRevX> getRefrence() { return getInstance(); } static std::weak_ptr<HardwareRevX> getRefrence() { return getInstance(); }
// HardwareAbstract // HardwareAbstract
virtual void init() override; virtual void init() override;
virtual void sendIR() override;
virtual void MQTTPublish(const char *topic, const char *payload) override;
virtual void debugPrint(std::string aDebugMessage) override; virtual void debugPrint(std::string aDebugMessage) override;
void loopHandler(); void loopHandler();

View file

@ -11,12 +11,6 @@ public:
std::cout << message; std::cout << message;
} }
virtual void sendIR() override {}
virtual void MQTTPublish(const char *topic, const char *payload) override{
};
virtual void init() override; virtual void init() override;
virtual std::optional<HardwareAbstract::batteryStatus> getBatteryStatus() override { virtual std::optional<HardwareAbstract::batteryStatus> getBatteryStatus() override {

View file

@ -33,7 +33,6 @@ void OmoteUI::bl_slider_event_cb(lv_event_t *e) {
// Apple Key Event handler // Apple Key Event handler
void OmoteUI::appleKey_event_cb(lv_event_t *e) { void OmoteUI::appleKey_event_cb(lv_event_t *e) {
// Send IR command based on the event user data // Send IR command based on the event user data
mHardware->sendIR();
//mHardware->debugPrint(std::to_string(50 + (int)e->user_data)); //mHardware->debugPrint(std::to_string(50 + (int)e->user_data));
} }