Bodmer / JPEGDecoder

A JPEG decoder library
Other
220 stars 64 forks source link

Using JPEGDecoder with SdFat #45

Closed magkosm closed 4 years ago

magkosm commented 4 years ago

So I am trying to get JPEG Decoder to work with SdFat (either the original or your modified one) and I keep getting errors. Is there something else that I need to do? (besides changing the user_config.h)? Is there maybe a prior version that works with sdfat? I am coding for the Arduino mega 2560. If you need any other information tell me. if I missed something basic forgive me but I am still a noob. :)

for reference the error I get when compiling in platformio. I just compile an empty sketch with the libraries loaded.


#include <Arduino.h>
#include <SdFat.h>
#include <JPEGdecoder.h>

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

this is the output.

.pio\libdeps\megaatmega2560\JPEGDecoder\src\JPEGdecoder.cpp:361:46: error: no matching function for call to 'SdFat::open(c
onst String&, const uint8_t&)'
  File pInFile = SD.open( pFilename, FILE_READ);
                                              ^
In file included from .pio\libdeps\megaatmega2560\SdFat-master/utility/FatLib.h:24:0,
                 from .pio\libdeps\megaatmega2560\SdFat-master/SdFat.h:27,
                 from .pio\libdeps\megaatmega2560\JPEGDecoder\src\JPEGDecoder.h:54,
                 from .pio\libdeps\megaatmega2560\JPEGDecoder\src\JPEGdecoder.cpp:39:
.pio\libdeps\megaatmega2560\SdFat-master/utility/FatFileSystem.h:82:8: note: candidate: File FatFileSystem::open(const cha
r*, uint8_t)
   File open(const char *path, uint8_t mode = FILE_READ) {
        ^
.pio\libdeps\megaatmega2560\SdFat-master/utility/FatFileSystem.h:82:8: note:   no known conversion for argument 1 from 'co
nst String' to 'const char*'
*** [.pio\build\megaatmega2560\libbc9\JPEGDecoder\JPEGDecoder.cpp.o] Error 1

here is the config file

// Comment out the next #defines if you are not using an SD Card to store the JPEGs
// Commenting out the line is NOT essential but will save some FLASH space if
// SD Card access is not needed. Note: use of SdFat is currently untested!

//#define LOAD_SD_LIBRARY // Default SD Card library
#define LOAD_SDFAT_LIBRARY // Use SdFat library instead, so SD Card SPI can be bit bashed

// Note for ESP8266 users:
// If the sketch uses SPIFFS and has included FS.h without defining FS_NO_GLOBALS first
// then the JPEGDecoder library will NOT load the SD or SdFat libraries. Use lines thus
// in your sketch (see the examples included in the JPEGDecoder library):
/*
#define FS_NO_GLOBALS
#include <FS.h>

// You will then need to directly reference the SPIFFS File type thus in the sketch, e.g.:

fs::File jpegFile = SPIFFS.open( filename, "r"); // Example

// This will then allow the default method of using the SD library File type to be used
// in the same sketch, e.g.:

File jpegFile = SD.open( filename, FILE_READ);

*/

// This is all to avoid a redefinition of 'class fs::File' error due to a conflict between the
// duplicate definitions in the SD library and the SPIFFS library.

#ifdef ESP8266
  // Uncomment out the next #define if you want the bytes swapped in the image blocks
    // returned by read().

    // Swapping the bytes is only needed to use the ESP8266 SPI library writePattern()
    // member function and it is better to use readSwappedBytes() instead of read() in
    // the sketch. Images will look psychedelic with wrong colours if the SPI transmit byte
    // order is not right for your sketch!

    // #define SWAP_BYTES // Deprecated, only included for backwards compatibility
#endif
magkosm commented 4 years ago

fixed it

on line 361 I added before the following

char tFilename[15];// char array that will hold filenames pFilename.toCharArray(tFilename,15);

and removed fileread, I hope it will work.

Will keep you posted :)