Trouble loading image files from the SD to disaply on UTFT

I am trying to get image files to show on a TFT display I am using a SainSmart arduino MEGA 2560 with a 4.3" TFT display and display shield. The setup is this one...

http://www.sainsmart.com/sainsmart-due-4-3-lcd-touch-panel-sd-card-slot-shield-kit-for-arduino.html

I am using the libraries etc from Henning Karlsen. I am able to get the UTFT library demo sketch, button, test sketch, and calibration sketch to run fine but when I run the UTFTtinyFAT library Demo_Landscape sketch for reading files off of the SD card, It displays:

File not found...
name of file not found

The display is a 800x480 and should be returning the images from this line:
char* files800[]={"150MM.RAW", "200MM.RAW", "NO.RAW", "YES.RAW", "PIC101.RAW", "", "", "", "", ""}; // 800x480

it seems to function correctly it just doesn't find the actual image files.

There is an SD card slot on the TFT display and one on the Display shield, I have tried using both but neither work. I am using a 2GB SD card formatted for FAT16. The image files are on the SD card root area ( No folders) The sketch is as follows

// Demo_Landscape (C)2013 Henning Karlsen
// web: Electronics - Henning Karlsen
//
// This program is a demo of the loadBitmap()-function.
//
// This program requires UTFT_tinyFAT, UTFT v2.41 or higher,
// as well as tinyFAT v3.0 or higher.
//
// The image files must be present in the root folder
// of a FAT16 formatted SDcard in the module cardslot.
//
// Please note that this demo only supports the following
// display sizes:
// 220x176
// 320x240
// 400x240
// 480x272
// 800x480
#include <SPI.h>
#include <tinyFAT.h>
#include <UTFT.h>
#include <UTFT_tinyFAT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];

#define sd_cs 53
#define sd_in 50
#define sd_out 51
#define sd_clk 52

UTFT myGLCD(TFT01_50, 38, 39, 40, 41); // Remember to change the model parameter to suit your display module!
UTFT_tinyFAT myFiles(&myGLCD);

// List of filenames for pictures to display.
char* files320[]={"PIC301.RAW", "PIC302.RAW", "PIC303.RAW", "PIC304.RAW", "PIC305.RAW", "PIC306.RAW", "PIC307.RAW", "PIC308.RAW", "PIC309.RAW", "PIC310.RAW"}; // 320x240
char* files400[]={"PIC401.RAW", "PIC402.RAW", "PIC403.RAW", "PIC404.RAW", "PIC405.RAW", "PIC406.RAW", "PIC407.RAW", "PIC408.RAW", "PIC409.RAW", "PIC410.RAW"}; // 400x240
char* files220[]={"PIC601.RAW", "PIC602.RAW", "PIC603.RAW", "PIC604.RAW", "PIC605.RAW", "PIC606.RAW", "PIC607.RAW", "PIC608.RAW", "PIC609.RAW", "PIC610.RAW"}; // 220x176
char* files480[]={"PIC701.RAW", "PIC702.RAW", "PIC703.RAW", "PIC704.RAW", "PIC705.RAW", "", "", "", "", ""}; // 480x272
char* files800[]={"150MM.RAW", "200MM.RAW", "NO.RAW", "YES.RAW", "PIC101.RAW", "", "", "", "", ""}; // 800x480
char* files[10];

int picsize_x, picsize_y;
boolean display_rendertime=false; // Set this to true if you want the rendertime to be displayed after a picture is loaded
boolean display_filename=true; // Set this to false to disable showing of filename

word res;
long sm, em;

void setup()
{
myGLCD.InitLCD();
myGLCD.clrScr();
file.initFAT();
myGLCD.setColor(255,255,255);
myGLCD.setFont(SmallFont);
picsize_x=myGLCD.getDisplayXSize();
picsize_y=myGLCD.getDisplayYSize();
switch (picsize_x)
{
case 220:
for (int z=0; z<sizeof(files220)/sizeof(*files220);z++)
files[z] = files220[z];
break;
case 320:
for (int z=0; z<sizeof(files320)/sizeof(*files320);z++)
files[z] = files320[z];
break;
case 400:
for (int z=0; z<sizeof(files400)/sizeof(*files400);z++)
files[z] = files400[z];
break;
case 480:
for (int z=0; z<sizeof(files480)/sizeof(*files480);z++)
files[z] = files480[z];
break;
case 800:
for (int z=0; z<sizeof(files800)/sizeof(*files800);z++)
files[z] = files800[z];
break;
}
}

