Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using SPIFFS and Inkplate.h does not work #100

Closed
michaelotto opened this issue Sep 10, 2021 · 6 comments
Closed

Using SPIFFS and Inkplate.h does not work #100

michaelotto opened this issue Sep 10, 2021 · 6 comments

Comments

@michaelotto
Copy link

michaelotto commented Sep 10, 2021

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?

@nitko12
Copy link
Member

nitko12 commented Sep 22, 2021

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.

@michaelotto
Copy link
Author

michaelotto commented Sep 22, 2021

#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;

@brandonroots
Copy link

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
Copy link

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

@TheWebMachine
Copy link

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.

@KarloLeksic
Copy link
Contributor

The issue is closed because there is no more activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants