rename hardwareAbstractionInterface
Change-Id: I39a9bcd7fc4d92b271a40a869faae7870d6d88a1
This commit is contained in:
parent
a0a46f729f
commit
55e2713127
5 changed files with 26 additions and 27 deletions
|
@ -3,7 +3,7 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
class HardwareSimulator : public HardwareAbstractionInterface {
|
||||
class HardwareSimulator : public HardwareInterface {
|
||||
public:
|
||||
HardwareSimulator() = default;
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#include <lvgl.h>
|
||||
#include <string>
|
||||
|
||||
class HardwareAbstractionInterface {
|
||||
class HardwareInterface {
|
||||
public:
|
||||
struct batteryStatus{
|
||||
struct batteryStatus {
|
||||
/// @brief Percent of battery remaining (0-100]
|
||||
int percentage;
|
||||
/// @brief Voltage of battery in millivolts
|
||||
|
@ -17,7 +17,7 @@ public:
|
|||
bool isCharging;
|
||||
};
|
||||
|
||||
HardwareAbstractionInterface() = default;
|
||||
HardwareInterface() = default;
|
||||
|
||||
virtual void init() = 0;
|
||||
virtual void sendIR() = 0;
|
||||
|
|
|
@ -4,23 +4,24 @@
|
|||
#define LV_CONF_INCLUDE_SIMPLE
|
||||
|
||||
#include "HardwareAbstractionInterface.h"
|
||||
#include "lvgl.h"
|
||||
#include "Images.hpp"
|
||||
#include "lvgl.h"
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
/// @brief Singleton to allow UI code to live separately from the Initialization
|
||||
/// of resources.
|
||||
class OmoteUI {
|
||||
public:
|
||||
OmoteUI(std::shared_ptr<HardwareAbstractionInterface> aHardware)
|
||||
: mHardware(aHardware) {};
|
||||
OmoteUI(std::shared_ptr<HardwareInterface> aHardware)
|
||||
: mHardware(aHardware){};
|
||||
|
||||
static std::weak_ptr<OmoteUI> getRefrence() { return getInstance(); };
|
||||
static std::shared_ptr<OmoteUI> getInstance(
|
||||
std::shared_ptr<HardwareAbstractionInterface> aHardware = nullptr) {
|
||||
static std::shared_ptr<OmoteUI>
|
||||
getInstance(std::shared_ptr<HardwareInterface> aHardware = nullptr) {
|
||||
if (mInstance) {
|
||||
return mInstance;
|
||||
} else if (aHardware) {
|
||||
|
@ -54,7 +55,7 @@ public:
|
|||
|
||||
private:
|
||||
static std::shared_ptr<OmoteUI> mInstance;
|
||||
std::shared_ptr<HardwareAbstractionInterface> mHardware;
|
||||
std::shared_ptr<HardwareInterface> mHardware;
|
||||
|
||||
lv_obj_t *panel = nullptr;
|
||||
Images imgs = Images();
|
||||
|
@ -62,7 +63,7 @@ private:
|
|||
int backlight_brightness = 255;
|
||||
lv_color_t color_primary = lv_color_hex(0x303030); // gray
|
||||
bool wakeupByIMUEnabled = true;
|
||||
|
||||
|
||||
inline static const uint_fast8_t virtualKeyMapTechnisat[10] = {
|
||||
0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x0};
|
||||
};
|
||||
|
|
|
@ -99,7 +99,7 @@ void HardwareRevX::MQTTPublish(const char *topic, const char *payload) {
|
|||
#endif
|
||||
}
|
||||
|
||||
HardwareAbstractionInterface::batteryStatus HardwareRevX::getBatteryPercentage(){
|
||||
HardwareInterface::batteryStatus HardwareRevX::getBatteryPercentage() {
|
||||
return battery;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,16 +10,17 @@
|
|||
#include <IRremoteESP8266.h>
|
||||
#include <IRsend.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 <Preferences.h>
|
||||
#include <PubSubClient.h>
|
||||
#include <TFT_eSPI.h> // Hardware-specific library
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
|
||||
#include "omoteconfig.h"
|
||||
|
||||
class HardwareRevX : public HardwareAbstractionInterface {
|
||||
class HardwareRevX : public HardwareInterface {
|
||||
public:
|
||||
enum class WakeReason { RESET, IMU, KEYPAD };
|
||||
|
||||
|
@ -29,12 +30,10 @@ public:
|
|||
}
|
||||
return mInstance;
|
||||
}
|
||||
static std::weak_ptr<HardwareRevX> getRefrence(){
|
||||
return getInstance();
|
||||
}
|
||||
static std::weak_ptr<HardwareRevX> getRefrence() { return getInstance(); }
|
||||
|
||||
HardwareRevX() : HardwareAbstractionInterface(){};
|
||||
// HardwareAbstractionInterface
|
||||
HardwareRevX() : HardwareInterface(){};
|
||||
// HardwareInterface
|
||||
virtual void init() override;
|
||||
virtual void sendIR() override;
|
||||
virtual void MQTTPublish(const char *topic, const char *payload) override;
|
||||
|
@ -62,7 +61,7 @@ protected:
|
|||
|
||||
// UI/UX Handlers
|
||||
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 handleWifiEvent(WiFiEvent_t event);
|
||||
|
@ -70,13 +69,12 @@ protected:
|
|||
// Tasks
|
||||
void startTasks();
|
||||
|
||||
static void updateBatteryTask([[maybe_unused]] void* aData);
|
||||
static void updateBatteryTask([[maybe_unused]] void *aData);
|
||||
TaskHandle_t batteryUpdateTskHndl = nullptr;
|
||||
|
||||
private:
|
||||
|
||||
// Static Wrappers Needed to Satisfy C APIs
|
||||
static void wiFiEventImpl(WiFiEvent_t event){
|
||||
static void wiFiEventImpl(WiFiEvent_t event) {
|
||||
mInstance->handleWifiEvent(event);
|
||||
}
|
||||
static void displayFlushImpl(lv_disp_drv_t *disp, const lv_area_t *area,
|
||||
|
@ -115,7 +113,7 @@ private:
|
|||
IRsend IrSender = IRsend(IR_LED, true);
|
||||
IRrecv IrReceiver = IRrecv(IR_RX);
|
||||
|
||||
HardwareAbstractionInterface::batteryStatus battery;
|
||||
HardwareInterface::batteryStatus battery;
|
||||
|
||||
// LVGL Screen Buffers
|
||||
lv_disp_draw_buf_t mdraw_buf;
|
||||
|
@ -148,7 +146,7 @@ private:
|
|||
{0x34, 0x0C, 0x22, 0x50, 0x55},
|
||||
{'?', 0x35, 0x2F, 0x32, 0x36}};
|
||||
byte virtualKeyMapTechnisat[10] = {0x1, 0x2, 0x3, 0x4, 0x5,
|
||||
0x6, 0x7, 0x8, 0x9, 0x0};
|
||||
0x6, 0x7, 0x8, 0x9, 0x0};
|
||||
|
||||
static std::shared_ptr<HardwareRevX> mInstance;
|
||||
};
|
Loading…
Add table
Reference in a new issue