rename hardwareAbstractionInterface

Change-Id: I39a9bcd7fc4d92b271a40a869faae7870d6d88a1
This commit is contained in:
Matthew Colvin 2023-08-01 15:48:31 -05:00
parent 89bf2f2b2e
commit 37b3a0642c
5 changed files with 26 additions and 27 deletions

View file

@ -3,7 +3,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
class HardwareSimulator : public HardwareAbstractionInterface { class HardwareSimulator : public HardwareInterface {
public: public:
HardwareSimulator() = default; HardwareSimulator() = default;

View file

@ -5,9 +5,9 @@
#include <lvgl.h> #include <lvgl.h>
#include <string> #include <string>
class HardwareAbstractionInterface { class HardwareInterface {
public: public:
struct batteryStatus{ struct batteryStatus {
/// @brief Percent of battery remaining (0-100] /// @brief Percent of battery remaining (0-100]
int percentage; int percentage;
/// @brief Voltage of battery in millivolts /// @brief Voltage of battery in millivolts
@ -17,7 +17,7 @@ public:
bool isCharging; bool isCharging;
}; };
HardwareAbstractionInterface() = default; HardwareInterface() = default;
virtual void init() = 0; virtual void init() = 0;
virtual void sendIR() = 0; virtual void sendIR() = 0;

View file

@ -4,23 +4,24 @@
#define LV_CONF_INCLUDE_SIMPLE #define LV_CONF_INCLUDE_SIMPLE
#include "HardwareAbstractionInterface.h" #include "HardwareAbstractionInterface.h"
#include "lvgl.h"
#include "Images.hpp" #include "Images.hpp"
#include "lvgl.h"
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
/// @brief Singleton to allow UI code to live separately from the Initialization /// @brief Singleton to allow UI code to live separately from the Initialization
/// of resources. /// of resources.
class OmoteUI { class OmoteUI {
public: public:
OmoteUI(std::shared_ptr<HardwareAbstractionInterface> aHardware) OmoteUI(std::shared_ptr<HardwareInterface> aHardware)
: mHardware(aHardware) {}; : mHardware(aHardware){};
static std::weak_ptr<OmoteUI> getRefrence() { return getInstance(); }; static std::weak_ptr<OmoteUI> getRefrence() { return getInstance(); };
static std::shared_ptr<OmoteUI> getInstance( static std::shared_ptr<OmoteUI>
std::shared_ptr<HardwareAbstractionInterface> aHardware = nullptr) { getInstance(std::shared_ptr<HardwareInterface> aHardware = nullptr) {
if (mInstance) { if (mInstance) {
return mInstance; return mInstance;
} else if (aHardware) { } else if (aHardware) {
@ -54,7 +55,7 @@ public:
private: private:
static std::shared_ptr<OmoteUI> mInstance; static std::shared_ptr<OmoteUI> mInstance;
std::shared_ptr<HardwareAbstractionInterface> mHardware; std::shared_ptr<HardwareInterface> mHardware;
lv_obj_t *panel = nullptr; lv_obj_t *panel = nullptr;
Images imgs = Images(); Images imgs = Images();
@ -62,7 +63,7 @@ private:
int backlight_brightness = 255; int backlight_brightness = 255;
lv_color_t color_primary = lv_color_hex(0x303030); // gray lv_color_t color_primary = lv_color_hex(0x303030); // gray
bool wakeupByIMUEnabled = true; bool wakeupByIMUEnabled = true;
inline static const uint_fast8_t virtualKeyMapTechnisat[10] = { inline static const uint_fast8_t virtualKeyMapTechnisat[10] = {
0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0}; 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0};
}; };

View file

@ -99,7 +99,7 @@ void HardwareRevX::MQTTPublish(const char *topic, const char *payload) {
#endif #endif
} }
HardwareAbstractionInterface::batteryStatus HardwareRevX::getBatteryPercentage(){ HardwareInterface::batteryStatus HardwareRevX::getBatteryPercentage() {
return battery; return battery;
} }

View file

@ -10,16 +10,17 @@
#include <IRremoteESP8266.h> #include <IRremoteESP8266.h>
#include <IRsend.h> #include <IRsend.h>
#include <IRutils.h> #include <IRutils.h>
#include <PubSubClient.h>
#include <Preferences.h>
#include <TFT_eSPI.h> // Hardware-specific library
#include <Keypad.h> // modified for inverted logic #include <Keypad.h> // modified for inverted logic
#include <Preferences.h>
#include <PubSubClient.h>
#include <TFT_eSPI.h> // Hardware-specific library
#include <functional> #include <functional>
#include <memory> #include <memory>
#include "omoteconfig.h" #include "omoteconfig.h"
class HardwareRevX : public HardwareAbstractionInterface { class HardwareRevX : public HardwareInterface {
public: public:
enum class WakeReason { RESET, IMU, KEYPAD }; enum class WakeReason { RESET, IMU, KEYPAD };
@ -29,12 +30,10 @@ public:
} }
return mInstance; return mInstance;
} }
static std::weak_ptr<HardwareRevX> getRefrence(){ static std::weak_ptr<HardwareRevX> getRefrence() { return getInstance(); }
return getInstance();
}
HardwareRevX() : HardwareAbstractionInterface(){}; HardwareRevX() : HardwareInterface(){};
// HardwareAbstractionInterface // HardwareInterface
virtual void init() override; virtual void init() override;
virtual void sendIR() override; virtual void sendIR() override;
virtual void MQTTPublish(const char *topic, const char *payload) override; virtual void MQTTPublish(const char *topic, const char *payload) override;
@ -62,7 +61,7 @@ protected:
// UI/UX Handlers // UI/UX Handlers
void handleDisplayFlush(lv_disp_drv_t *disp, const lv_area_t *area, void handleDisplayFlush(lv_disp_drv_t *disp, const lv_area_t *area,
lv_color_t *color_p); lv_color_t *color_p);
void handleTouchPadRead(lv_indev_drv_t *indev_driver, lv_indev_data_t *data); void handleTouchPadRead(lv_indev_drv_t *indev_driver, lv_indev_data_t *data);
void handleWifiEvent(WiFiEvent_t event); void handleWifiEvent(WiFiEvent_t event);
@ -70,13 +69,12 @@ protected:
// Tasks // Tasks
void startTasks(); void startTasks();
static void updateBatteryTask([[maybe_unused]] void* aData); static void updateBatteryTask([[maybe_unused]] void *aData);
TaskHandle_t batteryUpdateTskHndl = nullptr; TaskHandle_t batteryUpdateTskHndl = nullptr;
private: private:
// Static Wrappers Needed to Satisfy C APIs // Static Wrappers Needed to Satisfy C APIs
static void wiFiEventImpl(WiFiEvent_t event){ static void wiFiEventImpl(WiFiEvent_t event) {
mInstance->handleWifiEvent(event); mInstance->handleWifiEvent(event);
} }
static void displayFlushImpl(lv_disp_drv_t *disp, const lv_area_t *area, static void displayFlushImpl(lv_disp_drv_t *disp, const lv_area_t *area,
@ -115,7 +113,7 @@ private:
IRsend IrSender = IRsend(IR_LED, true); IRsend IrSender = IRsend(IR_LED, true);
IRrecv IrReceiver = IRrecv(IR_RX); IRrecv IrReceiver = IRrecv(IR_RX);
HardwareAbstractionInterface::batteryStatus battery; HardwareInterface::batteryStatus battery;
// LVGL Screen Buffers // LVGL Screen Buffers
lv_disp_draw_buf_t mdraw_buf; lv_disp_draw_buf_t mdraw_buf;
@ -148,7 +146,7 @@ private:
{0x34, 0x0C, 0x22, 0x50, 0x55}, {0x34, 0x0C, 0x22, 0x50, 0x55},
{'?', 0x35, 0x2F, 0x32, 0x36}}; {'?', 0x35, 0x2F, 0x32, 0x36}};
byte virtualKeyMapTechnisat[10] = {0x1, 0x2, 0x3, 0x4, 0x5, byte virtualKeyMapTechnisat[10] = {0x1, 0x2, 0x3, 0x4, 0x5,
0x6, 0x7, 0x8, 0x9, 0x0}; 0x6, 0x7, 0x8, 0x9, 0x0};
static std::shared_ptr<HardwareRevX> mInstance; static std::shared_ptr<HardwareRevX> mInstance;
}; };