From 37b3a0642c4392e4b6c9dd194865602a81b8f9e2 Mon Sep 17 00:00:00 2001 From: Matthew Colvin Date: Tue, 1 Aug 2023 15:48:31 -0500 Subject: [PATCH] rename hardwareAbstractionInterface Change-Id: I39a9bcd7fc4d92b271a40a869faae7870d6d88a1 --- .../LVGL.Simulator/HardwareSimulator.hpp | 2 +- .../OmoteUI/HardwareAbstractionInterface.h | 6 ++-- Platformio/include/OmoteUI/OmoteUI.hpp | 15 +++++----- Platformio/src/HardwareRevX.cpp | 2 +- Platformio/src/HardwareRevX.hpp | 28 +++++++++---------- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/LVGL Simulator/LVGL.Simulator/HardwareSimulator.hpp b/LVGL Simulator/LVGL.Simulator/HardwareSimulator.hpp index 131c7f0..f650b3c 100644 --- a/LVGL Simulator/LVGL.Simulator/HardwareSimulator.hpp +++ b/LVGL Simulator/LVGL.Simulator/HardwareSimulator.hpp @@ -3,7 +3,7 @@ #include #include -class HardwareSimulator : public HardwareAbstractionInterface { +class HardwareSimulator : public HardwareInterface { public: HardwareSimulator() = default; diff --git a/Platformio/include/OmoteUI/HardwareAbstractionInterface.h b/Platformio/include/OmoteUI/HardwareAbstractionInterface.h index 420b8f4..71a455f 100644 --- a/Platformio/include/OmoteUI/HardwareAbstractionInterface.h +++ b/Platformio/include/OmoteUI/HardwareAbstractionInterface.h @@ -5,9 +5,9 @@ #include #include -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; diff --git a/Platformio/include/OmoteUI/OmoteUI.hpp b/Platformio/include/OmoteUI/OmoteUI.hpp index ff966ed..3c3aa56 100644 --- a/Platformio/include/OmoteUI/OmoteUI.hpp +++ b/Platformio/include/OmoteUI/OmoteUI.hpp @@ -4,23 +4,24 @@ #define LV_CONF_INCLUDE_SIMPLE #include "HardwareAbstractionInterface.h" -#include "lvgl.h" #include "Images.hpp" +#include "lvgl.h" #include #include #include #include + /// @brief Singleton to allow UI code to live separately from the Initialization /// of resources. class OmoteUI { public: - OmoteUI(std::shared_ptr aHardware) - : mHardware(aHardware) {}; + OmoteUI(std::shared_ptr aHardware) + : mHardware(aHardware){}; static std::weak_ptr getRefrence() { return getInstance(); }; - static std::shared_ptr getInstance( - std::shared_ptr aHardware = nullptr) { + static std::shared_ptr + getInstance(std::shared_ptr aHardware = nullptr) { if (mInstance) { return mInstance; } else if (aHardware) { @@ -54,7 +55,7 @@ public: private: static std::shared_ptr mInstance; - std::shared_ptr mHardware; + std::shared_ptr 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}; }; diff --git a/Platformio/src/HardwareRevX.cpp b/Platformio/src/HardwareRevX.cpp index 7184667..161163a 100644 --- a/Platformio/src/HardwareRevX.cpp +++ b/Platformio/src/HardwareRevX.cpp @@ -99,7 +99,7 @@ void HardwareRevX::MQTTPublish(const char *topic, const char *payload) { #endif } -HardwareAbstractionInterface::batteryStatus HardwareRevX::getBatteryPercentage(){ +HardwareInterface::batteryStatus HardwareRevX::getBatteryPercentage() { return battery; } diff --git a/Platformio/src/HardwareRevX.hpp b/Platformio/src/HardwareRevX.hpp index 4a35c92..43335fb 100644 --- a/Platformio/src/HardwareRevX.hpp +++ b/Platformio/src/HardwareRevX.hpp @@ -10,16 +10,17 @@ #include #include #include -#include -#include -#include // Hardware-specific library #include // modified for inverted logic +#include +#include +#include // Hardware-specific library #include #include + #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 getRefrence(){ - return getInstance(); - } + static std::weak_ptr 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 mInstance; }; \ No newline at end of file