Skip to content

Commit fbd3990

Browse files
locatwfacchinm
authored andcommitted
Fix whitespaces
1 parent 4bc7cd6 commit fbd3990

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

Diff for: examples/InternalStoragePartitioning/InternalStoragePartitioning.ino

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
This example demonstrates the usage of the "Arduino_UnifiedStorage" library for retrieving and creating partitions on the internal storage.
55
The code should help you understand how to work with partitions and perform file operations in different partitions.
66
7-
It creates the partitions specified in the std::vector<Partitions> you find at the top of the sketch.
7+
It creates the partitions specified in the std::vector<Partitions> you find at the top of the sketch.
88
You can define your own, as long as the size of all partitions doesn't exceed the size of your board's QSPI flash( if you are in doubt about that check docs.arduino.com for more information) and as long as you don't have more than 4 partitions (MBR limitation)
99
The Partition struct has two values:
1010
- `size` the size of your partition in kilobytes
1111
- 'fileSystemType` which can be either `FS_FAT` or `FS_LITTLEFS`
1212
13-
Here are a few examples of valid partitioning schemes:
13+
Here are a few examples of valid partitioning schemes:
1414
- std::vector<Partition> partitioningScheme = {{16384, FS_FAT}};
1515
- std::vector<Partition> partitioningScheme = {{2048, FS_FAT}, {6144, FS_FAT} {8192, FS_LITTLEFS}};
1616
- std::vector<Partition> partitioningScheme = {{4096, FS_LITTLEFS}, {4096, FS_FAT}, {4096, FS_LITTLEFS}, {4096, FS_FAT}};
@@ -24,8 +24,8 @@
2424
INSTRUCTIONS:
2525
1. Check compatibility with your board and make sure you have "POSIXStorage" and "Arduino_UnifiedStorage" installed
2626
2. Connect your board to the serial monitor
27-
3. Wait for the sketch to run
28-
4. Modify the partitioning scheme according to your needs
27+
3. Wait for the sketch to run
28+
4. Modify the partitioning scheme according to your needs
2929
3030
Created: 26th October 2023
3131
By: Cristian Dragomir
@@ -36,7 +36,7 @@
3636
#include <vector>
3737