void loop()
{

for (int i=0; i<(sizeof(files)/sizeof(files)); i++)
{
if (files
!="")*

  • {*
  • sm=millis();*
    res=myFiles.loadBitmap(0, 0, picsize_x, picsize_y, files*);
    _
    em=millis();_
    _
    if (res!=0)_
    _
    {_
    _
    if (res==0x10)_
    _
    {_
    _
    myGLCD.print("File not found...", 0, 0);_
    _ myGLCD.print(files, 0, 14);
    }
    else*
    * {
    myGLCD.print("ERROR: ", 0, 0);
    myGLCD.printNumI(res, 56, 0);
    }
    delay(3000);
    myGLCD.clrScr();
    }
    else*
    * {_
    if (display_rendertime==true)
    _ {
    myGLCD.print("Rendertime (secs):", 0, 0);
    myGLCD.printNumF(float((em-sm)/1000.0), 2, 160,0);
    }_
    if (display_filename==true)
    _ {
    myGLCD.print(files, CENTER, myGLCD.getDisplayYSize()-12);
    }
    delay(3000);
    }
    }
    }
    }*

    Eventually I plan to use these images as buttons but I can't seem to read from the SD card._

tinyFAT is not that flexible, so many limitations. You would be better off using SdFat and UTFT_SdRaw. No more SD cards < 2GB, no more FAT16. You can use FAT32, any size card you wish, and as many folders as you wish. :wink:

Best wishes,

Graham

Since you wrote it, maybe you can tell me where to get it? I would willing to try it out and see if it can do these things.

http://forum.arduino.cc/index.php?topic=294264.msg2055085#msg2055085

That thread has all the info you need.

Message one of the threads if you have any questions.

Leave me karma if you like my library ;D Thanks.

Regards,

Graham

Corporate firewall isn't cooperating. Guess I will try tonight and bring it in

how can I help? email.... attach as zip??

Give me a clue?

G

You have PM

Thanks

Email sent.

Hope it does what you want.

Any questions, post to one of the threads I have posted to.

Best wishes,

Graham

I received your email, thank you , sir.

I extracted and installed the SdFat and UTFT_SdRaw libraries and tried to run the example sketch called SdRaw_800x480. It compiled and loaded fine but the screen just stays blank white, nothing happens.

My Pin settings are th eonly hting that IO changed from the example sketch:

UTFT myGLCD(TFT01_50, 38, 39, 40, 41);

UTouch myTouch( 6, 5, 4, 3, 2);

Which are the same as when I use the UTFT_Touch Button test example that works perfectly

This did not function at all...perhaps my hardware configuration is not compatible with your library?

What output are you getting on the serial monitor?

Regards,

Graham

PS. If you used the AVR example the pin settings were correct for TFT and Touch! The ONLY change needed was the display type...... If you used the ARM example, that will definitely NOT work on the MEGA, since the main speed increase is derived from huge amounts of extra SRAM!! Other than that, I can categorically state, my library works well with the MEGA and all UTFT compatible displays!

Your question: What output are you getting on the serial monitor?

Do you mean the UTFT Touch display? All of the pixels are white and stay that way, nothing changes.

I did do this using the AVR example. I tried ARM as well just to see if I could make it work but nothing different.

I am using the same Pin settings as the example... 38, 39, 40, 41. The only thing I changed was the display type which I changed to TFT01_50. I know this display type is correct all of the UTFT and UTouch examples work well with that settings.

cmrion:
Your question: What output are you getting on the serial monitor?

Do you mean the UTFT Touch display?

If I had meant what do you see on the UTFT Touch display, I would have asked what do you see on the display. As it is, I asked what you see on the serial monitor, and that is what I meant!

If you are not aware what the serial monitor is or what it does, then you have got way too far ahead of yourself by trying to draw pictures when 'blink' is probably more your skill level at the moment.

When you can let me know what you see in serial monitor, I may have more to offer in terms of wisdom and assistance with your problem!

Regards,

Graham

"If I had meant what do you see on the UTFT Touch display, I would have asked what do you see on the display. As it is, I asked what you see on the serial monitor, and that is what I meant!"

~ Thanks for clarifying without completely slam dunking me

"If you are not aware what the serial monitor is or what it does, then you have got way too far ahead of yourself by trying to draw pictures when 'blink' is probably more your skill level at the moment."

~ Yes, I am extremely new at this but I am beyond "blink". I learn quickly and in big chunks. I am still learning arrays and writing to tables etc...I am drawing rectangular buttons and attaching touch functionality to them. I am not a techno dope. At my regular job I am a particle accelerator engineer but I deal mostly with equipment systems and processes. Software is new(ish) to me. Learning the software aspects will help me use my professional knowledge in my home and hobby activities. I guess that I am trying to say thank you for your help, I appreciate technical knowledge and those willing to share it. I also appreciate the lack of desire to spoon feed beginners. I will pull my weight in trying not to ask dumb questions and be uninformed. I knew there was a way to do what the serial monitor does, I just didn't know how to do it yet or what it was called. Now I do...thanks for putting me on track.

"When you can let me know what you see in serial monitor, I may have more to offer in terms of wisdom and assistance with your problem!"

The serial monitor is going through the loop of

Initialising SD card...
Card failed, or not present
Retrying....

I am using a 2GB SD card, it has .raw files on it only (from your library). They are in the root.
I have formatted the card and attempted this with both FAT16 and FAT32 formats
I have a TFT monitor with a shield controller, both have SD card slots on them, I have attempted this sketch with the card in both of the slots. results are the same every time.

