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._
