Go Down

Topic: Load an image file from a SD card on a 7 inch LCD/TFT (Read 227 times) previous topic - next topic

t_lake

Hello all,
I have got a problem with my 7 inch TFT. I only want to load an image file from the SD card, but it doesn`t work. Has someone an example programm code? I need it for a Projekt at school.
My hardware:
- Arduino Mega 2560
-CTE TFT LCD/SD Shield
-7 inch Sainsamart TFT/LCD Display

Thanks for your help ;-)

AWOL

Quote
but it doesn`t work

What is the "it" that does not work?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

t_lake

The drawing on the TFT doesn´t work. The serial monitor shows this:
Initializing SD card...OK!
File size: 6966
Image Offset: 54
Header size: 40
Bit Depth: 24
Image size: 48x48
drawing image


AWOL

Oh. OK.
If you want to show your code and a schematic, debug output. . .  you know, anything that might help us help you, feel free to do so.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

t_lake

Ok;-). Here is my code.
Code: [Select]
// include the necessary libraries
#include <SPI.h>
#include <SD.h>
#include <TFT.h>  // Arduino LCD library

// pin definition for the MEGA

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

TFT TFTscreen = TFT(sd_cs, sd_in, sd_clk);

// this variable represents the image to be drawn on screen
PImage logo;


void setup() {
  // initialize the GLCD and show a message
  // asking the user to open the serial line
  TFTscreen.begin();
  TFTscreen.background(255, 255, 255);

  TFTscreen.stroke(0, 0, 255);
  TFTscreen.println();
  TFTscreen.println("Arduino TFT Bitmap Example");
  TFTscreen.stroke(0, 0, 0);
  TFTscreen.println("Open serial monitor");
  TFTscreen.println("to run the sketch");

  // initialize the serial port: it will be used to
  // print some diagnostic info 
  Serial.begin(9600);
  while (!Serial) {
    // wait for serial line to be ready
  }

  // clear the GLCD screen before starting
  TFTscreen.background(255, 255, 255);
 
  // try to access the SD card. If that fails (e.g.
  // no card present), the setup process will stop.
  Serial.print("Initializing SD card...");
  if (!SD.begin(sd_cs)) {
    Serial.println("failed!");
    return;
  }
  Serial.println("OK!");
 
  // initialize and clear the GLCD screen
  TFTscreen.begin();
  TFTscreen.background(255, 255, 255);

  // now that the SD card can be access, try to load the
  // image file.
  logo = TFTscreen.loadImage("arduino.bmp");
  if (!logo.isValid()) {
    Serial.println("error while loading arduino.bmp");
  }
}

void loop() {
  // don't do anything if the image wasn't loaded correctly.
  if (logo.isValid() == false) {
    return;
  }
 
  Serial.println("drawing image");

  // get a random location where to draw the image.
  // To avoid the image to be draw outside the screen,
  // take into account the image size.
  int x = random(TFTscreen.width() - logo.width());
  int y = random(TFTscreen.height() - logo.height());

  // draw the image to the screen
  TFTscreen.image(logo, x, y);

  // wait a little bit before drawing again
  delay(1500);
}



ghlawrence2000

You say Sainsmart 7" TFT as though that adequately describes what you have, however there are TWO different 7" TFT displays from several vendors, not just Sainsmart, neither of which will work with the built in Arduino TFT library.

You need Henning Karlsen UTFT suit of libraries UTFT

Then you need to figure out which of those displays you have.

Regards,

Graham

RaphaelAmin

I have the SainSmart 7" TFT LCD without CPLD. And I think the SainSmart shield is compatible with CTE because I use CTE70 on the LCD initialization program.
You have to use Henning Karslen library indeed, as Graham already said.

t_lake

I have the CTE70 Display. now i use the UTFT lib but it does not work... Has someone of you a running program for the CTE70? I only want to load an image on the Display. It sounds very easy, but it isn´t :smiley-sad: ...

ghlawrence2000

You are not trying very hard to help us to help you! What shield are you using? The Sainsmart CTE DUE TFT Shield? If so, did you edit the "UTFT\hardware\arm\HW_ARM_defines.h" file?

You simply say
Quote
I have the CTE70 Display. now i use the UTFT lib but it does not work...
yes it does, did you read the PDF files in UTFT folder? Have you got the UTFT/Example
Quote
Arduino (Arm)/UTFT_Demo_800x480
working?

You need to do some research and experimenting of your own, and give relevant  / concise information about what is not working and/or what you have already tried otherwise this is going to take an unnecessary number of posts to help you!

Regards,

Graham

t_lake

Hey.
You are right. My answeres were not so informative. I´m sorry.

I use the SainSmart MEGA2560(R3) 7'' LCD Extend TFT Shield for Arduino.
I´ve tested the Demo and it is working. I also downloaded the UTFT_tinyFAT.h. there is an example to load an image file from the sd card. I convert my image to a raw file and copy it on my FAT16 formatted sd card. The program said. "file not found"...

Regards, Tobi

ghlawrence2000

Hi Tobi,

Ok, where did you get your version of UTFT_tinyFAT? Is it the release version on the Henning Karlsen site?

Have you tried the tinyFAT 'All_In_One_Demo' ?

Have you done any other tests on the files on your SD card? What I mean, is the SD card initialising ok?

You are aware of the filename limitations of 8.3 filenames? (eg filename.raw)

tinyFAT does not support folders, all your files will need to be in the 'ROOT' folder.

What size is your SD card? tinyFAT has a 2GB limitation.

I personally gave up on tinyFAT because ultimately it does not work on the DUE, but also because there were too many limitations. My approach was to use SdFATlib and modify UTFT_tinyFAT to use that instead, this allows large SD cards and folders. Maybe this is a possible solution for you, although I think you should try to figure out why your current setup is not working first!

Regards,

Graham

Go Up