From 2345ba6d139a55be0814d202853536850bc075b5 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 9 Feb 2025 16:48:23 +0100 Subject: [PATCH] HAL renaming & relocation (#215) Implemented more consistent naming: - Moved all HAL devices into their own namespace (and related folder) - Post-fixed all HAL device names with "Device" --- .../Source/hal/YellowDisplay.cpp | 2 +- .../CYD-2432S024C/Source/hal/YellowDisplay.h | 4 ++-- .../CYD-2432S024C/Source/hal/YellowSdCard.cpp | 16 ++++++++------ .../CYD-2432S024C/Source/hal/YellowSdCard.h | 6 ++--- Boards/CYD-2432S024C/Source/hal/YellowTouch.h | 4 ++-- .../LilygoTdeck/Source/hal/TdeckDisplay.cpp | 4 ++-- Boards/LilygoTdeck/Source/hal/TdeckDisplay.h | 12 ++++------ .../LilygoTdeck/Source/hal/TdeckKeyboard.cpp | 2 +- Boards/LilygoTdeck/Source/hal/TdeckKeyboard.h | 6 ++--- Boards/LilygoTdeck/Source/hal/TdeckPower.cpp | 6 ++--- Boards/LilygoTdeck/Source/hal/TdeckPower.h | 10 ++++----- Boards/LilygoTdeck/Source/hal/TdeckSdCard.cpp | 16 ++++++++------ Boards/LilygoTdeck/Source/hal/TdeckSdCard.h | 6 ++--- Boards/LilygoTdeck/Source/hal/TdeckTouch.h | 4 ++-- .../M5stackCore2/Source/hal/Core2Display.cpp | 2 +- Boards/M5stackCore2/Source/hal/Core2Display.h | 4 ++-- Boards/M5stackCore2/Source/hal/Core2Power.cpp | 6 ++--- Boards/M5stackCore2/Source/hal/Core2Power.h | 10 ++++----- .../M5stackCore2/Source/hal/Core2SdCard.cpp | 16 ++++++++------ Boards/M5stackCore2/Source/hal/Core2SdCard.h | 6 ++--- Boards/M5stackCore2/Source/hal/Core2Touch.h | 6 ++--- .../Source/hal/CoreS3Display.cpp | 4 ++-- .../M5stackCoreS3/Source/hal/CoreS3Display.h | 4 ++-- .../M5stackCoreS3/Source/hal/CoreS3Power.cpp | 6 ++--- Boards/M5stackCoreS3/Source/hal/CoreS3Power.h | 10 ++++----- .../M5stackCoreS3/Source/hal/CoreS3SdCard.cpp | 16 ++++++++------ .../M5stackCoreS3/Source/hal/CoreS3SdCard.h | 6 ++--- Boards/M5stackCoreS3/Source/hal/CoreS3Touch.h | 4 ++-- Boards/Simulator/Source/hal/SdlDisplay.h | 8 +++---- Boards/Simulator/Source/hal/SdlKeyboard.h | 6 ++--- Boards/Simulator/Source/hal/SdlTouch.h | 4 ++-- .../Simulator/Source/hal/SimulatorPower.cpp | 6 ++--- Boards/Simulator/Source/hal/SimulatorPower.h | 10 ++++----- Boards/Simulator/Source/hal/SimulatorSdCard.h | 8 +++---- Boards/UnPhone/Source/hal/UnPhoneDisplay.cpp | 4 ++-- Boards/UnPhone/Source/hal/UnPhoneDisplay.h | 8 +++---- Boards/UnPhone/Source/hal/UnPhonePower.cpp | 6 ++--- Boards/UnPhone/Source/hal/UnPhonePower.h | 10 ++++----- Boards/UnPhone/Source/hal/UnPhoneSdCard.cpp | 16 ++++++++------ Boards/UnPhone/Source/hal/UnPhoneSdCard.h | 6 ++--- Boards/UnPhone/Source/hal/UnPhoneTouch.h | 4 ++-- Drivers/ILI934x/Source/Ili934xDisplay.h | 12 +++++----- Tactility/Source/app/ElfApp.cpp | 4 ++-- Tactility/Source/app/boot/Boot.cpp | 7 +++--- Tactility/Source/app/display/Display.cpp | 8 +++---- Tactility/Source/app/files/State.cpp | 6 ++--- Tactility/Source/app/power/Power.cpp | 18 +++++++-------- .../Source/app/screenshot/Screenshot.cpp | 10 ++++++--- Tactility/Source/lvgl/Init.cpp | 12 +++++----- .../Source/service/statusbar/Statusbar.cpp | 22 +++++++++---------- .../Include/Tactility/hal/Configuration.h | 19 ++++++++-------- .../{Display.h => display/DisplayDevice.h} | 14 +++++++----- .../{Keyboard.h => keyboard/KeyboardDevice.h} | 6 ++--- .../hal/{Power.h => power/PowerDevice.h} | 12 +++++----- .../hal/{SdCard.h => sdcard/SdCardDevice.h} | 14 ++++++------ .../{SpiSdCard.h => sdcard/SpiSdCardDevice.h} | 13 ++++++----- .../hal/{Touch.h => touch/TouchDevice.h} | 6 ++--- TactilityHeadless/Source/hal/Hal.cpp | 4 ++-- .../Source/hal/{ => sdcard}/SdCard.cpp | 8 +++---- .../Source/hal/{ => sdcard}/SpiSdCard.cpp | 14 ++++++------ TactilityHeadless/Source/hal/usb/Usb.cpp | 6 ++--- .../Source/service/sdcard/Sdcard.cpp | 4 ++-- 62 files changed, 263 insertions(+), 250 deletions(-) rename TactilityHeadless/Include/Tactility/hal/{Display.h => display/DisplayDevice.h} (78%) rename TactilityHeadless/Include/Tactility/hal/{Keyboard.h => keyboard/KeyboardDevice.h} (76%) rename TactilityHeadless/Include/Tactility/hal/{Power.h => power/PowerDevice.h} (80%) rename TactilityHeadless/Include/Tactility/hal/{SdCard.h => sdcard/SdCardDevice.h} (82%) rename TactilityHeadless/Include/Tactility/hal/{SpiSdCard.h => sdcard/SpiSdCardDevice.h} (89%) rename TactilityHeadless/Include/Tactility/hal/{Touch.h => touch/TouchDevice.h} (75%) rename TactilityHeadless/Source/hal/{ => sdcard}/SdCard.cpp (52%) rename TactilityHeadless/Source/hal/{ => sdcard}/SpiSdCard.cpp (92%) diff --git a/Boards/CYD-2432S024C/Source/hal/YellowDisplay.cpp b/Boards/CYD-2432S024C/Source/hal/YellowDisplay.cpp index 3ad003a4..9a951558 100644 --- a/Boards/CYD-2432S024C/Source/hal/YellowDisplay.cpp +++ b/Boards/CYD-2432S024C/Source/hal/YellowDisplay.cpp @@ -71,7 +71,7 @@ void setBacklightDuty(uint8_t backlightDuty) { } -std::shared_ptr createDisplay() { +std::shared_ptr createDisplay() { auto touch = std::make_shared(); diff --git a/Boards/CYD-2432S024C/Source/hal/YellowDisplay.h b/Boards/CYD-2432S024C/Source/hal/YellowDisplay.h index 64a4e0b7..036603c9 100644 --- a/Boards/CYD-2432S024C/Source/hal/YellowDisplay.h +++ b/Boards/CYD-2432S024C/Source/hal/YellowDisplay.h @@ -1,6 +1,6 @@ #pragma once -#include +#include "Tactility/hal/display/DisplayDevice.h" #include -std::shared_ptr createDisplay(); +std::shared_ptr createDisplay(); diff --git a/Boards/CYD-2432S024C/Source/hal/YellowSdCard.cpp b/Boards/CYD-2432S024C/Source/hal/YellowSdCard.cpp index c465a7a5..823958eb 100644 --- a/Boards/CYD-2432S024C/Source/hal/YellowSdCard.cpp +++ b/Boards/CYD-2432S024C/Source/hal/YellowSdCard.cpp @@ -2,28 +2,30 @@ #define TAG "twodotfour_sdcard" +#include #include -#include #define SDCARD_SPI_HOST SPI3_HOST #define SDCARD_PIN_CS GPIO_NUM_5 -std::shared_ptr createYellowSdCard() { - auto* configuration = new tt::hal::SpiSdCard::Config( +using tt::hal::sdcard::SpiSdCardDevice; + +std::shared_ptr createYellowSdCard() { + auto* configuration = new SpiSdCardDevice::Config( SDCARD_PIN_CS, GPIO_NUM_NC, GPIO_NUM_NC, GPIO_NUM_NC, - SdCard::MountBehaviour::AtBoot, + SdCardDevice::MountBehaviour::AtBoot, std::make_shared(), std::vector(), SDCARD_SPI_HOST ); - auto* sdcard = (SdCard*) new SpiSdCard( - std::unique_ptr(configuration) + auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( + std::unique_ptr(configuration) ); - return std::shared_ptr(sdcard); + return std::shared_ptr(sdcard); } diff --git a/Boards/CYD-2432S024C/Source/hal/YellowSdCard.h b/Boards/CYD-2432S024C/Source/hal/YellowSdCard.h index b0692219..772f7119 100644 --- a/Boards/CYD-2432S024C/Source/hal/YellowSdCard.h +++ b/Boards/CYD-2432S024C/Source/hal/YellowSdCard.h @@ -1,8 +1,8 @@ #pragma once -#include +#include "Tactility/hal/sdcard/SdCardDevice.h" -using namespace tt::hal; +using tt::hal::sdcard::SdCardDevice; -std::shared_ptr createYellowSdCard(); +std::shared_ptr createYellowSdCard(); diff --git a/Boards/CYD-2432S024C/Source/hal/YellowTouch.h b/Boards/CYD-2432S024C/Source/hal/YellowTouch.h index 57dbcef5..5a742a59 100644 --- a/Boards/CYD-2432S024C/Source/hal/YellowTouch.h +++ b/Boards/CYD-2432S024C/Source/hal/YellowTouch.h @@ -1,10 +1,10 @@ #pragma once -#include +#include "Tactility/hal/touch/TouchDevice.h" #include #include -class YellowTouch : public tt::hal::Touch { +class YellowTouch : public tt::hal::touch::TouchDevice { private: diff --git a/Boards/LilygoTdeck/Source/hal/TdeckDisplay.cpp b/Boards/LilygoTdeck/Source/hal/TdeckDisplay.cpp index 8d42a7eb..e1d8759e 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckDisplay.cpp +++ b/Boards/LilygoTdeck/Source/hal/TdeckDisplay.cpp @@ -191,7 +191,7 @@ void TdeckDisplay::setPowerOn(bool turnOn) { } } -std::shared_ptr _Nullable TdeckDisplay::createTouch() { +std::shared_ptr _Nullable TdeckDisplay::createTouch() { return std::make_shared(); } @@ -233,6 +233,6 @@ void TdeckDisplay::setGammaCurve(uint8_t index) { } } -std::shared_ptr createDisplay() { +std::shared_ptr createDisplay() { return std::make_shared(); } diff --git a/Boards/LilygoTdeck/Source/hal/TdeckDisplay.h b/Boards/LilygoTdeck/Source/hal/TdeckDisplay.h index ba9293bb..29bb05e7 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckDisplay.h +++ b/Boards/LilygoTdeck/Source/hal/TdeckDisplay.h @@ -1,10 +1,10 @@ #pragma once +#include "Tactility/hal/display/DisplayDevice.h" #include #include -#include -class TdeckDisplay : public tt::hal::Display { +class TdeckDisplay : public tt::hal::display::DisplayDevice { private: @@ -26,7 +26,7 @@ public: bool isPoweredOn() const override { return poweredOn; }; bool supportsPowerControl() const override { return true; } - std::shared_ptr _Nullable createTouch() override; + std::shared_ptr _Nullable createTouch() override; void setBacklightDuty(uint8_t backlightDuty) override; bool supportsBacklightDuty() const override { return true; } @@ -35,10 +35,6 @@ public: uint8_t getGammaCurveCount() const override { return 4; }; lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; } - -private: - - static bool startBacklight(); }; -std::shared_ptr createDisplay(); +std::shared_ptr createDisplay(); diff --git a/Boards/LilygoTdeck/Source/hal/TdeckKeyboard.cpp b/Boards/LilygoTdeck/Source/hal/TdeckKeyboard.cpp index 1f257cc2..47c8590d 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckKeyboard.cpp +++ b/Boards/LilygoTdeck/Source/hal/TdeckKeyboard.cpp @@ -62,6 +62,6 @@ bool TdeckKeyboard::isAttached() const { return tt::hal::i2c::masterHasDeviceAtAddress(TDECK_KEYBOARD_I2C_BUS_HANDLE, TDECK_KEYBOARD_SLAVE_ADDRESS, 100); } -std::shared_ptr createKeyboard() { +std::shared_ptr createKeyboard() { return std::make_shared(); } diff --git a/Boards/LilygoTdeck/Source/hal/TdeckKeyboard.h b/Boards/LilygoTdeck/Source/hal/TdeckKeyboard.h index 566d2b2f..26eea592 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckKeyboard.h +++ b/Boards/LilygoTdeck/Source/hal/TdeckKeyboard.h @@ -1,11 +1,11 @@ #pragma once -#include +#include #include #include #include -class TdeckKeyboard : public tt::hal::Keyboard { +class TdeckKeyboard : public tt::hal::keyboard::KeyboardDevice { private: @@ -22,4 +22,4 @@ public: lv_indev_t* _Nullable getLvglIndev() override { return deviceHandle; } }; -std::shared_ptr createKeyboard(); +std::shared_ptr createKeyboard(); diff --git a/Boards/LilygoTdeck/Source/hal/TdeckPower.cpp b/Boards/LilygoTdeck/Source/hal/TdeckPower.cpp index 95383964..008198db 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckPower.cpp +++ b/Boards/LilygoTdeck/Source/hal/TdeckPower.cpp @@ -66,7 +66,7 @@ bool TdeckPower::supportsMetric(MetricType type) const { return false; // Safety guard for when new enum values are introduced } -bool TdeckPower::getMetric(Power::MetricType type, Power::MetricData& data) { +bool TdeckPower::getMetric(MetricType type, MetricData& data) { switch (type) { using enum MetricType; case BatteryVoltage: @@ -119,9 +119,9 @@ bool TdeckPower::readBatteryVoltageSampled(uint32_t& output) { } } -static std::shared_ptr power; +static std::shared_ptr power; -std::shared_ptr tdeck_get_power() { +std::shared_ptr tdeck_get_power() { if (power == nullptr) { power = std::make_shared(); } diff --git a/Boards/LilygoTdeck/Source/hal/TdeckPower.h b/Boards/LilygoTdeck/Source/hal/TdeckPower.h index fc6467ef..4dc4d75c 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckPower.h +++ b/Boards/LilygoTdeck/Source/hal/TdeckPower.h @@ -1,12 +1,12 @@ #pragma once -#include +#include "Tactility/hal/power/PowerDevice.h" #include #include -using namespace tt::hal; +using tt::hal::power::PowerDevice; -class TdeckPower : public Power { +class TdeckPower : public PowerDevice { adc_oneshot_unit_handle_t adcHandle = nullptr; @@ -19,7 +19,7 @@ public: std::string getDescription() const final { return "Power measurement interface via ADC pin"; } bool supportsMetric(MetricType type) const override; - bool getMetric(Power::MetricType type, Power::MetricData& data) override; + bool getMetric(MetricType type, MetricData& data) override; private: @@ -27,4 +27,4 @@ private: bool readBatteryVoltageOnce(uint32_t& output); }; -std::shared_ptr tdeck_get_power(); +std::shared_ptr tdeck_get_power(); diff --git a/Boards/LilygoTdeck/Source/hal/TdeckSdCard.cpp b/Boards/LilygoTdeck/Source/hal/TdeckSdCard.cpp index f6833296..1f24bd97 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckSdCard.cpp +++ b/Boards/LilygoTdeck/Source/hal/TdeckSdCard.cpp @@ -1,21 +1,23 @@ #include "TdeckSdCard.h" #include -#include +#include #include +using tt::hal::sdcard::SpiSdCardDevice; + #define TDECK_SDCARD_PIN_CS GPIO_NUM_39 #define TDECK_LCD_PIN_CS GPIO_NUM_12 #define TDECK_RADIO_PIN_CS GPIO_NUM_9 -std::shared_ptr createTdeckSdCard() { - auto* configuration = new tt::hal::SpiSdCard::Config( +std::shared_ptr createTdeckSdCard() { + auto* configuration = new SpiSdCardDevice::Config( TDECK_SDCARD_PIN_CS, GPIO_NUM_NC, GPIO_NUM_NC, GPIO_NUM_NC, - SdCard::MountBehaviour::AtBoot, + SdCardDevice::MountBehaviour::AtBoot, tt::lvgl::getLvglSyncLockable(), { TDECK_RADIO_PIN_CS, @@ -23,9 +25,9 @@ std::shared_ptr createTdeckSdCard() { } ); - auto* sdcard = (SdCard*) new SpiSdCard( - std::unique_ptr(configuration) + auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( + std::unique_ptr(configuration) ); - return std::shared_ptr(sdcard); + return std::shared_ptr(sdcard); } diff --git a/Boards/LilygoTdeck/Source/hal/TdeckSdCard.h b/Boards/LilygoTdeck/Source/hal/TdeckSdCard.h index 63a45433..e12eb6d0 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckSdCard.h +++ b/Boards/LilygoTdeck/Source/hal/TdeckSdCard.h @@ -1,7 +1,7 @@ #pragma once -#include +#include "Tactility/hal/sdcard/SdCardDevice.h" -using namespace tt::hal; +using tt::hal::sdcard::SdCardDevice; -std::shared_ptr createTdeckSdCard(); +std::shared_ptr createTdeckSdCard(); diff --git a/Boards/LilygoTdeck/Source/hal/TdeckTouch.h b/Boards/LilygoTdeck/Source/hal/TdeckTouch.h index 73ce708b..37bac956 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckTouch.h +++ b/Boards/LilygoTdeck/Source/hal/TdeckTouch.h @@ -1,11 +1,11 @@ #pragma once -#include +#include "Tactility/hal/touch/TouchDevice.h" #include #include #include -class TdeckTouch : public tt::hal::Touch { +class TdeckTouch : public tt::hal::touch::TouchDevice { private: diff --git a/Boards/M5stackCore2/Source/hal/Core2Display.cpp b/Boards/M5stackCore2/Source/hal/Core2Display.cpp index 8615988a..43b72065 100644 --- a/Boards/M5stackCore2/Source/hal/Core2Display.cpp +++ b/Boards/M5stackCore2/Source/hal/Core2Display.cpp @@ -3,7 +3,7 @@ #include -std::shared_ptr createDisplay() { +std::shared_ptr createDisplay() { auto touch = std::make_shared(); auto configuration = std::make_unique( diff --git a/Boards/M5stackCore2/Source/hal/Core2Display.h b/Boards/M5stackCore2/Source/hal/Core2Display.h index 4a035f6c..75c13107 100644 --- a/Boards/M5stackCore2/Source/hal/Core2Display.h +++ b/Boards/M5stackCore2/Source/hal/Core2Display.h @@ -1,6 +1,6 @@ #pragma once -#include +#include "Tactility/hal/display/DisplayDevice.h" #include #define CORE2_LCD_SPI_HOST SPI2_HOST @@ -11,4 +11,4 @@ #define CORE2_LCD_DRAW_BUFFER_HEIGHT (CORE2_LCD_VERTICAL_RESOLUTION / 10) #define CORE2_LCD_DRAW_BUFFER_SIZE (CORE2_LCD_HORIZONTAL_RESOLUTION * CORE2_LCD_DRAW_BUFFER_HEIGHT) -std::shared_ptr createDisplay(); +std::shared_ptr createDisplay(); diff --git a/Boards/M5stackCore2/Source/hal/Core2Power.cpp b/Boards/M5stackCore2/Source/hal/Core2Power.cpp index 9fd64ad1..504ff594 100644 --- a/Boards/M5stackCore2/Source/hal/Core2Power.cpp +++ b/Boards/M5stackCore2/Source/hal/Core2Power.cpp @@ -20,7 +20,7 @@ bool Core2Power::supportsMetric(MetricType type) const { return false; // Safety guard for when new enum values are introduced } -bool Core2Power::getMetric(Power::MetricType type, Power::MetricData& data) { +bool Core2Power::getMetric(MetricType type, MetricData& data) { switch (type) { using enum MetricType; case BatteryVoltage: { @@ -100,9 +100,9 @@ void Core2Power::setAllowedToCharge(bool canCharge) { } } -static std::shared_ptr power; +static std::shared_ptr power; -std::shared_ptr createPower() { +std::shared_ptr createPower() { if (power == nullptr) { power = std::make_shared(); } diff --git a/Boards/M5stackCore2/Source/hal/Core2Power.h b/Boards/M5stackCore2/Source/hal/Core2Power.h index 44583c70..c1e29b15 100644 --- a/Boards/M5stackCore2/Source/hal/Core2Power.h +++ b/Boards/M5stackCore2/Source/hal/Core2Power.h @@ -1,11 +1,11 @@ #pragma once -#include +#include "Tactility/hal/power/PowerDevice.h" #include -using namespace tt::hal; +using tt::hal::power::PowerDevice; -class Core2Power : public Power { +class Core2Power : public PowerDevice { public: @@ -16,11 +16,11 @@ public: std::string getDescription() const final { return "Power management via I2C"; } bool supportsMetric(MetricType type) const override; - bool getMetric(Power::MetricType type, Power::MetricData& data) override; + bool getMetric(MetricType type, MetricData& data) override; bool supportsChargeControl() const override { return true; } bool isAllowedToCharge() const override; void setAllowedToCharge(bool canCharge) override; }; -std::shared_ptr createPower(); +std::shared_ptr createPower(); diff --git a/Boards/M5stackCore2/Source/hal/Core2SdCard.cpp b/Boards/M5stackCore2/Source/hal/Core2SdCard.cpp index 701d02e4..075c2494 100644 --- a/Boards/M5stackCore2/Source/hal/Core2SdCard.cpp +++ b/Boards/M5stackCore2/Source/hal/Core2SdCard.cpp @@ -1,29 +1,31 @@ #include "Core2SdCard.h" +#include #include -#include #include #define CORE2_SDCARD_PIN_CS GPIO_NUM_4 #define CORE2_LCD_PIN_CS GPIO_NUM_5 -std::shared_ptr createSdCard() { - auto* configuration = new tt::hal::SpiSdCard::Config( +using tt::hal::sdcard::SpiSdCardDevice; + +std::shared_ptr createSdCard() { + auto* configuration = new SpiSdCardDevice::Config( CORE2_SDCARD_PIN_CS, GPIO_NUM_NC, GPIO_NUM_NC, GPIO_NUM_NC, - SdCard::MountBehaviour::AtBoot, + SdCardDevice::MountBehaviour::AtBoot, tt::lvgl::getLvglSyncLockable(), { CORE2_LCD_PIN_CS } ); - auto* sdcard = (SdCard*) new SpiSdCard( - std::unique_ptr(configuration) + auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( + std::unique_ptr(configuration) ); - return std::shared_ptr(sdcard); + return std::shared_ptr(sdcard); } diff --git a/Boards/M5stackCore2/Source/hal/Core2SdCard.h b/Boards/M5stackCore2/Source/hal/Core2SdCard.h index 940f7aa6..5cb65a73 100644 --- a/Boards/M5stackCore2/Source/hal/Core2SdCard.h +++ b/Boards/M5stackCore2/Source/hal/Core2SdCard.h @@ -1,7 +1,7 @@ #pragma once -#include +#include "Tactility/hal/sdcard/SdCardDevice.h" -using namespace tt::hal; +using tt::hal::sdcard::SdCardDevice; -std::shared_ptr createSdCard(); +std::shared_ptr createSdCard(); diff --git a/Boards/M5stackCore2/Source/hal/Core2Touch.h b/Boards/M5stackCore2/Source/hal/Core2Touch.h index 5aaf8349..1fb39365 100644 --- a/Boards/M5stackCore2/Source/hal/Core2Touch.h +++ b/Boards/M5stackCore2/Source/hal/Core2Touch.h @@ -1,10 +1,10 @@ #pragma once -#include -#include +#include "Tactility/hal/touch/TouchDevice.h" #include "ft6x36/FT6X36.h" +#include -class Core2Touch : public tt::hal::Touch { +class Core2Touch : public tt::hal::touch::TouchDevice { private: diff --git a/Boards/M5stackCoreS3/Source/hal/CoreS3Display.cpp b/Boards/M5stackCoreS3/Source/hal/CoreS3Display.cpp index 75f0d058..138947a1 100644 --- a/Boards/M5stackCoreS3/Source/hal/CoreS3Display.cpp +++ b/Boards/M5stackCoreS3/Source/hal/CoreS3Display.cpp @@ -10,7 +10,7 @@ #define TAG "cores3" -void setBacklightDuty(uint8_t backlightDuty) { +static void setBacklightDuty(uint8_t backlightDuty) { const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark // TODO: Refactor to use Axp2102 class with https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/AXP2101_Class.cpp#L42 if (!tt::hal::i2c::masterWriteRegister(I2C_NUM_0, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000)) { // Sets DLD01 @@ -18,7 +18,7 @@ void setBacklightDuty(uint8_t backlightDuty) { } } -std::shared_ptr createDisplay() { +std::shared_ptr createDisplay() { auto touch = std::make_shared(); auto configuration = std::make_unique( diff --git a/Boards/M5stackCoreS3/Source/hal/CoreS3Display.h b/Boards/M5stackCoreS3/Source/hal/CoreS3Display.h index 5469d3dc..5a0d81b3 100644 --- a/Boards/M5stackCoreS3/Source/hal/CoreS3Display.h +++ b/Boards/M5stackCoreS3/Source/hal/CoreS3Display.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "Tactility/hal/display/DisplayDevice.h" -std::shared_ptr createDisplay(); +std::shared_ptr createDisplay(); diff --git a/Boards/M5stackCoreS3/Source/hal/CoreS3Power.cpp b/Boards/M5stackCoreS3/Source/hal/CoreS3Power.cpp index 9b0ccf46..6b998aed 100644 --- a/Boards/M5stackCoreS3/Source/hal/CoreS3Power.cpp +++ b/Boards/M5stackCoreS3/Source/hal/CoreS3Power.cpp @@ -14,7 +14,7 @@ bool CoreS3Power::supportsMetric(MetricType type) const { return false; // Safety guard for when new enum values are introduced } -bool CoreS3Power::getMetric(Power::MetricType type, Power::MetricData& data) { +bool CoreS3Power::getMetric(MetricType type, MetricData& data) { switch (type) { using enum MetricType; case BatteryVoltage: { @@ -70,10 +70,10 @@ void CoreS3Power::setAllowedToCharge(bool canCharge) { axpDevice->setChargingEnabled(canCharge); } -static std::shared_ptr power; +static std::shared_ptr power; extern std::shared_ptr axp2101; -std::shared_ptr createPower() { +std::shared_ptr createPower() { if (power == nullptr) { power = std::make_shared(axp2101); } diff --git a/Boards/M5stackCoreS3/Source/hal/CoreS3Power.h b/Boards/M5stackCoreS3/Source/hal/CoreS3Power.h index 7820643d..4b889ac8 100644 --- a/Boards/M5stackCoreS3/Source/hal/CoreS3Power.h +++ b/Boards/M5stackCoreS3/Source/hal/CoreS3Power.h @@ -1,13 +1,13 @@ #pragma once +#include "Tactility/hal/power/PowerDevice.h" #include -#include #include #include -using namespace tt::hal; +using tt::hal::power::PowerDevice; -class CoreS3Power final : public Power { +class CoreS3Power final : public PowerDevice { std::shared_ptr axpDevice; @@ -20,11 +20,11 @@ public: std::string getDescription() const final { return "Power management via I2C"; } bool supportsMetric(MetricType type) const override; - bool getMetric(Power::MetricType type, Power::MetricData& data) override; + bool getMetric(MetricType type, MetricData& data) override; bool supportsChargeControl() const override { return true; } bool isAllowedToCharge() const override; void setAllowedToCharge(bool canCharge) override; }; -std::shared_ptr createPower(); +std::shared_ptr createPower(); diff --git a/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.cpp b/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.cpp index 5419417d..cca72682 100644 --- a/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.cpp +++ b/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.cpp @@ -1,20 +1,22 @@ #include "CoreS3SdCard.h" #include -#include +#include #include #define CORES3_SDCARD_PIN_CS GPIO_NUM_4 #define CORES3_LCD_PIN_CS GPIO_NUM_3 -std::shared_ptr createSdCard() { - auto* configuration = new tt::hal::SpiSdCard::Config( +using tt::hal::sdcard::SpiSdCardDevice; + +std::shared_ptr createSdCard() { + auto* configuration = new SpiSdCardDevice::Config( CORES3_SDCARD_PIN_CS, GPIO_NUM_NC, GPIO_NUM_NC, GPIO_NUM_NC, - SdCard::MountBehaviour::AtBoot, + SdCardDevice::MountBehaviour::AtBoot, tt::lvgl::getLvglSyncLockable(), { CORES3_LCD_PIN_CS @@ -22,9 +24,9 @@ std::shared_ptr createSdCard() { SPI3_HOST ); - auto* sdcard = (SdCard*) new SpiSdCard( - std::unique_ptr(configuration) + auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( + std::unique_ptr(configuration) ); - return std::shared_ptr(sdcard); + return std::shared_ptr(sdcard); } diff --git a/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.h b/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.h index 940f7aa6..5cb65a73 100644 --- a/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.h +++ b/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.h @@ -1,7 +1,7 @@ #pragma once -#include +#include "Tactility/hal/sdcard/SdCardDevice.h" -using namespace tt::hal; +using tt::hal::sdcard::SdCardDevice; -std::shared_ptr createSdCard(); +std::shared_ptr createSdCard(); diff --git a/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.h b/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.h index 91f8d05b..e50c0e49 100644 --- a/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.h +++ b/Boards/M5stackCoreS3/Source/hal/CoreS3Touch.h @@ -1,10 +1,10 @@ #pragma once -#include +#include "Tactility/hal/touch/TouchDevice.h" #include #include -class CoreS3Touch : public tt::hal::Touch { +class CoreS3Touch : public tt::hal::touch::TouchDevice { private: diff --git a/Boards/Simulator/Source/hal/SdlDisplay.h b/Boards/Simulator/Source/hal/SdlDisplay.h index bb522651..ab2aa805 100644 --- a/Boards/Simulator/Source/hal/SdlDisplay.h +++ b/Boards/Simulator/Source/hal/SdlDisplay.h @@ -1,13 +1,13 @@ #pragma once #include "SdlTouch.h" -#include +#include "Tactility/hal/display/DisplayDevice.h" #include /** Hack: variable comes from LvglTask.cpp */ extern lv_disp_t* displayHandle; -class SdlDisplay final : public tt::hal::Display { +class SdlDisplay final : public tt::hal::display::DisplayDevice { public: @@ -20,12 +20,12 @@ public: bool stop() override { tt_crash("Not supported"); } - std::shared_ptr _Nullable createTouch() override { return std::make_shared(); } + std::shared_ptr _Nullable createTouch() override { return std::make_shared(); } lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; } }; -std::shared_ptr createDisplay() { +std::shared_ptr createDisplay() { return std::make_shared(); } diff --git a/Boards/Simulator/Source/hal/SdlKeyboard.h b/Boards/Simulator/Source/hal/SdlKeyboard.h index 640a8c2d..f9730286 100644 --- a/Boards/Simulator/Source/hal/SdlKeyboard.h +++ b/Boards/Simulator/Source/hal/SdlKeyboard.h @@ -1,9 +1,9 @@ #pragma once -#include +#include #include -class SdlKeyboard final : public tt::hal::Keyboard { +class SdlKeyboard final : public tt::hal::keyboard::KeyboardDevice { private: lv_indev_t* _Nullable handle = nullptr; @@ -24,6 +24,6 @@ public: lv_indev_t* _Nullable getLvglIndev() override { return handle; } }; -std::shared_ptr createKeyboard() { +std::shared_ptr createKeyboard() { return std::make_shared(); } diff --git a/Boards/Simulator/Source/hal/SdlTouch.h b/Boards/Simulator/Source/hal/SdlTouch.h index 265cac69..613742d6 100644 --- a/Boards/Simulator/Source/hal/SdlTouch.h +++ b/Boards/Simulator/Source/hal/SdlTouch.h @@ -1,9 +1,9 @@ #pragma once -#include +#include "Tactility/hal/touch/TouchDevice.h" #include -class SdlTouch final : public tt::hal::Touch { +class SdlTouch final : public tt::hal::touch::TouchDevice { private: lv_indev_t* _Nullable handle = nullptr; diff --git a/Boards/Simulator/Source/hal/SimulatorPower.cpp b/Boards/Simulator/Source/hal/SimulatorPower.cpp index 642257f8..593cbe61 100644 --- a/Boards/Simulator/Source/hal/SimulatorPower.cpp +++ b/Boards/Simulator/Source/hal/SimulatorPower.cpp @@ -15,7 +15,7 @@ bool SimulatorPower::supportsMetric(MetricType type) const { return false; // Safety guard for when new enum values are introduced } -bool SimulatorPower::getMetric(Power::MetricType type, Power::MetricData& data) { +bool SimulatorPower::getMetric(MetricType type, MetricData& data) { switch (type) { using enum MetricType; case IsCharging: @@ -35,9 +35,9 @@ bool SimulatorPower::getMetric(Power::MetricType type, Power::MetricData& data) return false; // Safety guard for when new enum values are introduced } -static std::shared_ptr power; +static std::shared_ptr power; -std::shared_ptr simulatorPower() { +std::shared_ptr simulatorPower() { if (power == nullptr) { power = std::make_shared(); } diff --git a/Boards/Simulator/Source/hal/SimulatorPower.h b/Boards/Simulator/Source/hal/SimulatorPower.h index 5d7ca8fe..b4949502 100644 --- a/Boards/Simulator/Source/hal/SimulatorPower.h +++ b/Boards/Simulator/Source/hal/SimulatorPower.h @@ -1,11 +1,11 @@ #pragma once -#include +#include "Tactility/hal/power/PowerDevice.h" #include -using namespace tt::hal; +using tt::hal::power::PowerDevice; -class SimulatorPower final : public Power { +class SimulatorPower final : public PowerDevice { bool allowedToCharge = false; @@ -18,11 +18,11 @@ public: std::string getDescription() const final { return ""; } bool supportsMetric(MetricType type) const override; - bool getMetric(Power::MetricType type, Power::MetricData& data) override; + bool getMetric(MetricType type, MetricData& data) override; bool supportsChargeControl() const override { return true; } bool isAllowedToCharge() const override { return allowedToCharge; } void setAllowedToCharge(bool canCharge) override { allowedToCharge = canCharge; } }; -std::shared_ptr simulatorPower(); +std::shared_ptr simulatorPower(); diff --git a/Boards/Simulator/Source/hal/SimulatorSdCard.h b/Boards/Simulator/Source/hal/SimulatorSdCard.h index e9940806..528aecf0 100644 --- a/Boards/Simulator/Source/hal/SimulatorSdCard.h +++ b/Boards/Simulator/Source/hal/SimulatorSdCard.h @@ -1,12 +1,12 @@ #pragma once -#include +#include "Tactility/hal/sdcard/SdCardDevice.h" #include #include -using namespace tt::hal; +using tt::hal::sdcard::SdCardDevice; -class SimulatorSdCard final : public SdCard { +class SimulatorSdCard final : public SdCardDevice { private: @@ -16,7 +16,7 @@ private: public: - SimulatorSdCard() : SdCard(MountBehaviour::AtBoot), + SimulatorSdCard() : SdCardDevice(MountBehaviour::AtBoot), state(State::Unmounted), lockable(std::make_shared()) {} diff --git a/Boards/UnPhone/Source/hal/UnPhoneDisplay.cpp b/Boards/UnPhone/Source/hal/UnPhoneDisplay.cpp index d1c078a9..de4ade53 100644 --- a/Boards/UnPhone/Source/hal/UnPhoneDisplay.cpp +++ b/Boards/UnPhone/Source/hal/UnPhoneDisplay.cpp @@ -63,10 +63,10 @@ bool UnPhoneDisplay::stop() { return true; } -std::shared_ptr _Nullable UnPhoneDisplay::createTouch() { +std::shared_ptr _Nullable UnPhoneDisplay::createTouch() { return std::make_shared(); } -std::shared_ptr createDisplay() { +std::shared_ptr createDisplay() { return std::make_shared(); } diff --git a/Boards/UnPhone/Source/hal/UnPhoneDisplay.h b/Boards/UnPhone/Source/hal/UnPhoneDisplay.h index 079adbd9..134969e4 100644 --- a/Boards/UnPhone/Source/hal/UnPhoneDisplay.h +++ b/Boards/UnPhone/Source/hal/UnPhoneDisplay.h @@ -1,10 +1,10 @@ #pragma once +#include "Tactility/hal/display/DisplayDevice.h" #include #include -#include -class UnPhoneDisplay : public tt::hal::Display { +class UnPhoneDisplay : public tt::hal::display::DisplayDevice { private: @@ -20,9 +20,9 @@ public: bool stop() override; - std::shared_ptr _Nullable createTouch() override; + std::shared_ptr _Nullable createTouch() override; lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; } }; -std::shared_ptr createDisplay(); +std::shared_ptr createDisplay(); diff --git a/Boards/UnPhone/Source/hal/UnPhonePower.cpp b/Boards/UnPhone/Source/hal/UnPhonePower.cpp index 87beb949..afa0538b 100644 --- a/Boards/UnPhone/Source/hal/UnPhonePower.cpp +++ b/Boards/UnPhone/Source/hal/UnPhonePower.cpp @@ -27,7 +27,7 @@ bool UnPhonePower::supportsMetric(MetricType type) const { } } -bool UnPhonePower::getMetric(Power::MetricType type, Power::MetricData& data) { +bool UnPhonePower::getMetric(MetricType type, MetricData& data) { switch (type) { using enum MetricType; case BatteryVoltage: @@ -83,9 +83,9 @@ bool UnPhonePower::readBatteryVoltageSampled(uint32_t& output) const { } } -static std::shared_ptr power; +static std::shared_ptr power; -std::shared_ptr unPhoneGetPower() { +std::shared_ptr unPhoneGetPower() { if (power == nullptr) { power = std::make_shared(); } diff --git a/Boards/UnPhone/Source/hal/UnPhonePower.h b/Boards/UnPhone/Source/hal/UnPhonePower.h index 84ac56cc..649243c2 100644 --- a/Boards/UnPhone/Source/hal/UnPhonePower.h +++ b/Boards/UnPhone/Source/hal/UnPhonePower.h @@ -1,11 +1,11 @@ #pragma once -#include +#include "Tactility/hal/power/PowerDevice.h" #include -using namespace tt::hal; +using tt::hal::power::PowerDevice; -class UnPhonePower : public Power { +class UnPhonePower : public PowerDevice { public: @@ -16,7 +16,7 @@ public: std::string getDescription() const final { return "Power interface via XPT2046 voltage measurement"; } bool supportsMetric(MetricType type) const override; - bool getMetric(Power::MetricType type, Power::MetricData& data) override; + bool getMetric(MetricType type, MetricData& data) override; private: @@ -24,4 +24,4 @@ private: bool readBatteryVoltageSampled(uint32_t& output) const; }; -std::shared_ptr unPhoneGetPower(); +std::shared_ptr unPhoneGetPower(); diff --git a/Boards/UnPhone/Source/hal/UnPhoneSdCard.cpp b/Boards/UnPhone/Source/hal/UnPhoneSdCard.cpp index 176d61ab..47dc57d5 100644 --- a/Boards/UnPhone/Source/hal/UnPhoneSdCard.cpp +++ b/Boards/UnPhone/Source/hal/UnPhoneSdCard.cpp @@ -1,7 +1,7 @@ #include "UnPhoneSdCard.h" #include -#include +#include #include @@ -10,13 +10,15 @@ #define UNPHONE_LORA_PIN_CS GPIO_NUM_44 #define UNPHONE_TOUCH_PIN_CS GPIO_NUM_38 -std::shared_ptr createUnPhoneSdCard() { - auto* configuration = new tt::hal::SpiSdCard::Config( +using tt::hal::sdcard::SpiSdCardDevice; + +std::shared_ptr createUnPhoneSdCard() { + auto* configuration = new SpiSdCardDevice::Config( UNPHONE_SDCARD_PIN_CS, GPIO_NUM_NC, GPIO_NUM_NC, GPIO_NUM_NC, - SdCard::MountBehaviour::AtBoot, + SdCardDevice::MountBehaviour::AtBoot, tt::lvgl::getLvglSyncLockable(), { UNPHONE_LORA_PIN_CS, @@ -25,9 +27,9 @@ std::shared_ptr createUnPhoneSdCard() { } ); - auto* sdcard = (SdCard*) new SpiSdCard( - std::unique_ptr(configuration) + auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( + std::unique_ptr(configuration) ); - return std::shared_ptr(sdcard); + return std::shared_ptr(sdcard); } diff --git a/Boards/UnPhone/Source/hal/UnPhoneSdCard.h b/Boards/UnPhone/Source/hal/UnPhoneSdCard.h index 0d9e410e..2ac34751 100644 --- a/Boards/UnPhone/Source/hal/UnPhoneSdCard.h +++ b/Boards/UnPhone/Source/hal/UnPhoneSdCard.h @@ -1,7 +1,7 @@ #pragma once -#include +#include "Tactility/hal/sdcard/SdCardDevice.h" -using namespace tt::hal; +using tt::hal::sdcard::SdCardDevice; -std::shared_ptr createUnPhoneSdCard(); +std::shared_ptr createUnPhoneSdCard(); diff --git a/Boards/UnPhone/Source/hal/UnPhoneTouch.h b/Boards/UnPhone/Source/hal/UnPhoneTouch.h index 358af212..526ed92f 100644 --- a/Boards/UnPhone/Source/hal/UnPhoneTouch.h +++ b/Boards/UnPhone/Source/hal/UnPhoneTouch.h @@ -1,11 +1,11 @@ #pragma once -#include +#include "Tactility/hal/touch/TouchDevice.h" #include #include #include -class UnPhoneTouch : public tt::hal::Touch { +class UnPhoneTouch : public tt::hal::touch::TouchDevice { private: diff --git a/Drivers/ILI934x/Source/Ili934xDisplay.h b/Drivers/ILI934x/Source/Ili934xDisplay.h index 7a87d3eb..670eb6cf 100644 --- a/Drivers/ILI934x/Source/Ili934xDisplay.h +++ b/Drivers/ILI934x/Source/Ili934xDisplay.h @@ -1,6 +1,6 @@ #pragma once -#include +#include "Tactility/hal/display/DisplayDevice.h" #include #include @@ -9,7 +9,7 @@ #include #include -class Ili934xDisplay final : public tt::hal::Display { +class Ili934xDisplay final : public tt::hal::display::DisplayDevice { public: @@ -23,7 +23,7 @@ public: gpio_num_t dcPin, unsigned int horizontalResolution, unsigned int verticalResolution, - std::shared_ptr touch + std::shared_ptr touch ) : spiBusHandle(spi_bus_handle), csPin(csPin), dcPin(dcPin), @@ -44,7 +44,7 @@ public: bool mirrorY = false; bool invertColor = true; uint32_t bufferSize = 0; // Size in pixel count. 0 means default, which is 1/10 of the screen size - std::shared_ptr touch; + std::shared_ptr touch; std::function _Nullable backlightDutyFunction = nullptr; }; @@ -68,7 +68,7 @@ public: bool stop() final; - std::shared_ptr _Nullable createTouch() final { return configuration->touch; } + std::shared_ptr _Nullable createTouch() final { return configuration->touch; } void setBacklightDuty(uint8_t backlightDuty) final { if (configuration->backlightDutyFunction != nullptr) { @@ -84,4 +84,4 @@ public: lv_display_t* _Nullable getLvglDisplay() const final { return displayHandle; } }; -std::shared_ptr createDisplay(); +std::shared_ptr createDisplay(); diff --git a/Tactility/Source/app/ElfApp.cpp b/Tactility/Source/app/ElfApp.cpp index e6c20a20..7f75e709 100644 --- a/Tactility/Source/app/ElfApp.cpp +++ b/Tactility/Source/app/ElfApp.cpp @@ -4,9 +4,9 @@ #include "Tactility/file/File.h" #include "Tactility/service/loader/Loader.h" +#include "Tactility/hal/sdcard/SdCardDevice.h" #include #include -#include #include "esp_elf.h" @@ -50,7 +50,7 @@ private: assert(elfFileData == nullptr); size_t size = 0; - hal::withSdCardLock(filePath, [this, &size](){ + hal::sdcard::withSdCardLock(filePath, [this, &size](){ elfFileData = file::readBinary(filePath, size); }); diff --git a/Tactility/Source/app/boot/Boot.cpp b/Tactility/Source/app/boot/Boot.cpp index ecbac91d..e77aa6b1 100644 --- a/Tactility/Source/app/boot/Boot.cpp +++ b/Tactility/Source/app/boot/Boot.cpp @@ -5,8 +5,8 @@ #include "Tactility/service/loader/Loader.h" #include "Tactility/lvgl/Style.h" +#include "Tactility/hal/display/DisplayDevice.h" #include -#include #include #include @@ -24,8 +24,8 @@ namespace tt::app::boot { -static std::shared_ptr getHalDisplay() { - return hal::findFirstDevice(hal::Device::Type::Display); +static std::shared_ptr getHalDisplay() { + return hal::findFirstDevice(hal::Device::Type::Display); } class BootApp : public App { @@ -57,7 +57,6 @@ private: TickType_t ticks_passed = end_time - start_time; TickType_t minimum_ticks = (CONFIG_TT_SPLASH_DURATION / portTICK_PERIOD_MS); if (minimum_ticks > ticks_passed) { - TT_LOG_I(TAG, "Remaining delay: %lu", minimum_ticks - ticks_passed); kernel::delayTicks(minimum_ticks - ticks_passed); } diff --git a/Tactility/Source/app/display/Display.cpp b/Tactility/Source/app/display/Display.cpp index 9094edf3..c9299b3f 100644 --- a/Tactility/Source/app/display/Display.cpp +++ b/Tactility/Source/app/display/Display.cpp @@ -1,6 +1,6 @@ #include "Tactility/app/display/DisplaySettings.h" -#include "Tactility/hal/Display.h" +#include "Tactility/hal/display/DisplayDevice.h" #include "Tactility/lvgl/Toolbar.h" #include @@ -22,8 +22,8 @@ static uint8_t gamma = 255; #define ROTATION_270 2 #define ROTATION_90 3 -static std::shared_ptr getHalDisplay() { - return hal::findFirstDevice(hal::Device::Type::Display); +static std::shared_ptr getHalDisplay() { + return hal::findFirstDevice(hal::Device::Type::Display); } static void onBacklightSliderEvent(lv_event_t* event) { @@ -46,7 +46,7 @@ static void onGammaSliderEvent(lv_event_t* event) { auto* slider = static_cast(lv_event_get_target(event)); auto* lvgl_display = lv_display_get_default(); assert(lvgl_display != nullptr); - auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display); + auto* hal_display = (tt::hal::display::DisplayDevice*)lv_display_get_user_data(lvgl_display); assert(hal_display != nullptr); if (hal_display->getGammaCurveCount() > 0) { diff --git a/Tactility/Source/app/files/State.cpp b/Tactility/Source/app/files/State.cpp index cd924b2a..58fb6d0a 100644 --- a/Tactility/Source/app/files/State.cpp +++ b/Tactility/Source/app/files/State.cpp @@ -1,9 +1,9 @@ #include "Tactility/app/files/State.h" #include "Tactility/app/files/FileUtils.h" +#include "Tactility/hal/sdcard/SdCardDevice.h" #include #include -#include #include #include @@ -59,10 +59,10 @@ bool State::setEntriesForPath(const std::string& path) { .d_name = DATA_PARTITION_NAME }); - auto sdcards = tt::hal::findDevices(hal::Device::Type::SdCard); + auto sdcards = tt::hal::findDevices(hal::Device::Type::SdCard); for (auto& sdcard : sdcards) { auto state = sdcard->getState(); - if (state == hal::SdCard::State::Mounted) { + if (state == hal::sdcard::SdCardDevice::State::Mounted) { auto mount_name = sdcard->getMountPath().substr(1); auto dir_entry = dirent { .d_ino = 2, diff --git a/Tactility/Source/app/power/Power.cpp b/Tactility/Source/app/power/Power.cpp index a99b4a15..b5d69663 100644 --- a/Tactility/Source/app/power/Power.cpp +++ b/Tactility/Source/app/power/Power.cpp @@ -4,10 +4,10 @@ #include "Tactility/lvgl/Toolbar.h" #include "Tactility/service/loader/Loader.h" -#include -#include +#include "Tactility/hal/power/PowerDevice.h" #include #include +#include #include @@ -35,7 +35,7 @@ private: Timer update_timer = Timer(Timer::Type::Periodic, &onTimer, nullptr); - std::shared_ptr power; + std::shared_ptr power; lv_obj_t* enableLabel = nullptr; lv_obj_t* enableSwitch = nullptr; @@ -71,8 +71,8 @@ private: void updateUi() { const char* charge_state; - hal::Power::MetricData metric_data; - if (power->getMetric(hal::Power::MetricType::IsCharging, metric_data)) { + hal::power::PowerDevice::MetricData metric_data; + if (power->getMetric(hal::power::PowerDevice::MetricType::IsCharging, metric_data)) { charge_state = metric_data.valueAsBool ? "yes" : "no"; } else { charge_state = "N/A"; @@ -80,7 +80,7 @@ private: uint8_t charge_level; bool charge_level_scaled_set = false; - if (power->getMetric(hal::Power::MetricType::ChargeLevel, metric_data)) { + if (power->getMetric(hal::power::PowerDevice::MetricType::ChargeLevel, metric_data)) { charge_level = metric_data.valueAsUint8; charge_level_scaled_set = true; } @@ -90,14 +90,14 @@ private: int32_t current; bool current_set = false; - if (power->getMetric(hal::Power::MetricType::Current, metric_data)) { + if (power->getMetric(hal::power::PowerDevice::MetricType::Current, metric_data)) { current = metric_data.valueAsInt32; current_set = true; } uint32_t battery_voltage; bool battery_voltage_set = false; - if (power->getMetric(hal::Power::MetricType::BatteryVoltage, metric_data)) { + if (power->getMetric(hal::power::PowerDevice::MetricType::BatteryVoltage, metric_data)) { battery_voltage = metric_data.valueAsUint32; battery_voltage_set = true; } @@ -139,7 +139,7 @@ private: public: void onCreate(AppContext& app) override { - power = hal::findFirstDevice(hal::Device::Type::Power); + power = hal::findFirstDevice(hal::Device::Type::Power); } void onShow(AppContext& app, lv_obj_t* parent) override { diff --git a/Tactility/Source/app/screenshot/Screenshot.cpp b/Tactility/Source/app/screenshot/Screenshot.cpp index 382c0b72..61780a43 100644 --- a/Tactility/Source/app/screenshot/Screenshot.cpp +++ b/Tactility/Source/app/screenshot/Screenshot.cpp @@ -205,9 +205,13 @@ void ScreenshotApp::createFilePathWidgets(lv_obj_t* parent) { lv_textarea_set_one_line(pathTextArea, true); lv_obj_set_flex_grow(pathTextArea, 1); if (kernel::getPlatform() == kernel::PlatformEsp) { - auto sdcard = tt::hal::getConfiguration()->sdcard; - if (sdcard != nullptr && sdcard->getState() == hal::SdCard::State::Mounted) { - lv_textarea_set_text(pathTextArea, "A:/sdcard"); + auto sdcard_devices = tt::hal::findDevices(tt::hal::Device::Type::SdCard); + if (sdcard_devices.size() > 1) { + TT_LOG_W(TAG, "Found multiple SD card devices - picking first"); + } + if (!sdcard_devices.empty() && sdcard_devices.front()->isMounted()) { + std::string lvgl_mount_path = "A:" + sdcard_devices.front()->getMountPath(); + lv_textarea_set_text(pathTextArea, lvgl_mount_path.c_str()); } else { lv_textarea_set_text(pathTextArea, "Error: no SD card"); } diff --git a/Tactility/Source/lvgl/Init.cpp b/Tactility/Source/lvgl/Init.cpp index 81183a5b..7da432c5 100644 --- a/Tactility/Source/lvgl/Init.cpp +++ b/Tactility/Source/lvgl/Init.cpp @@ -1,10 +1,10 @@ #include "Tactility/app/display/DisplaySettings.h" #include "Tactility/lvgl/LvglKeypad.h" +#include "Tactility/hal/display/DisplayDevice.h" +#include "Tactility/hal/touch/TouchDevice.h" #include -#include -#include -#include +#include #include #ifdef ESP_PLATFORM @@ -17,7 +17,7 @@ namespace tt::lvgl { #define TAG "lvgl_init" -static std::shared_ptr initDisplay(const hal::Configuration& config) { +static std::shared_ptr initDisplay(const hal::Configuration& config) { assert(config.createDisplay); auto display = config.createDisplay(); assert(display != nullptr); @@ -48,7 +48,7 @@ static std::shared_ptr initDisplay(const hal::Configuration& c return display; } -static bool initTouch(const std::shared_ptr& display, const std::shared_ptr& touch) { +static bool initTouch(const std::shared_ptr& display, const std::shared_ptr& touch) { TT_LOG_I(TAG, "Touch init"); assert(display); assert(touch); @@ -60,7 +60,7 @@ static bool initTouch(const std::shared_ptr& display, const std::s } } -static bool initKeyboard(const std::shared_ptr& display, const std::shared_ptr& keyboard) { +static bool initKeyboard(const std::shared_ptr& display, const std::shared_ptr& keyboard) { TT_LOG_I(TAG, "Keyboard init"); assert(display); assert(keyboard); diff --git a/Tactility/Source/service/statusbar/Statusbar.cpp b/Tactility/Source/service/statusbar/Statusbar.cpp index a49cbe42..8161371a 100644 --- a/Tactility/Source/service/statusbar/Statusbar.cpp +++ b/Tactility/Source/service/statusbar/Statusbar.cpp @@ -1,15 +1,15 @@ #include "Tactility/lvgl/Statusbar.h" #include "Tactility/lvgl/LvglSync.h" +#include "Tactility/hal/power/PowerDevice.h" +#include "Tactility/hal/sdcard/SdCardDevice.h" #include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include namespace tt::service::statusbar { @@ -70,9 +70,9 @@ static const char* getWifiStatusIcon(wifi::RadioState state, bool secure) { } } -static const char* getSdCardStatusIcon(hal::SdCard::State state) { +static const char* getSdCardStatusIcon(hal::sdcard::SdCardDevice::State state) { switch (state) { - using enum hal::SdCard::State; + using enum hal::sdcard::SdCardDevice::State; case Mounted: return STATUSBAR_ICON_SDCARD; case Error: @@ -92,8 +92,8 @@ static _Nullable const char* getPowerStatusIcon() { auto power = get_power(); - hal::Power::MetricData charge_level; - if (!power->getMetric(hal::Power::MetricType::ChargeLevel, charge_level)) { + hal::power::PowerDevice::MetricData charge_level; + if (!power->getMetric(hal::power::PowerDevice::MetricType::ChargeLevel, charge_level)) { return nullptr; } @@ -181,7 +181,7 @@ private: auto sdcard = tt::hal::getConfiguration()->sdcard; if (sdcard != nullptr) { auto state = sdcard->getState(); - if (state != hal::SdCard::State::Unknown) { + if (state != hal::sdcard::SdCardDevice::State::Unknown) { auto* desired_icon = getSdCardStatusIcon(state); if (sdcard_last_icon != desired_icon) { auto icon_path = paths->getSystemPathLvgl(desired_icon); diff --git a/TactilityHeadless/Include/Tactility/hal/Configuration.h b/TactilityHeadless/Include/Tactility/hal/Configuration.h index d2da35ed..05dc8d62 100644 --- a/TactilityHeadless/Include/Tactility/hal/Configuration.h +++ b/TactilityHeadless/Include/Tactility/hal/Configuration.h @@ -1,20 +1,21 @@ #pragma once -#include "./SdCard.h" -#include "./i2c/I2c.h" +#include "Tactility/hal/sdcard/SdCardDevice.h" #include "Tactility/hal/spi/Spi.h" #include "Tactility/hal/uart/Uart.h" +#include "i2c/I2c.h" namespace tt::hal { typedef bool (*InitBoot)(); -class Display; -class Keyboard; -class Power; -typedef std::shared_ptr (*CreateDisplay)(); -typedef std::shared_ptr (*CreateKeyboard)(); -typedef std::shared_ptr (*CreatePower)(); +namespace display { class DisplayDevice; } +namespace keyboard { class KeyboardDevice; } +namespace power { class PowerDevice; } + +typedef std::shared_ptr (*CreateDisplay)(); +typedef std::shared_ptr (*CreateKeyboard)(); +typedef std::shared_ptr (*CreatePower)(); enum class LvglInit { Default, @@ -38,7 +39,7 @@ struct Configuration { const CreateKeyboard _Nullable createKeyboard = nullptr; /** An optional SD card interface. */ - const std::shared_ptr _Nullable sdcard = nullptr; + const std::shared_ptr _Nullable sdcard = nullptr; /** An optional power interface for battery or other power delivery. */ const CreatePower _Nullable power = nullptr; diff --git a/TactilityHeadless/Include/Tactility/hal/Display.h b/TactilityHeadless/Include/Tactility/hal/display/DisplayDevice.h similarity index 78% rename from TactilityHeadless/Include/Tactility/hal/Display.h rename to TactilityHeadless/Include/Tactility/hal/display/DisplayDevice.h index bf12b69c..ea3080fa 100644 --- a/TactilityHeadless/Include/Tactility/hal/Display.h +++ b/TactilityHeadless/Include/Tactility/hal/display/DisplayDevice.h @@ -1,14 +1,16 @@ #pragma once -#include "Device.h" +#include "../Device.h" #include -namespace tt::hal { +namespace tt::hal::touch { +class TouchDevice; +} -class Touch; +namespace tt::hal::display { -class Display : public Device { +class DisplayDevice : public Device { public: @@ -21,7 +23,7 @@ public: virtual bool isPoweredOn() const { return true; } virtual bool supportsPowerControl() const { return false; } - virtual std::shared_ptr _Nullable createTouch() = 0; + virtual std::shared_ptr _Nullable createTouch() = 0; /** Set a value in the range [0, 255] */ virtual void setBacklightDuty(uint8_t backlightDuty) { /* NO-OP */ } @@ -35,4 +37,4 @@ public: virtual lv_display_t* _Nullable getLvglDisplay() const = 0; }; -} +} // namespace tt::hal::display diff --git a/TactilityHeadless/Include/Tactility/hal/Keyboard.h b/TactilityHeadless/Include/Tactility/hal/keyboard/KeyboardDevice.h similarity index 76% rename from TactilityHeadless/Include/Tactility/hal/Keyboard.h rename to TactilityHeadless/Include/Tactility/hal/keyboard/KeyboardDevice.h index 372a14d4..1aa618c8 100644 --- a/TactilityHeadless/Include/Tactility/hal/Keyboard.h +++ b/TactilityHeadless/Include/Tactility/hal/keyboard/KeyboardDevice.h @@ -1,14 +1,14 @@ #pragma once -#include "Device.h" +#include "../Device.h" #include -namespace tt::hal { +namespace tt::hal::keyboard { class Display; -class Keyboard : public Device { +class KeyboardDevice : public Device { public: diff --git a/TactilityHeadless/Include/Tactility/hal/Power.h b/TactilityHeadless/Include/Tactility/hal/power/PowerDevice.h similarity index 80% rename from TactilityHeadless/Include/Tactility/hal/Power.h rename to TactilityHeadless/Include/Tactility/hal/power/PowerDevice.h index c0ab590b..2525289d 100644 --- a/TactilityHeadless/Include/Tactility/hal/Power.h +++ b/TactilityHeadless/Include/Tactility/hal/power/PowerDevice.h @@ -1,16 +1,16 @@ #pragma once -#include "Device.h" +#include "../Device.h" #include -namespace tt::hal { +namespace tt::hal::power { -class Power : public Device { +class PowerDevice : public Device { public: - Power() = default; - ~Power() override = default; + PowerDevice() = default; + ~PowerDevice() override = default; Type getType() const override { return Type::Power; } @@ -34,7 +34,7 @@ public: /** * @return false when metric is not supported or (temporarily) not available. */ - virtual bool getMetric(Power::MetricType type, MetricData& data) = 0; + virtual bool getMetric(MetricType type, MetricData& data) = 0; virtual bool supportsChargeControl() const { return false; } virtual bool isAllowedToCharge() const { return false; } diff --git a/TactilityHeadless/Include/Tactility/hal/SdCard.h b/TactilityHeadless/Include/Tactility/hal/sdcard/SdCardDevice.h similarity index 82% rename from TactilityHeadless/Include/Tactility/hal/SdCard.h rename to TactilityHeadless/Include/Tactility/hal/sdcard/SdCardDevice.h index 3a027683..065119fa 100644 --- a/TactilityHeadless/Include/Tactility/hal/SdCard.h +++ b/TactilityHeadless/Include/Tactility/hal/sdcard/SdCardDevice.h @@ -1,12 +1,12 @@ #pragma once -#include "Device.h" +#include "../Device.h" #include -namespace tt::hal { +namespace tt::hal::sdcard { -class SdCard : public Device { +class SdCardDevice : public Device { public: @@ -28,8 +28,8 @@ private: public: - explicit SdCard(MountBehaviour mountBehaviour) : mountBehaviour(mountBehaviour) {} - virtual ~SdCard() override = default; + explicit SdCardDevice(MountBehaviour mountBehaviour) : mountBehaviour(mountBehaviour) {} + virtual ~SdCardDevice() override = default; Type getType() const final { return Type::SdCard; }; @@ -46,7 +46,7 @@ public: }; /** Return the SdCard device if the path is within the SdCard mounted path (path std::string::starts_with() check)*/ -std::shared_ptr _Nullable findSdCard(const std::string& path); +std::shared_ptr _Nullable find(const std::string& path); /** * Acquires an SD card lock if the path is an SD card path. @@ -54,7 +54,7 @@ std::shared_ptr _Nullable findSdCard(const std::string& path); */ template inline ReturnType withSdCardLock(const std::string& path, std::function fn) { - auto sdcard = hal::findSdCard(path); + auto sdcard = find(path); std::unique_ptr scoped_lockable; if (sdcard != nullptr) { scoped_lockable = sdcard->getLockable()->scoped(); diff --git a/TactilityHeadless/Include/Tactility/hal/SpiSdCard.h b/TactilityHeadless/Include/Tactility/hal/sdcard/SpiSdCardDevice.h similarity index 89% rename from TactilityHeadless/Include/Tactility/hal/SpiSdCard.h rename to TactilityHeadless/Include/Tactility/hal/sdcard/SpiSdCardDevice.h index 2b8bf624..64fd612c 100644 --- a/TactilityHeadless/Include/Tactility/hal/SpiSdCard.h +++ b/TactilityHeadless/Include/Tactility/hal/sdcard/SpiSdCardDevice.h @@ -2,7 +2,7 @@ #pragma once -#include "Tactility/hal/SdCard.h" +#include "SdCardDevice.h" #include #include @@ -10,13 +10,15 @@ #include #include -namespace tt::hal { +namespace tt::hal::sdcard { /** * SD card interface at the default SPI interface */ -class SpiSdCard final : public tt::hal::SdCard { +class SpiSdCardDevice final : public SdCardDevice { + public: + struct Config { Config( gpio_num_t spiPinCs, @@ -46,7 +48,7 @@ public: gpio_num_t spiPinCd; // Card detect gpio_num_t spiPinWp; // Write-protect gpio_num_t spiPinInt; // Interrupt - SdCard::MountBehaviour mountBehaviourAtBoot; + SdCardDevice::MountBehaviour mountBehaviourAtBoot; std::shared_ptr _Nullable lockable; std::vector csPinWorkAround; spi_host_device_t spiHost; @@ -67,8 +69,7 @@ private: public: - explicit SpiSdCard(std::unique_ptr config) : - SdCard(config->mountBehaviourAtBoot), + explicit SpiSdCardDevice(std::unique_ptr config) : SdCardDevice(config->mountBehaviourAtBoot), config(std::move(config)) {} diff --git a/TactilityHeadless/Include/Tactility/hal/Touch.h b/TactilityHeadless/Include/Tactility/hal/touch/TouchDevice.h similarity index 75% rename from TactilityHeadless/Include/Tactility/hal/Touch.h rename to TactilityHeadless/Include/Tactility/hal/touch/TouchDevice.h index 2677f36b..f1cc0748 100644 --- a/TactilityHeadless/Include/Tactility/hal/Touch.h +++ b/TactilityHeadless/Include/Tactility/hal/touch/TouchDevice.h @@ -1,14 +1,14 @@ #pragma once -#include "Device.h" +#include "../Device.h" #include -namespace tt::hal { +namespace tt::hal::touch { class Display; -class Touch : public Device { +class TouchDevice : public Device { public: diff --git a/TactilityHeadless/Source/hal/Hal.cpp b/TactilityHeadless/Source/hal/Hal.cpp index 12585be2..c4a7d143 100644 --- a/TactilityHeadless/Source/hal/Hal.cpp +++ b/TactilityHeadless/Source/hal/Hal.cpp @@ -1,9 +1,9 @@ #include "Tactility/hal/Configuration.h" #include "Tactility/hal/Device.h" #include "Tactility/hal/i2c/I2c.h" +#include "Tactility/hal/power/PowerDevice.h" #include "Tactility/hal/spi/Spi.h" #include "Tactility/hal/uart/Uart.h" -#include "Tactility/hal/Power.h" #include @@ -42,7 +42,7 @@ void init(const Configuration& configuration) { } if (configuration.power != nullptr) { - std::shared_ptr power = configuration.power(); + std::shared_ptr power = configuration.power(); hal::registerDevice(power); } diff --git a/TactilityHeadless/Source/hal/SdCard.cpp b/TactilityHeadless/Source/hal/sdcard/SdCard.cpp similarity index 52% rename from TactilityHeadless/Source/hal/SdCard.cpp rename to TactilityHeadless/Source/hal/sdcard/SdCard.cpp index 3542f99e..9cce5391 100644 --- a/TactilityHeadless/Source/hal/SdCard.cpp +++ b/TactilityHeadless/Source/hal/sdcard/SdCard.cpp @@ -1,10 +1,10 @@ -#include "Tactility/hal/SdCard.h" #include "Tactility/hal/Device.h" +#include "Tactility/hal/sdcard/SdCardDevice.h" -namespace tt::hal { +namespace tt::hal::sdcard { -std::shared_ptr _Nullable findSdCard(const std::string& path) { - auto sdcards = findDevices(Device::Type::SdCard); +std::shared_ptr _Nullable find(const std::string& path) { + auto sdcards = findDevices(Device::Type::SdCard); for (auto& sdcard : sdcards) { if (sdcard->isMounted() && path.starts_with(sdcard->getMountPath())) { return sdcard; diff --git a/TactilityHeadless/Source/hal/SpiSdCard.cpp b/TactilityHeadless/Source/hal/sdcard/SpiSdCard.cpp similarity index 92% rename from TactilityHeadless/Source/hal/SpiSdCard.cpp rename to TactilityHeadless/Source/hal/sdcard/SpiSdCard.cpp index 5385993c..97b16363 100644 --- a/TactilityHeadless/Source/hal/SpiSdCard.cpp +++ b/TactilityHeadless/Source/hal/sdcard/SpiSdCard.cpp @@ -1,6 +1,6 @@ #ifdef ESP_PLATFORM -#include "Tactility/hal/SpiSdCard.h" +#include "Tactility/hal/sdcard/SpiSdCardDevice.h" #include @@ -10,7 +10,7 @@ #define TAG "spi_sdcard" -namespace tt::hal { +namespace tt::hal::sdcard { /** * Before we can initialize the sdcard's SPI communications, we have to set all @@ -19,7 +19,7 @@ namespace tt::hal { * See https://github.com/Xinyuan-LilyGO/T-Deck/blob/master/examples/UnitTest/UnitTest.ino * @return success result */ -bool SpiSdCard::applyGpioWorkAround() { +bool SpiSdCardDevice::applyGpioWorkAround() { TT_LOG_D(TAG, "init"); uint64_t pin_bit_mask = BIT64(config->spiPinCs); @@ -50,7 +50,7 @@ bool SpiSdCard::applyGpioWorkAround() { return true; } -bool SpiSdCard::mountInternal(const std::string& newMountPath) { +bool SpiSdCardDevice::mountInternal(const std::string& newMountPath) { TT_LOG_I(TAG, "Mounting %s", newMountPath.c_str()); esp_vfs_fat_sdmmc_mount_config_t mount_config = { @@ -92,7 +92,7 @@ bool SpiSdCard::mountInternal(const std::string& newMountPath) { return true; } -bool SpiSdCard::mount(const std::string& newMountPath) { +bool SpiSdCardDevice::mount(const std::string& newMountPath) { if (!applyGpioWorkAround()) { TT_LOG_E(TAG, "Failed to set SPI CS pins high. This is a pre-requisite for mounting."); return false; @@ -107,7 +107,7 @@ bool SpiSdCard::mount(const std::string& newMountPath) { } } -bool SpiSdCard::unmount() { +bool SpiSdCardDevice::unmount() { if (card == nullptr) { TT_LOG_E(TAG, "Can't unmount: not mounted"); return false; @@ -124,7 +124,7 @@ bool SpiSdCard::unmount() { } // TODO: Refactor to "bool getStatus(Status* status)" method so that it can fail when the lvgl lock fails -tt::hal::SdCard::State SpiSdCard::getState() const { +SdCardDevice::State SpiSdCardDevice::getState() const { if (card == nullptr) { return State::Unmounted; } diff --git a/TactilityHeadless/Source/hal/usb/Usb.cpp b/TactilityHeadless/Source/hal/usb/Usb.cpp index 389ed075..ce522b3c 100644 --- a/TactilityHeadless/Source/hal/usb/Usb.cpp +++ b/TactilityHeadless/Source/hal/usb/Usb.cpp @@ -1,9 +1,9 @@ #ifdef ESP_PLATFORM #include "Tactility/hal/usb/Usb.h" -#include "Tactility/hal/usb/UsbTusb.h" -#include "Tactility/hal/SpiSdCard.h" #include "Tactility/TactilityHeadless.h" +#include "Tactility/hal/sdcard/SpiSdCardDevice.h" +#include "Tactility/hal/usb/UsbTusb.h" #include @@ -32,7 +32,7 @@ sdmmc_card_t* _Nullable getCard() { return nullptr; } - auto spi_sdcard = std::static_pointer_cast(sdcard); + auto spi_sdcard = std::static_pointer_cast(sdcard); if (spi_sdcard == nullptr) { TT_LOG_W(TAG, "SD card interface is not supported (must be SpiSdCard)"); return nullptr; diff --git a/TactilityHeadless/Source/service/sdcard/Sdcard.cpp b/TactilityHeadless/Source/service/sdcard/Sdcard.cpp index fa15b9d0..80452316 100644 --- a/TactilityHeadless/Source/service/sdcard/Sdcard.cpp +++ b/TactilityHeadless/Source/service/sdcard/Sdcard.cpp @@ -17,7 +17,7 @@ private: Mutex mutex; std::unique_ptr updateTimer; - hal::SdCard::State lastState = hal::SdCard::State::Unmounted; + hal::sdcard::SdCardDevice::State lastState = hal::sdcard::SdCardDevice::State::Unmounted; bool lock(TickType_t timeout) const { return mutex.lock(timeout); @@ -34,7 +34,7 @@ private: if (lock(50)) { auto new_state = sdcard->getState(); - if (new_state == hal::SdCard::State::Error) { + if (new_state == hal::sdcard::SdCardDevice::State::Error) { TT_LOG_W(TAG, "Sdcard error - unmounting. Did you eject the card in an unsafe manner?"); sdcard->unmount(); }