Chris

Ok, we are getting somewhere now :smiley:

So you see from the serial monitor, your SD card is NOT initialising. This could easily be the same problem with tinyFat etc.

I have a genuine CTE TFT shield, and NOT a Sainsmart clone (which is more expensive and less reliable by the way), and from the documentation JP9 is enabled by default, which would enable the SD card, but from the pictures shown on the Sainsmart site..... JP9 is NOT enabled..... Recommendation.... Take your soldering iron and stick a blob of solder on JP9/8 or whatever it is labeled on your copy..... See image attached!

Once you can be certain there is a blob of solder where I have indicated, we can proceed from there.

Regards,

Graham

JP9 was labeled SD enable. It was open. I soldered it closed. Still have the same error. with card in either SD slot. I will try a different card next.

Have you tried 'sdinfo' the SDfat example sketch...... It is very good at helping with these issues........ also, have you changed your SD chip select pin to 53?

That's pretty much all I have to suggest now you soldered that jumper.

Regards,

Graham

Hi Graham.
This thread - and the other, you told about - was absolut helpfull for me. And 'first of all' it works very well.
Here my own constellation from today : MEGA2560 (clon), TFT/SD-Shield for MEGA V2.2, 7"-TFT-TouchScreen, with MD070SD Chip (SaintSmart CP11015).
I told it for everyone who also had problems with starting this combination. So perhaps I can help too with my little experience.
Regards
Bodo

I have same problem, but with UTFT display ILI9486. At my case arduino does not see SD card.

Code of program:

#include <SPI.h>
#include <SdFat.h>
#include <UTFT.h>
#include <UTFT_SdRaw.h>

#define SD_CHIP_SELECT 53

SdFat sd;

UTFT myGLCD(ILI9486, 38, 39, 40, 41);

extern uint8_t BigFont[];

UTFT_SdRaw myFiles(&myGLCD);

void setup()
{

myGLCD.InitLCD();
myGLCD.clrScr();
myGLCD.setFont(BigFont);
while (!sd.begin(SD_CHIP_SELECT)) {
myGLCD.setColor(VGA_RED);

myGLCD.print("SD Card failed!", CENTER, 100);
delay(1000);
}

myGLCD.setColor(VGA_GREEN);
myGLCD.print("SD Card initialised", CENTER, 100);

delay(1000);

myFiles.load(0, 0, 480, 320, "Arduino.RAW");
}

void loop()
{
}

Hello Graham,

thanks for your amazing work! i already give you one more karma! lol

I have succeed to run your exemple UTFT_SDRaw but it only work with the sd on the CTE Shield, after soldering JP8.

I try everything i could but it doesnt work with the sdcard on the TFT reader...

Is someone know how to solve it?

The reader on the CTE is not simple to access...need to remove the TFT each time...not good.

Thanks for your help!

Olivier

Hello,

i found an issue...its just the SPI speed...i put SPI_HALF_SPEED and now it works...here are the time comparaison :

With SPI_FULL_SPEED : on board CTE card reader :
Time to draw 240x240 raw (no extra buffer) (non inverted colour) 234 ms
Time to draw 240x240 raw (16*buffer) (inverted colour) 142 ms
Time to draw 240x240 portion from 4040x4040 raw image (non inverted colour) 376 ms
Time to draw 240x240 portion from 4040x4040 raw image (inverted colour) 376 ms
Time to draw 35 42x42 icons (0-34) from 2374x696 image 1132 ms
Time to draw 35 42x42 icons (35-69) from 2374x696 image 1126 ms
Time to draw 35 42x42 icons (70-104) from 2374x696 image 1130 ms
Time to draw 35 42x42 icons (105-139) from 2374x696 image 1127 ms
Time to draw 35 42x42 icons (140-174) from 2374x696 image 1131 ms
Time to draw 35 42x42 icons (175-209) from 2374x696 image 1132 ms

With SPI_HALF_SPEED : on board TFT card reader :

Time to draw 240x240 raw (no extra buffer) (non inverted colour) 257 ms
Time to draw 240x240 raw (16*buffer) (inverted colour) 165 ms
Time to draw 240x240 portion from 4040x4040 raw image (non inverted colour) 424 ms
Time to draw 240x240 portion from 4040x4040 raw image (inverted colour) 424 ms
Time to draw 35 42x42 icons (0-34) from 2374x696 image 1306 ms
Time to draw 35 42x42 icons (35-69) from 2374x696 image 1300 ms
Time to draw 35 42x42 icons (70-104) from 2374x696 image 1305 ms
Time to draw 35 42x42 icons (105-139) from 2374x696 image 1302 ms
Time to draw 35 42x42 icons (140-174) from 2374x696 image 1306 ms
Time to draw 35 42x42 icons (175-209) from 2374x696 image 1306 ms

As you can see, there is not a lot of difference...looks like a bit faster in SPI_FULL_SPEED...but when i look to the time to draw...just 12% average faster...

Hope it will help others with trouble shooting SPI_HALF/FULL_SPEED :slight_smile: