Inkplate-Arduino-library icon indicating copy to clipboard operation
Inkplate-Arduino-library copied to clipboard

Using SPIFFS and Inkplate.h does not work

Open michaelotto opened this issue 4 years ago • 4 comments

If I use Inkplate.h and FS/SPIFFS in the same sketch, like this

#include "Inkplate.h" // Include Inkplate library to the sketch #include "FS.h" #include "SPIFFS.h"

I get a namespace clash error:

../Arduino/libraries/InkplateLibrary/src/include/../libs/SdFat/FatLib/ArduinoFiles.h:122:7: error: redefinition of 'class fs::File'
 class File : public FatFile, public Stream {

How can I use SPIFFS and display related functions in the same sketch?

michaelotto avatar Sep 10 '21 13:09 michaelotto

Can you please provide the code in question?

The bug is probably beacuse there is a class with the same name in the Inkplate library, I'll add a define or something where you can make the compiler ignore it.

nitko12 avatar Sep 22 '21 12:09 nitko12

#include "Inkplate.h"
#include "SPIFFS.h"

void setup() { }
void loop() { }

=>

In file included from ../Library/Arduino15/packages/Croduino_Boards/hardware/Inkplate/1.0.1/libraries/SPIFFS/src/SPIFFS.h:17:0,
                 from ../Documents/Arduino/test/test.ino:2:
../Library/Arduino15/packages/Croduino_Boards/hardware/Inkplate/1.0.1/libraries/FS/src/FS.h:118:11: error: 'File' is already declared in this scope
 using fs::File;

michaelotto avatar Sep 22 '21 16:09 michaelotto

SPIFFS and Inkplate.h are still not useable together. Is this a conflict with the SD library similar to the conversation in this thread?

brandonroots avatar Oct 04 '22 16:10 brandonroots

Found a solution here for the conflict between File class defined in FS.h and SD that does not require any changes to the Inkplate library.

As shared by luc-github there is a define for this to be used before header call in the Arduino sketch: #define FS_NO_GLOBALS #include <FS.h>

then you must add namespace fs for SPIFFS objects like fs::File currentfile = SPIFFS.open("/myfile.txt", "r"); but for SD no need : File textfile = SD.open("/myfile.txt", FILE_READ);

This resolves the conflict

brandonroots avatar Oct 04 '22 21:10 brandonroots

Found a solution here for the conflict between File class defined in FS.h and SD that does not require any changes to the Inkplate library.

As shared by luc-github there is a define for this to be used before header call in the Arduino sketch: #define FS_NO_GLOBALS #include <FS.h>

then you must add namespace fs for SPIFFS objects like fs::File currentfile = SPIFFS.open("/myfile.txt", "r"); but for SD no need : File textfile = SD.open("/myfile.txt", FILE_READ);

This resolves the conflict

Thank you for this! It ended up being the first useful result in my search for an answer to this problem.

TheWebMachine avatar Mar 08 '23 07:03 TheWebMachine

The issue is closed because there is no more activity

KarloLeksic avatar Apr 13 '23 13:04 KarloLeksic