3838
// Create a vector of partitions with one partition of 16MB using LittleFS
39-
std::vector<Partition> partitioningScheme = {
39+
std::vector<Partition> partitioningScheme = {
4040
{1024, FS_FAT}, // 1 MB for certificates
4141
{5120, FS_FAT}, // 5 MB for OTA firmware updates
4242
{8192, FS_LITTLEFS} // 8 MB for user data
@@ -50,7 +50,7 @@ void testWriting(Arduino_UnifiedStorage *storage) {
5050
// Create a new file named "file.txt" for writing
5151
UFile file = root.createFile("file.txt", FileMode::WRITE);
5252
Serial.println("\t\t - File path: " + file.getPathAsString());
53-
53+
5454
// Write data to the file
5555
file.write("writing stuff to the file");
5656

@@ -65,7 +65,7 @@ void testWriting(Arduino_UnifiedStorage *storage) {
6565
void testAllPartitions(std::vector<Partition> partitions) {
6666
for (size_t i = 1; i < partitions.size() + 1; ++i) {
6767
const char *partitionName = createPartitionName(i);
68-
68+
6969
// Create an InternalStorage object for the partition
7070
InternalStorage thisPartition = InternalStorage(i, partitionName, partitions[i - 1].fileSystemType);
7171

@@ -113,7 +113,7 @@ void setup() {
113113

114114
delay(1000);
115115

116-
// Read the MBR sector and display the partitions
116+
// Read the MBR sector and display the partitions
117117
listPartitions();
118118
}
119119

Diff for: src/InternalStorage.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
*/
1111
class InternalStorage : public Arduino_UnifiedStorage {
1212
public:
13-
13+
1414

1515
/**
1616
* Constructs an InternalStorage object with default settings.
1717
* If no partitions are available, it restores the default partitioning scheme (See restoreDefaultPartitions() for more info).
1818
* If partitions are available, it sets the partition number, file system type, and partition name based on the last partition available.
19-
* When using the default partitioning scheme the last partition would be the user partition.
19+
* When using the default partitioning scheme the last partition would be the user partition.
2020
*/
2121
InternalStorage();
2222

2323
/**
2424
* Constructs an InternalStorage object with the specified partition, name, and file system.
25-
*
25+
*
2626
* @param partition The partition number.
2727
* @param name The name of the partition.
2828
* @param fs The desired file system (FS_FAT or FS_LITTLEFS).
@@ -31,45 +31,45 @@ class InternalStorage : public Arduino_UnifiedStorage {
3131

3232
/**
3333
* Initializes the internal storage.
34-
*
34+
*
3535
* @return true if successful, false if failed.
3636
*/
3737
bool begin() override;
3838

3939
/**
4040
* Initializes the internal storage with the specified file system.
41-
*
41+
*
4242
* @param fs The desired file system (FS_FAT or FS_LITTLEFS).
4343
* @return true if successful, false if failed.
4444
*/
4545
bool begin(FileSystems fs) override;
4646

4747
/**
4848
* Unmounts the internal storage.
49-
*
49+
*
5050
* @return true if successful, false if failed.
5151
*/
5252
bool unmount() override;
5353

5454
/**
5555
* Retrieves the root folder of the internal storage.
56-
*
56+
*
5757
* @return The root folder as a Folder object.
5858
*/
5959
Folder getRootFolder() override;
6060

6161

6262
/**
6363
* Formats the internal storage with the selected file system.
64-
*
64+
*
6565
* @return true if successful, false if failed.
6666
*/
6767
bool format(FileSystems fs) override;
6868

6969

7070
/**
7171
* Retrieves the block device associated with the internal storage.
72-
*
72+
*
7373
* @return The block device as a BlockDevice object.
7474
*/
7575
BlockDeviceType *getBlockDevice();
@@ -86,7 +86,7 @@ class InternalStorage : public Arduino_UnifiedStorage {
8686
* Creates one partition spanning over the whole size of the internal storage drive erasing the existing partitions.
8787
* @return true if successful, false if failed.
8888
*/
89-
static bool partition();
89+
static bool partition();
9090

9191
/**
9292
* Restores the default partitioning scheme (1MB FAT32 for Certificates, 5MB FAT32 for OTA, 8MB user storage) to the internal storage drive erasing the existing partitions.
@@ -96,7 +96,7 @@ class InternalStorage : public Arduino_UnifiedStorage {
9696

9797
/**
9898
* Reads the partitioning scheme from the MBR sector of the internal storage drive and returns a vector of structs of type Partition that represents the partitioning scheme
99-
* @return vector of structs of type Partition
99+
* @return vector of structs of type Partition
100100
*/
101101
static std::vector<Partition> readPartitions();
102102

Diff for: src/Partitioning.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ bool Partitioning::eraseMBRSector(BlockDeviceType * blockDevice)
2121
}
2222

2323
bool Partitioning::isPartitionSchemeValid(BlockDeviceType * blockDevice, std::vector<Partition> partitions){
24-
size_t driveSize = blockDevice -> size() / 1024; //
24+
size_t driveSize = blockDevice -> size() / 1024; //
2525
size_t totalSize = 0;
2626

2727
for (size_t i = 1; i < partitions.size() + 1; ++i) {
@@ -72,7 +72,7 @@ bool Partitioning::formatPartition(BlockDeviceType * blockDevice, int partitionN
7272
}
7373

7474
bool Partitioning::createAndFormatPartitions(BlockDeviceType * blockDevice, std::vector<Partition> partitions){
75-
75+
7676
bool success = true; // initialize to true
7777
int lastPartitionEnd = 0;
7878

@@ -117,7 +117,7 @@ bool Partitioning::partitionDrive(BlockDeviceType * blockDevice, std::vector<Par
117117

118118
std::vector<Partition> Partitioning::readPartitions(BlockDeviceType * blockDevice){
119119
std::vector<Partition> partitions;
120-
120+
121121
auto returnCode = blockDevice->init();
122122
if (returnCode) {
123123
Arduino_UnifiedStorage::debugPrint("[Partitioning][readPartitions][ERROR] Unable to read the Block Device.");
@@ -142,9 +142,9 @@ std::vector<Partition> Partitioning::readPartitions(BlockDeviceType * blockDevic
142142

143143
auto table_start_offset = buffer_size - sizeof(mbrTable);
144144
auto table = reinterpret_cast<mbrTable*>(&buffer[table_start_offset]);
145-
145+
146146
if (table->signature[0] != mbrMagicNumbers[0] || table->signature[1] != mbrMagicNumbers[1]) {
147-
147+
148148
Arduino_UnifiedStorage::debugPrint("[Partitioning][readPartitions][INFO] MBR Not Found - Flash Memory doesn't have partitions.");
149149
delete[] buffer;
150150
return partitions;
@@ -156,9 +156,9 @@ std::vector<Partition> Partitioning::readPartitions(BlockDeviceType * blockDevic
156156
Partition partition;
157157

158158
/*This code calculates the size of a partition in kilobytes.
159-
It takes the Logical Block Address (LBA) size of the partition,
159+
It takes the Logical Block Address (LBA) size of the partition,
160160
multiplies it by 4096 (the size of a block in bytes),
161-
and then shifts the result 10 bits to the right to convert it to kilobytes.
161+
and then shifts the result 10 bits to the right to convert it to kilobytes.
162162
*/
163163
partition.size = (entry.lbaSize * 4096) >> 10;
164164

Diff for: src/Utils.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,4 @@
215215

216216

217217

218-
#endif
218+
#endif

0 commit comments

Comments
 (0)