From 75ee1887214d20523722385025049881d65d7c8d Mon Sep 17 00:00:00 2001 From: devyte Date: Sun, 28 Oct 2018 18:44:17 -0300 Subject: [PATCH 1/2] Fix arg type in Wire to size_t --- libraries/Wire/Wire.cpp | 2 +- libraries/Wire/Wire.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp index 906b22eedf..7e86894991 100644 --- a/libraries/Wire/Wire.cpp +++ b/libraries/Wire/Wire.cpp @@ -212,7 +212,7 @@ void TwoWire::flush(void){ txBufferLength = 0; } -void TwoWire::onReceiveService(uint8_t* inBytes, int numBytes) +void TwoWire::onReceiveService(uint8_t* inBytes, size_t numBytes) { // don't bother if user hasn't registered a callback if (!user_onReceive) { diff --git a/libraries/Wire/Wire.h b/libraries/Wire/Wire.h index e14b90a521..e697bcca07 100644 --- a/libraries/Wire/Wire.h +++ b/libraries/Wire/Wire.h @@ -47,7 +47,7 @@ class TwoWire : public Stream static void (*user_onRequest)(void); static void (*user_onReceive)(int); static void onRequestService(void); - static void onReceiveService(uint8_t*, int); + static void onReceiveService(uint8_t*, size_t); public: TwoWire(); void begin(int sda, int scl); From 52170ea8cc7ac09bb5f99df66fd3fdf0974b1991 Mon Sep 17 00:00:00 2001 From: devyte Date: Sun, 28 Oct 2018 22:19:48 -0300 Subject: [PATCH 2/2] Document dir.fileSize() and other nearby doc fixes --- doc/filesystem.rst | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/doc/filesystem.rst b/doc/filesystem.rst index 3e6fdeffbf..606a2707d5 100644 --- a/doc/filesystem.rst +++ b/doc/filesystem.rst @@ -278,7 +278,7 @@ Directory object (Dir) ---------------------- The purpose of *Dir* object is to iterate over files inside a directory. -It provides three methods: ``next()``, ``fileName()``, and +It provides the methods: ``next()``, ``fileName()``, ``fileSize()`` , and ``openFile(mode)``. The following example shows how it should be used: @@ -288,21 +288,41 @@ The following example shows how it should be used: Dir dir = SPIFFS.openDir("/data"); while (dir.next()) { Serial.print(dir.fileName()); - File f = dir.openFile("r"); - Serial.println(f.size()); + if(dir.fileSize()) { + File f = dir.openFile("r"); + Serial.println(f.size()); + } } -``dir.next()`` returns true while there are files in the directory to -iterate over. It must be called before calling ``fileName`` and -``openFile`` functions. +next +~~~~ + +Returns true while there are files in the directory to +iterate over. It must be called before calling ``fileName()``, ``fileSize()``, +and ``openFile()`` functions. + +fileName +~~~~~~~~~ + +Returns the name of the current file pointed to +by the internal iterator. + +fileSize +~~~~~~~~ + +Returns the size of the current file pointed to +by the internal iterator. + +openFile +~~~~~~~~ -``openFile`` method takes *mode* argument which has the same meaning as -for ``SPIFFS.open`` function. +This method takes *mode* argument which has the same meaning as +for ``SPIFFS.open()`` function. File object ----------- -``SPIFFS.open`` and ``dir.openFile`` functions return a *File* object. +``SPIFFS.open()`` and ``dir.openFile()`` functions return a *File* object. This object supports all the functions of *Stream*, so you can use ``readBytes``, ``findUntil``, ``parseInt``, ``println``, and all other *Stream* methods.