SD.h SdFat.h UTFT_SdRaw.h - can they co-exist, multiple compile errors

Hi,

HW = mega, CTE shield, CTE 480x272 TFT (device is ‘CPLD’)

Could someone please help on these multiple compile errors ?

Using the example UTFT_ViewFont as a basis for my code I have successfully opened a .txt file on the SD card and can display text on the TFT.

then …

Using the example SdRaw_320x240 as a basis for my code I have successfully opened a .RAW file on the SD card and can display an image on the TFT of size 480x272.

I then wanted to use an image as a backdrop on the TFT and then display the text over it.

I used my ViewFont code as my start and started to paste the code I needed from SdRaw_320x240.

What I am trying to do is to run myFiles.pan in UTFT_ViewFont, but get multiple compile errors which are not helpful (to me)… and whatever I try to do I get a whole different set of compile errors

#include <SdFat.h>
#include <UTFT.h>
#include <SPI.h>
#include <SD.h>
#include <UTouch.h>
#include <UTFT_Buttons.h>
#include <UTFT_SdRaw.h>
.

UTFT myGLCD(CPLD,38,39,40,41);
.
UTFT_SdRaw myFiles(&myGLCD);

.
myFiles.pan(0, 0, 480, 272, 0, 0, 480, 272, "myfilename.RAW", 0);

here is the compile output…

Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

In file included from CTE_Verse_V11.ino:41:0:
C:\Program Files (x86)\Arduino\libraries\SD\src/SD.h:26:7: error: redefinition of 'class File'
 class File : public Stream {
       ^
In file included from C:\...\Arduino\libraries\SdFat/utility/FatLib.h:22:0,
                 from C:\...\Arduino\libraries\SdFat/SdFat.h:27,
                 from CTE_Verse_V11.ino:38:
C:\...\Arduino\libraries\SdFat/utility/ArduinoFiles.h:118:7: error: previous definition of 'class File'
 class File : public FatFile, public Stream {
       ^
In file included from CTE_Verse_V11.ino:41:0:
C:\Program Files (x86)\Arduino\libraries\SD\src/SD.h:60:3: error: 'SdVolume' does not name a type
   SdVolume volume;
   ^
C:\Program Files (x86)\Arduino\libraries\SD\src/SD.h:68:33: error: 'SD_CHIP_SELECT_PIN' was not declared in this scope
   boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN);
                                 ^
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Can SD.h , SdFat.h with UTFT_SdRaw.h libraries co-exist is same sketch? … Thanks…

Do not include SD.h because SdFat.h is doing exactly the same thing.

Hi c0rsair,

Thanks… please bear with me (newbie)… so I uncommented SD.h

#include <SdFat.h>
#include <UTFT.h>
#include <SPI.h>
//#include <SD.h>
#include <UTouch.h>
#include <UTFT_Buttons.h>
#include <UTFT_SdRaw.h>

but compile complained about

     if (!SD.begin(SD_CS)) {  

and  

 myFile = SD.open(chapName);

So I changed them to …

     if (!SdFat.begin(SD_CS)) {  

and  

 myFile = SdFat.open(chapName);

and compile errors are now, for the SdFat.open statement…

Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

CTE_Verse_V12.ino: In function 'void setup()':
CTE_Verse_V12:119: error: expected primary-expression before '.' token
CTE_Verse_V12.ino: In function 'void scrollChap(char*)':
CTE_Verse_V12:152: error: expected primary-expression before '.' token
expected primary-expression before '.' token

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

The code has to be like this:

#include <SdFat.h>

//stuff here

#define SD_CHIP_SELECT  42 //set the sd pin here
SdFat sd;

//then you change the other things

if (!sd.begin(SD_CHIP_SELECT)) { 

and 

 myFile = sd.open(chapName);

Hi again,

/////// Edited this post .... 20 mins after first posting it ///////

Thanks for your clear instructions... NO compile errors :) :) :) now. I had tried so many things before I did not notice I had 'SdFat sd' commented out and your tips e.g. SD >> sd did the trick !!!!!

So all working now , .. but....

I can display text on to the image but the 'set background color' wipes out most of the image, so where I have a full screen of text the image is lost.

I need a 'set background color' to transparent. But my searches seem to imply that is not possible.

Thank you though !!!!!!

Hi cblx5,

Why on earth use UTFT_SdRaw.pan when you are displaying the entire image??

pan was designed to show a small portion of a larger image… I would suggest just using UTFT_SdRaw.load as it will be faster!!

eg:

myFiles.load(0, 0, 480, 272, "myfilename.RAW", 2, 0);

cblx5:
I need a ‘set background color’ to transparent. But my searches seem to imply that is not possible.

Perhaps you should read the documentation for UTFT? It is possible and works well.

Like this?!

100_0793a.jpg

Regards,

Graham

Hi,

All solved by GHL so, just closing of this post ...... for people with same issue...

see continuation here

https://forum.arduino.cc/index.php?topic=368335.0

Thanks