Skip to content

Commit

Permalink
IDFv4 logic for f.setBufferSize()
Browse files Browse the repository at this point in the history
  • Loading branch information
troyhacks committed Jan 23, 2025
1 parent 46a2bed commit a244910
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion wled00/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ static bool bufferedFind(const char *target, bool fromStart = true) {

size_t index = 0;
byte buf[FS_BUFSIZE];
#if ESP_IDF_VERSION_MAJOR >= 4
f.setBufferSize(FS_BUFSIZE);
#endif
if (fromStart) f.seek(0);

while (f.position() < f.size() -1) {
Expand Down Expand Up @@ -108,7 +110,9 @@ static bool bufferedFindSpace(size_t targetLen, bool fromStart = true) {

size_t index = 0; // better to use size_t instead if uint16_t
byte buf[FS_BUFSIZE];
#if ESP_IDF_VERSION_MAJOR >= 4
f.setBufferSize(FS_BUFSIZE);
#endif
if (fromStart) f.seek(0);

while (f.position() < f.size() -1) {
Expand Down Expand Up @@ -152,8 +156,9 @@ static bool bufferedFindObjectEnd() {
uint16_t objDepth = 0; //num of '{' minus num of '}'. return once 0
//size_t start = f.position();
byte buf[FS_BUFSIZE];
#if ESP_IDF_VERSION_MAJOR >= 4
f.setBufferSize(FS_BUFSIZE);

#endif
while (f.position() < f.size() -1) {
size_t bufsize = f.read(buf, FS_BUFSIZE); // better to use size_t instead of uint16_t
size_t count = 0;
Expand All @@ -178,7 +183,9 @@ static void writeSpace(size_t l)
{
byte buf[FS_BUFSIZE];
memset(buf, ' ', FS_BUFSIZE);
#if ESP_IDF_VERSION_MAJOR >= 4
f.setBufferSize(FS_BUFSIZE);
#endif
while (l > 0) {
size_t block = (l>FS_BUFSIZE) ? FS_BUFSIZE : l;
f.write(buf, block);
Expand Down

0 comments on commit a244910

Please sign in to comment.