From 35d6e3e1da60f4fe57f8b164585279817beef626 Mon Sep 17 00:00:00 2001 From: Ali Jahangiri <75624145+aliphys@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:21:36 +0200 Subject: [PATCH 1/2] Append Arduino_ to POSIXStorage and UnifiedStorage --- README.md | 2 +- docs/README.md | 10 +++++----- examples/advanced/advanced.ino | 4 ++-- examples/opta_logger/opta_logger.ino | 4 ++-- examples/simple/simple.ino | 4 ++-- library.properties | 4 ++-- src/InternalStorage.cpp | 2 +- src/InternalStorage.h | 2 +- src/SDStorage.h | 2 +- src/Types.h | 2 +- src/USBStorage.h | 2 +- src/UnifiedStorage.h | 2 +- tests/test_qspi_usb_sd/test_c33 | 2 +- tests/test_qspi_usb_sd/test_h7 | 2 +- tests/test_qspi_usb_sd/test_qspi_usb_sd.ino | 2 +- 15 files changed, 23 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 32a2bca..087576d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Unified Storage Library -The UnifiedStorage library provides a unified interface to access different types of storage, including internal storage, SD cards, and USB mass storage devices. It simplifies the handling of files and directories across multiple storage mediums on Portenta, Opta, and some Nicla boards. +The Arduino_UnifiedStorage library provides a unified interface to access different types of storage, including internal storage, SD cards, and USB mass storage devices. It simplifies the handling of files and directories across multiple storage mediums on Portenta, Opta, and some Nicla boards. ## Examples diff --git a/docs/README.md b/docs/README.md index 0bd6611..983deb8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,18 +3,18 @@ ### Use QSPI Flash, SD cards, and USB mass storage devices This library allows you to easily switch between different storage mediums on supported boards, check the "Compatibility" section for more details about what storage medium is supported on what board. -To initialise the storage medium you need to create a `UnifiedStorage` object, and to mount it you need to call it's `begin()` method: +To initialise the storage medium you need to create a `Arduino_UnifiedStorage` object, and to mount it you need to call it's `begin()` method: ```c -UnifiedStorage storageMedium = USBStorage(); // or -// UnifiedStorage sd = SDStorage(); -// UnifiedStorage internal = InternalStorage(); +Arduino_UnifiedStorage storageMedium = USBStorage(); // or +// Arduino_UnifiedStorage sd = SDStorage(); +// Arduino_UnifiedStorage internal = InternalStorage(); void setup(){ storageMedium.begin(); } ``` -You can initialize a UnifiedStorage object of each type (QSPI, SD, USB), and copy files and folders from one medium to another. +You can initialize a Arduino_UnifiedStorage object of each type (QSPI, SD, USB), and copy files and folders from one medium to another. ### Open, Write, and Read Files diff --git a/examples/advanced/advanced.ino b/examples/advanced/advanced.ino index f909ba0..8548f5a 100644 --- a/examples/advanced/advanced.ino +++ b/examples/advanced/advanced.ino @@ -1,5 +1,5 @@ /* -This example demonstrates the usage of the "UnifiedStorage" library with USB storage and internal storage. +This example demonstrates the usage of the "Arduino_UnifiedStorage" library with USB storage and internal storage. The code includes the necessary library and defines instances of the "USBStorage" and "InternalStorage" classes. In the setup function, the code initializes the serial communication and mounts the USB storage and internal storage. @@ -13,7 +13,7 @@ After the file operations, the code prints the contents of both the USB storage It recursively prints the directories (marked as "[D]") and files (marked as "[F]") using the "printFolderContents" function. */ -#include "UnifiedStorage.h" +#include "Arduino_UnifiedStorage.h" USBStorage usbStorage = USBStorage(); diff --git a/examples/opta_logger/opta_logger.ino b/examples/opta_logger/opta_logger.ino index 89e9b69..346fdbb 100644 --- a/examples/opta_logger/opta_logger.ino +++ b/examples/opta_logger/opta_logger.ino @@ -1,5 +1,5 @@ /* -This example demonstrates the usage of the "UnifiedStorage" library for logging and backing up data to USB storage in case a USB Mass Storage device is inserted. +This example demonstrates the usage of the "Arduino_UnifiedStorage" library for logging and backing up data to USB storage in case a USB Mass Storage device is inserted. The code defines two main functions: "logData" and "performUpdate". The "logData" function logs sensor data by reading an analog sensor and writing the data to the log file. @@ -21,7 +21,7 @@ INSTRUCTIONS The skecth will log to internal storage in the meantime, and wait for the USB drive to be inserted again. */ -#include "UnifiedStorage.h" +#include "Arduino_UnifiedStorage.h" #include #define USB_MOUNTED_LED LED_BLUE diff --git a/examples/simple/simple.ino b/examples/simple/simple.ino index 9c96c26..f9b1714 100644 --- a/examples/simple/simple.ino +++ b/examples/simple/simple.ino @@ -1,5 +1,5 @@ /* -This examples demonstrates the usage of the "UnifiedStorage" library, +This examples demonstrates the usage of the "Arduino_UnifiedStorage" library, which allows the program to easily switch between different storage mediums. By uncommenting the appropriate lines, you can choose to use either an SD card, @@ -16,7 +16,7 @@ It changes the mode of the files to read mode, moves the file pointers to the be The read data is printed to the serial monitor. */ -#include "UnifiedStorage.h" +#include "Arduino_UnifiedStorage.h" SDStorage unifiedStorage = SDStorage(); // or //USBStorage unifiedStorage = USBStorage() // or diff --git a/library.properties b/library.properties index c2eae90..56b701b 100644 --- a/library.properties +++ b/library.properties @@ -1,4 +1,4 @@ -name=UnifiedStorage +name=Arduino_UnifiedStorage version=1.0.0 author=Arduino maintainer=Arduino @@ -7,4 +7,4 @@ paragraph=Adds ability to access different storage mediums category=Storage url=https://arduino.cc architectures=renesas,mbed_portenta -includes=UnifiedStorage.h +includes=Arduino_UnifiedStorage.h diff --git a/src/InternalStorage.cpp b/src/InternalStorage.cpp index 976db5e..89aefcc 100644 --- a/src/InternalStorage.cpp +++ b/src/InternalStorage.cpp @@ -1,4 +1,4 @@ -#include "UnifiedStorage.h" +#include "Arduino_UnifiedStorage.h" InternalStorage::InternalStorage(){ #if defined(ARDUINO_PORTENTA_C33) diff --git a/src/InternalStorage.h b/src/InternalStorage.h index 284e913..920c52e 100644 --- a/src/InternalStorage.h +++ b/src/InternalStorage.h @@ -3,7 +3,7 @@ #ifndef InternalStorage_H #define InternalStorage_H -#include "UnifiedStorage.h" +#include "Arduino_UnifiedStorage.h" class InternalStorage : public UnifiedStorage { diff --git a/src/SDStorage.h b/src/SDStorage.h index dda4c56..c97e0bd 100644 --- a/src/SDStorage.h +++ b/src/SDStorage.h @@ -3,7 +3,7 @@ #ifndef SDStorage_H #define SDStorage_H -#include "UnifiedStorage.h" +#include "Arduino_UnifiedStorage.h" #if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_C33) || !defined(ARDUINO_OPTA) diff --git a/src/Types.h b/src/Types.h index 82503d8..645cd8d 100644 --- a/src/Types.h +++ b/src/Types.h @@ -5,7 +5,7 @@ #define PATH_MAX 255 #include "Arduino.h" -#include "POSIXStorage.h" +#include "Arduino_POSIXStorage.h" #include #include diff --git a/src/USBStorage.h b/src/USBStorage.h index c9263b1..96b68a7 100644 --- a/src/USBStorage.h +++ b/src/USBStorage.h @@ -1,4 +1,4 @@ -#include "UnifiedStorage.h" +#include "Arduino_UnifiedStorage.h" #ifndef USBStorage_H #define USBStorage_H diff --git a/src/UnifiedStorage.h b/src/UnifiedStorage.h index a811611..b6371b0 100644 --- a/src/UnifiedStorage.h +++ b/src/UnifiedStorage.h @@ -9,7 +9,7 @@ #if defined(ARDUINO_PORTENTA_C33) #include "Types.h" #include "Arduino.h" -#include "POSIXStorage.h" +#include "Arduino_POSIXStorage.h" #endif diff --git a/tests/test_qspi_usb_sd/test_c33 b/tests/test_qspi_usb_sd/test_c33 index 02d8812..a29b2e1 100755 --- a/tests/test_qspi_usb_sd/test_c33 +++ b/tests/test_qspi_usb_sd/test_c33 @@ -1,3 +1,3 @@ #!/bin/bash -arduino-cli compile -b arduino:renesas_portenta:portenta_c33 --library "../../POSIXStorage" --library "/home/c.dragomir/ArduinoWorkspace/arduino_UnifiedStorage" +arduino-cli compile -b arduino:renesas_portenta:portenta_c33 --library "../../Arduino_POSIXStorage" --library "/home/c.dragomir/ArduinoWorkspace/Arduino_UnifiedStorage" arduino-cli upload -b arduino:renesas_portenta:portenta_c33 \ No newline at end of file diff --git a/tests/test_qspi_usb_sd/test_h7 b/tests/test_qspi_usb_sd/test_h7 index fdba3be..92a2832 100755 --- a/tests/test_qspi_usb_sd/test_h7 +++ b/tests/test_qspi_usb_sd/test_h7 @@ -1,3 +1,3 @@ #!/bin/bash -arduino-cli compile -b arduino:mbed_portenta:envie_m7 --library "../../POSIXStorage" --library "/home/c.dragomir/ArduinoWorkspace/arduino_UnifiedStorage" +arduino-cli compile -b arduino:mbed_portenta:envie_m7 --library "../../Arduino_POSIXStorage" --library "/home/c.dragomir/ArduinoWorkspace/Arduino_UnifiedStorage" arduino-cli upload -b arduino:mbed_portenta:envie_m7 \ No newline at end of file diff --git a/tests/test_qspi_usb_sd/test_qspi_usb_sd.ino b/tests/test_qspi_usb_sd/test_qspi_usb_sd.ino index 55e6ab7..6ef1814 100644 --- a/tests/test_qspi_usb_sd/test_qspi_usb_sd.ino +++ b/tests/test_qspi_usb_sd/test_qspi_usb_sd.ino @@ -1,5 +1,5 @@ #include -#include "UnifiedStorage.h" +#include "Arduino_UnifiedStorage.h" #define HAS_USB 1 #define HAS_SD 1 From adc589b5b07d065c7d86b72199edc68501e9ce16 Mon Sep 17 00:00:00 2001 From: Ali Jahangiri <75624145+aliphys@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:25:09 +0200 Subject: [PATCH 2/2] Allow main class to be called by UnifiedStorage --- src/{UnifiedStorage.h => Arduino_UnifiedStorage.h} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename src/{UnifiedStorage.h => Arduino_UnifiedStorage.h} (93%) diff --git a/src/UnifiedStorage.h b/src/Arduino_UnifiedStorage.h similarity index 93% rename from src/UnifiedStorage.h rename to src/Arduino_UnifiedStorage.h index b6371b0..9693e4f 100644 --- a/src/UnifiedStorage.h +++ b/src/Arduino_UnifiedStorage.h @@ -28,7 +28,7 @@ #include "FATFileSystem.h" #endif -class UnifiedStorage { +class Arduino_UnifiedStorage { public: virtual int begin() = 0; @@ -50,5 +50,7 @@ class UnifiedStorage { #endif +extern Arduino_UnifiedStorage UnifiedStorage; + #endif