From 1890beb7ba5cef4a8cc2a9b4de35220516b64fdf Mon Sep 17 00:00:00 2001 From: Rennan Cockles Date: Wed, 5 Mar 2025 12:30:49 -0300 Subject: [PATCH 1/6] fix typedef warning --- lib/utility/bq27220.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utility/bq27220.h b/lib/utility/bq27220.h index b7470053e..8cd875744 100644 --- a/lib/utility/bq27220.h +++ b/lib/utility/bq27220.h @@ -71,7 +71,7 @@ #include #include -typedef enum OP_STATUS{ +enum OP_STATUS{ SEALED = 0b11, UNSEALED = 0b10, FULL = 0b01, From b20e2c1e690304f086a7cbc9f8c4490984fbdb04 Mon Sep 17 00:00:00 2001 From: Rennan Cockles Date: Thu, 6 Mar 2025 23:26:04 -0300 Subject: [PATCH 2/6] fix BTN_ALIAS error defining as char instead of string literal --- boards/pinouts/_New-Device-Model.h | 6 +++--- boards/pinouts/lilygo-t-display-s3.h | 8 ++++---- boards/pinouts/lilygo-t-embed-cc1101.h | 20 ++++++++++---------- boards/pinouts/lilygo-t-embed.h | 8 ++++---- boards/pinouts/m5stack-cores3.h | 4 ++-- boards/pinouts/smoochiee-board.h | 10 +++++----- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/boards/pinouts/_New-Device-Model.h b/boards/pinouts/_New-Device-Model.h index 193704029..08de6302c 100644 --- a/boards/pinouts/_New-Device-Model.h +++ b/boards/pinouts/_New-Device-Model.h @@ -65,13 +65,13 @@ static const uint8_t ADC2 = 8; #define BAD_RX GROVE_SCL #define HAS_BTN 0 -#define BTN_ALIAS '"Ok"' +#define BTN_ALIAS "\"Ok\"" #define BTN_PIN 0 #define BTN_ACT LOW #define IR_TX_PINS '{{"M5 IR Mod", GROVE_SDA}, {"Pin 1", 1}, {"Pin 2", 2}}' #define IR_RX_PINS '{{"M5 IR Mod", GROVE_SCL}, {"Pin 1", 1}, {"Pin 2", 2}}' -#define LED -1 +#define LED -1 #define LED_ON HIGH #define LED_OFF LOW @@ -85,7 +85,7 @@ static const uint8_t ADC2 = 8; #define CC1101_MISO_PIN SPI_MISO_PIN #define NRF24_CE_PIN 6 -#define NRF24_SS_PIN 7 +#define NRF24_SS_PIN 7 #define NRF24_MOSI_PIN SPI_MOSI_PIN #define NRF24_SCK_PIN SPI_SCK_PIN #define NRF24_MISO_PIN SPI_MISO_PIN diff --git a/boards/pinouts/lilygo-t-display-s3.h b/boards/pinouts/lilygo-t-display-s3.h index 0282f4dd5..6db4e7e37 100644 --- a/boards/pinouts/lilygo-t-display-s3.h +++ b/boards/pinouts/lilygo-t-display-s3.h @@ -36,7 +36,7 @@ static const uint8_t SCL = GROVE_SCL; #define TFT_WIDTH 170 #define TFT_HEIGHT 320 #define TFT_BL 38 -#define TFT_CS 6 +#define TFT_CS 6 #define TFT_DC 7 #define TFT_RST 5 #define TFT_D0 39 @@ -76,11 +76,11 @@ static const uint8_t SCL = GROVE_SCL; #define PIN_DATA 42 // Buttons & Navigation -#define BTN_ALIAS '"OK"' +#define BTN_ALIAS "\"OK\"" #define HAS_3_BUTTONS #define SEL_BTN 16 #define UP_BTN 0 -#define DW_BTN 14 +#define DW_BTN 14 #define BK_BTN 3 #define BTN_ACT LOW @@ -90,7 +90,7 @@ static const uint8_t SCL = GROVE_SCL; #define LED_ON HIGH #define LED_OFF LOW -// BadUSB +// BadUSB #define USB_as_HID 1 #endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/boards/pinouts/lilygo-t-embed-cc1101.h b/boards/pinouts/lilygo-t-embed-cc1101.h index d93832858..03daa316e 100644 --- a/boards/pinouts/lilygo-t-embed-cc1101.h +++ b/boards/pinouts/lilygo-t-embed-cc1101.h @@ -30,11 +30,11 @@ static const uint8_t SCL = GROVE_SCL; #define TFT_INVERSION_ON #define TFT_WIDTH 170 #define TFT_HEIGHT 320 -#define TFT_BL 21 -#define TFT_MISO SPI_MISO_PIN +#define TFT_BL 21 +#define TFT_MISO SPI_MISO_PIN #define TFT_MOSI SPI_MOSI_PIN #define TFT_SCLK SPI_SCK_PIN -#define TFT_CS 41 +#define TFT_CS 41 #define TFT_DC 16 #define TFT_RST 40 #define SPI_FREQUENCY 80000000 @@ -67,7 +67,7 @@ static const uint8_t SCL = GROVE_SCL; // CC1101 #define USE_CC1101_VIA_SPI -#define CC1101_GDO0_PIN 3 +#define CC1101_GDO0_PIN 3 #define CC1101_GDO2_PIN 38 #define CC1101_SW1_PIN 47 #define CC1101_SW0_PIN 48 @@ -92,7 +92,7 @@ static const uint8_t SCL = GROVE_SCL; #define MCLK PIN_CLK // Serial -#define SERIAL_TX 43 +#define SERIAL_TX 43 #define SERIAL_RX 44 static const uint8_t TX = SERIAL_TX; static const uint8_t RX = SERIAL_RX; @@ -111,7 +111,7 @@ static const uint8_t RX = SERIAL_RX; #define ENCODER_INB 5 #define ENCODER_KEY 0 #define HAS_BTN 1 -#define BTN_ALIAS '"Mid"' +#define BTN_ALIAS "\"Mid\"" #define SEL_BTN ENCODER_KEY #define UP_BTN -1 #define DW_BTN -1 @@ -119,12 +119,12 @@ static const uint8_t RX = SERIAL_RX; #define BTN_ACT LOW // IR -#define LED 2 -#define RXLED 1 +#define LED 2 +#define RXLED 1 #define LED_ON HIGH #define LED_OFF LOW -// RFID +// RFID #define RFID125_RX_PIN SERIAL_RX #define RFID125_TX_PIN SERIAL_TX @@ -137,7 +137,7 @@ static const uint8_t RX = SERIAL_RX; #define LED_TYPE_IS_RGBW 0 #define LED_COUNT 8 -// BadUSB +// BadUSB #define USB_as_HID 1 #endif /* Pins_Arduino_h */ diff --git a/boards/pinouts/lilygo-t-embed.h b/boards/pinouts/lilygo-t-embed.h index c8adc840d..6a2f4af52 100644 --- a/boards/pinouts/lilygo-t-embed.h +++ b/boards/pinouts/lilygo-t-embed.h @@ -32,10 +32,10 @@ static const uint8_t SCL = GROVE_SCL; #define TFT_WIDTH 170 #define TFT_HEIGHT 320 #define TFT_BL 15 -#define TFT_MISO -1 +#define TFT_MISO -1 #define TFT_MOSI 11 #define TFT_SCLK 12 -#define TFT_CS 10 +#define TFT_CS 10 #define TFT_DC 13 #define TFT_RST 9 #define TOUCH_CS -1 @@ -100,7 +100,7 @@ static const uint8_t SCL = GROVE_SCL; #define ENCODER_INB 1 #define ENCODER_KEY 0 #define HAS_BTN 1 -#define BTN_ALIAS '"Mid"' +#define BTN_ALIAS "\"Mid\"" #define SEL_BTN ENCODER_KEY #define UP_BTN 1 #define DW_BTN 1 @@ -127,7 +127,7 @@ static const uint8_t SCL = GROVE_SCL; #define LED_TYPE_IS_RGBW 0 #define LED_COUNT 8 -// BadUSB +// BadUSB #define USB_as_HID 1 #endif /* Pins_Arduino_h */ diff --git a/boards/pinouts/m5stack-cores3.h b/boards/pinouts/m5stack-cores3.h index a8d89529b..aec2cfa45 100644 --- a/boards/pinouts/m5stack-cores3.h +++ b/boards/pinouts/m5stack-cores3.h @@ -60,7 +60,7 @@ static const uint8_t G46 = 46; static const uint8_t ADC = 10; -#define HAS_RTC +#define HAS_RTC #define USB_as_HID #define HAS_TOUCH @@ -102,7 +102,7 @@ static const uint8_t ADC = 10; #define SPI_TOUCH_FREQUENCY 2500000 -#define BTN_ALIAS '"Ok"' +#define BTN_ALIAS "\"Ok\"" #define BTN_PIN -1 #define BTN_ACT LOW diff --git a/boards/pinouts/smoochiee-board.h b/boards/pinouts/smoochiee-board.h index 02382a26b..9b8715c91 100644 --- a/boards/pinouts/smoochiee-board.h +++ b/boards/pinouts/smoochiee-board.h @@ -52,15 +52,15 @@ static const uint8_t ADC2 = 8; #define BAD_TX SERIAL_TX #define USB_as_HID 1 -#define BTN_ALIAS '"OK"' +#define BTN_ALIAS "\"OK\"" #define HAS_5_BUTTONS #define SEL_BTN 0 #define UP_BTN 40 -#define DW_BTN 41 +#define DW_BTN 41 #define R_BTN 38 #define L_BTN 39 #define BTN_ACT LOW - + #define RXLED 4 #define LED 5 #define LED_ON HIGH @@ -68,7 +68,7 @@ static const uint8_t ADC2 = 8; #define USE_CC1101_VIA_SPI #define CC1101_GDO0_PIN 9 -#define CC1101_GDO2_PIN 10 +#define CC1101_GDO2_PIN 10 #define CC1101_SS_PIN 46 #define CC1101_MOSI_PIN SPI_MOSI_PIN #define CC1101_SCK_PIN SPI_SCK_PIN @@ -76,7 +76,7 @@ static const uint8_t ADC2 = 8; #define USE_NRF24_VIA_SPI #define NRF24_CE_PIN 21 -#define NRF24_SS_PIN 14 +#define NRF24_SS_PIN 14 #define NRF24_MOSI_PIN SPI_MOSI_PIN #define NRF24_SCK_PIN SPI_SCK_PIN #define NRF24_MISO_PIN SPI_MISO_PIN From 5ad3cc25e20fc98f1818ea7e40c259abf74e78fe Mon Sep 17 00:00:00 2001 From: Rennan Cockles Date: Thu, 6 Mar 2025 23:29:56 -0300 Subject: [PATCH 3/6] fix memory access warning --- src/core/connect.cpp | 5 ++++- src/core/connect.h | 16 ++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/core/connect.cpp b/src/core/connect.cpp index 23a43c41f..27028b5e7 100644 --- a/src/core/connect.cpp +++ b/src/core/connect.cpp @@ -324,7 +324,10 @@ void onDataSent(const uint8_t* mac_addr, esp_now_send_status_t status) { void onDataRecv(const uint8_t* mac, const uint8_t* incomingData, int len) { DeviceConnection::FileMessage recvFileMessage; - memcpy(&recvFileMessage, incomingData, sizeof(recvFileMessage)); + + // Use reinterpret_cast and copy assignment + const DeviceConnection::FileMessage* incomingMessage = reinterpret_cast(incomingData); + recvFileMessage = *incomingMessage; // Use copy assignment if (recvFileMessage.ping) return sendPong(mac); if (recvFileMessage.pong) return appendPeerToList(mac); diff --git a/src/core/connect.h b/src/core/connect.h index ec0553add..3a98f764e 100644 --- a/src/core/connect.h +++ b/src/core/connect.h @@ -26,17 +26,21 @@ class DeviceConnection { ABORTED, }; - typedef struct { + struct FileMessage { String filename; String filepath; size_t totalBytes; size_t bytesSent; char data[PAGE_BYTES]; - size_t dataSize = 0; - bool done = false; - bool ping = false; - bool pong = false; - } FileMessage; + size_t dataSize; + bool done; + bool ping; + bool pong; + + // Constructor to initialize defaults + FileMessage() + : totalBytes(0), bytesSent(0), dataSize(0), done(false), ping(false), pong(false) {} + }; ///////////////////////////////////////////////////////////////////////////////////// // Constructor From 580a04d6fd2ccacb32bfe9fc180a0dd9ec356162 Mon Sep 17 00:00:00 2001 From: Rennan Cockles Date: Thu, 6 Mar 2025 23:31:29 -0300 Subject: [PATCH 4/6] fix idx not assigned warning --- src/core/led_control.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/led_control.cpp b/src/core/led_control.cpp index a07af382f..2a8ef5405 100644 --- a/src/core/led_control.cpp +++ b/src/core/led_control.cpp @@ -121,7 +121,7 @@ void setLedColorConfig() { void setLedBrightnessConfig() { - int idx; + int idx = 0; if (bruceConfig.ledBright==10) idx=0; else if (bruceConfig.ledBright==25) idx=1; else if (bruceConfig.ledBright==50) idx=2; From 877de707c5746432d2717432cb96a217f9947b90 Mon Sep 17 00:00:00 2001 From: Rennan Cockles Date: Fri, 7 Mar 2025 17:40:48 -0300 Subject: [PATCH 5/6] Add USB mass storage --- src/core/massStorage.cpp | 198 +++++++++++++++++++++++++++++ src/core/massStorage.h | 51 ++++++++ src/core/menu_items/ConfigMenu.cpp | 8 +- src/core/menu_items/FileMenu.cpp | 2 + 4 files changed, 255 insertions(+), 4 deletions(-) create mode 100644 src/core/massStorage.cpp create mode 100644 src/core/massStorage.h diff --git a/src/core/massStorage.cpp b/src/core/massStorage.cpp new file mode 100644 index 000000000..214003d83 --- /dev/null +++ b/src/core/massStorage.cpp @@ -0,0 +1,198 @@ +#include "massStorage.h" +#include "core/display.h" +#include + +bool MassStorage::shouldStop = false; + +MassStorage::MassStorage() { + setup(); +} + + +MassStorage::~MassStorage() { + msc.end(); + USB.~ESPUSB(); + + // Hack to make USB back to flash mode + USB.enableDFU(); +} + + +void MassStorage::setup() { + displayMessage("Mounting..."); + + setShouldStop(false); + + if (!setupSdCard()) { + displayError("SD card not found."); + delay(1000); + return; + } + + beginUsb(); + + delay(500); + return loop(); +} + + +void MassStorage::loop() { + while(!check(EscPress) && !shouldStop) yield(); +} + + +void MassStorage::beginUsb() { + setupUsbCallback(); + setupUsbEvent(); + drawUSBStickIcon(false); + USB.begin(); +} + + +void MassStorage::setupUsbCallback() { + uint32_t secSize = SD.sectorSize(); + uint32_t numSectors = SD.numSectors(); + + msc.vendorID("ESP32"); + msc.productID("BRUCE"); + msc.productRevision("1.0"); + + msc.onRead(usbReadCallback); + msc.onWrite(usbWriteCallback); + msc.onStartStop(usbStartStopCallback); + + msc.mediaPresent(true); + msc.begin(numSectors, secSize); +} + + +void MassStorage::setupUsbEvent() { + USB.onEvent([](void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) { + if (event_base == ARDUINO_USB_EVENTS) { + auto* data = reinterpret_cast(event_data); + switch (event_id) { + case ARDUINO_USB_STARTED_EVENT: + drawUSBStickIcon(true); + break; + case ARDUINO_USB_STOPPED_EVENT: + drawUSBStickIcon(false); + break; + case ARDUINO_USB_SUSPEND_EVENT: + MassStorage::displayMessage("USB suspend"); + break; + case ARDUINO_USB_RESUME_EVENT: + MassStorage::displayMessage("USB resume"); + break; + default: + break; + } + } + }); +} + + +void MassStorage::displayMessage(String message) { + drawMainBorderWithTitle("Mass Storage"); + padprintln(""); + padprintln(message); +} + + +int32_t usbWriteCallback(uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) { + // Verify freespace + uint64_t freeSpace = SD.totalBytes() - SD.usedBytes(); + if (bufsize > freeSpace) { + return -1; // no space available + } + + // Verify sector size + const uint32_t secSize = SD.sectorSize(); + if (secSize == 0) return -1; // disk error + + // Write blocs + for (uint32_t x = 0; x < bufsize / secSize; ++x) { + uint8_t blkBuffer[secSize]; + memcpy(blkBuffer, buffer + secSize * x, secSize); + if (!SD.writeRAW(blkBuffer, lba + x)) { + return -1; // write error + } + } + return bufsize; +} + + +int32_t usbReadCallback(uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) { + // Verify sector size + const uint32_t secSize = SD.sectorSize(); + if (secSize == 0) return -1; // disk error + + // Read blocs + for (uint32_t x = 0; x < bufsize / secSize; ++x) { + if (!SD.readRAW(reinterpret_cast(buffer) + (x * secSize), lba + x)) { + return -1; // read error + } + } + return bufsize; +} + + +bool usbStartStopCallback(uint8_t power_condition, bool start, bool load_eject) { + if (!start && load_eject) { + MassStorage::setShouldStop(true); + return false; + } + + return true; +} + + +void drawUSBStickIcon(bool plugged) { + MassStorage::displayMessage(""); + + float scale; + if (bruceConfig.rotation & 0b01) scale = float((float)tftHeight/(float)135); + else scale = float((float)tftWidth/(float)240); + + int iconW = scale * 120; + int iconH = scale * 40; + + if (iconW % 2 != 0) iconW++; + if (iconH % 2 != 0) iconH++; + + int radius = 5; + + int bodyW = 2*iconW/3; + int bodyH = iconH; + int bodyX = tftWidth/2 - iconW/2; + int bodyY = tftHeight/2; + + int portW = iconW - bodyW; + int portH = 0.8*bodyH; + int portX = bodyX + bodyW; + int portY = bodyY + (bodyH-portH)/2; + + int portDetailW = portW/2; + int portDetailH = portH/4; + int portDetailX = portX + (portW - portDetailW)/2; + int portDetailY1 = portY + 0.8*portDetailH; + int portDetailY2 = portY + portH - 1.8*portDetailH; + + int ledW = 0.1*bodyH; + int ledH = 0.6*bodyH; + int ledX = bodyX + 2*ledW; + int ledY = bodyY + (iconH-ledH)/2; + + // Body + tft.fillRoundRect(bodyX, bodyY, bodyW, bodyH, radius, TFT_DARKCYAN); + // Port USB + tft.fillRoundRect(portX, portY, portW, portH, radius, TFT_LIGHTGREY); + // Small square on port + tft.fillRoundRect( + portDetailX, portDetailY1, portDetailW, portDetailH, radius, TFT_DARKGREY + ); + tft.fillRoundRect( + portDetailX, portDetailY2, portDetailW, portDetailH, radius, TFT_DARKGREY + ); + // Led + tft.fillRoundRect(ledX, ledY, ledW, ledH, radius, plugged ? TFT_GREEN : TFT_RED); +} diff --git a/src/core/massStorage.h b/src/core/massStorage.h new file mode 100644 index 000000000..50dc44f8e --- /dev/null +++ b/src/core/massStorage.h @@ -0,0 +1,51 @@ +#ifndef __MASS_STORAGE_H__ +#define __MASS_STORAGE_H__ + +#include +#include + + +class MassStorage { +public: + static bool shouldStop; + + ///////////////////////////////////////////////////////////////////////////////////// + // Constructor + ///////////////////////////////////////////////////////////////////////////////////// + MassStorage(); + ~MassStorage(); + + ///////////////////////////////////////////////////////////////////////////////////// + // Life Cycle + ///////////////////////////////////////////////////////////////////////////////////// + void setup(); + void loop(); + + ///////////////////////////////////////////////////////////////////////////////////// + // Operations + ///////////////////////////////////////////////////////////////////////////////////// + static void setShouldStop(bool value) { shouldStop = value; } + + ///////////////////////////////////////////////////////////////////////////////////// + // Display functions + ///////////////////////////////////////////////////////////////////////////////////// + static void displayMessage(String message); + +private: + USBMSC msc; + + ///////////////////////////////////////////////////////////////////////////////////// + // Setup + ///////////////////////////////////////////////////////////////////////////////////// + void beginUsb(void); + void setupUsbCallback(void); + void setupUsbEvent(void); +}; + +int32_t usbWriteCallback(uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize); +int32_t usbReadCallback(uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize); +bool usbStartStopCallback(uint8_t power_condition, bool start, bool load_eject); + +void drawUSBStickIcon(bool plugged); + +#endif // MASS_STORAGE_H diff --git a/src/core/menu_items/ConfigMenu.cpp b/src/core/menu_items/ConfigMenu.cpp index c71a78ee4..8eb500b4d 100644 --- a/src/core/menu_items/ConfigMenu.cpp +++ b/src/core/menu_items/ConfigMenu.cpp @@ -26,12 +26,11 @@ void ConfigMenu::optionsMenu() { {"Sleep", [=]() { setSleepMode(); }}, {"Factory Reset", [=]() { bruceConfig.factoryReset(); }}, {"Restart", [=]() { ESP.restart(); }}, - {"About", [=]() { showDeviceInfo(); }}, }; #if defined(T_EMBED_1101) - options.emplace_back("Turn-off", [=]() { powerOff(); }); - options.emplace_back("DeepSleep", [=]() { digitalWrite(PIN_POWER_ON,LOW); esp_sleep_enable_ext0_wakeup(GPIO_NUM_6,LOW); esp_deep_sleep_start(); }); + options.emplace_back("Turn-off", [=]() { powerOff(); }); + options.emplace_back("Deep Sleep", [=]() { digitalWrite(PIN_POWER_ON,LOW); esp_sleep_enable_ext0_wakeup(GPIO_NUM_6,LOW); esp_deep_sleep_start(); }); #elif defined(T_DISPLAY_S3) options.emplace_back("Turn-off", [=]() { @@ -39,11 +38,12 @@ void ConfigMenu::optionsMenu() { digitalWrite(PIN_POWER_ON, LOW); digitalWrite(TFT_BL, LOW); tft.writecommand(0x10); - esp_deep_sleep_start(); + esp_deep_sleep_start(); }); #endif if (bruceConfig.devMode) options.emplace_back("Dev Mode", [=]() { devMenu(); }); + options.emplace_back("About", [=]() { showDeviceInfo(); }); options.emplace_back("Main Menu", [=]() { backToMenu(); }); loopOptions(options,false,true,"Config"); diff --git a/src/core/menu_items/FileMenu.cpp b/src/core/menu_items/FileMenu.cpp index 621921217..45a30f948 100644 --- a/src/core/menu_items/FileMenu.cpp +++ b/src/core/menu_items/FileMenu.cpp @@ -3,12 +3,14 @@ #include "core/sd_functions.h" #include "modules/others/webInterface.h" #include "core/utils.h" +#include "core/massStorage.h" void FileMenu::optionsMenu() { options = { {"SD Card", [=]() { loopSD(SD); }}, {"LittleFS", [=]() { loopSD(LittleFS); }}, {"WebUI", [=]() { loopOptionsWebUi(); }}, + {"Mass Storage", [=]() { MassStorage(); }}, {"Main Menu", [=]() { backToMenu(); }}, }; From d64ba89662b6a4b8a33c9f7c48bfb8fb4a031e85 Mon Sep 17 00:00:00 2001 From: Rennan Cockles Date: Fri, 7 Mar 2025 19:00:13 -0300 Subject: [PATCH 6/6] fix stick build error --- src/core/massStorage.cpp | 4 ++++ src/core/massStorage.h | 3 +++ src/core/menu_items/FileMenu.cpp | 2 ++ 3 files changed, 9 insertions(+) diff --git a/src/core/massStorage.cpp b/src/core/massStorage.cpp index 214003d83..5d403f812 100644 --- a/src/core/massStorage.cpp +++ b/src/core/massStorage.cpp @@ -1,3 +1,5 @@ +#ifdef ARDUINO_USB_MODE + #include "massStorage.h" #include "core/display.h" #include @@ -196,3 +198,5 @@ void drawUSBStickIcon(bool plugged) { // Led tft.fillRoundRect(ledX, ledY, ledW, ledH, radius, plugged ? TFT_GREEN : TFT_RED); } + +#endif // ARDUINO_USB_MODE diff --git a/src/core/massStorage.h b/src/core/massStorage.h index 50dc44f8e..368ac947f 100644 --- a/src/core/massStorage.h +++ b/src/core/massStorage.h @@ -1,3 +1,5 @@ +#ifdef ARDUINO_USB_MODE + #ifndef __MASS_STORAGE_H__ #define __MASS_STORAGE_H__ @@ -49,3 +51,4 @@ bool usbStartStopCallback(uint8_t power_condition, bool start, bool load_eject); void drawUSBStickIcon(bool plugged); #endif // MASS_STORAGE_H +#endif // ARDUINO_USB_MODE diff --git a/src/core/menu_items/FileMenu.cpp b/src/core/menu_items/FileMenu.cpp index 45a30f948..a9c0eef6b 100644 --- a/src/core/menu_items/FileMenu.cpp +++ b/src/core/menu_items/FileMenu.cpp @@ -10,7 +10,9 @@ void FileMenu::optionsMenu() { {"SD Card", [=]() { loopSD(SD); }}, {"LittleFS", [=]() { loopSD(LittleFS); }}, {"WebUI", [=]() { loopOptionsWebUi(); }}, + #ifdef ARDUINO_USB_MODE {"Mass Storage", [=]() { MassStorage(); }}, + #endif {"Main Menu", [=]() { backToMenu(); }}, };