Before too many folks go reaching for their soldering irons to fix 'badly built and untested hardware from Sainsmart', may I share my experiences with you...
I ordered a full Sainsmart setup ( Mega 2560, Adjustable TFT/Touch/SD, 3.2" TFT ) from ebay 23rd October from 'Sainsmart China'. It arrived Nov 1st which was pretty impressive to be honest, and all of this cost £30 to my door. The same setup from 'Sainsmart UK' was £45.
I made the initial oversight of forgetting to order an SD card to go with my new toys.
I am an electronics engineer by trade, but have no experience at all of Arduino hardware or how to program it, although I have previously played with PICs, and have limited/medium experience with C. Basically everything is a learning curve and new to me, that was the basis of my experience so far.
'In for a penny, in for a pound', I searched google, arduino display jpegs. It didnt take long to find henningkarlson. Got the wonderful utft, tinyfat, utft-tinyfat libries and bobs your uncle.
I had borrowed a Transcend 1GB SD card.........copied the test images to it and tried the utft-tinyfat "Demo Landscape" example........ no joy. MUCH reading later........ changed the pin definitions to match the Mega, lo and behold it worked...... I was dead chuffed. So I ordered a 8GB SDHC card again from China.
All I had read told me 4GB was the maximum although untested that tinyfat can handle, so partitioned and formatted 4GB to Fat16 and copied the images once again. My previously working sketch refused to work. Re-partitioned to 2GB still no luck, 1GB, no luck.....I was getting annoyed but took out my trusty multimeter and tested the signal paths as prescribed earlier in this thread. I can categorically state that my V1.0 mega shield pin outs are correct.....
53 - 38 CS
51 - 37 MOSI
52 - 36 SCK
50 - 35 MISO
Maybe we can deduce from this there is multiple 'V1.0' hardwares?
But the point is if I had not already seen it working with my own eyes, maybe I would have been reaching for the soldering iron myself!!
There is more to this than meets the eye!!
So I started populating the sketch with loads of 'Serial.println(xx)' .....This revealed almost nothing....No error codes!!! BUT the SD library 'Cardinfo' example listed the files perfectly......
I started combining SD and tinyfat..... Suddenly it worked......I have no satisfactory explanation for this and no happy ending.....I intend getting in touch with henning to persue this further...... But the code I have that works is shown :-
#include <tinyFAT.h>
#include <UTFT.h>
#include <UTFT_tinyFAT.h>
#include <SD.h>
File root;
// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 53;
// Declare which fonts we will be using
extern uint8_t SmallFont[];
UTFTtf myGLCD(ITDB32S, 38, 39, 40, 41); // Remember to change the model parameter to suit your display module!
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=false; // Set this to false to disable showing of filename
word res;
long sm, em;
void setup()
{
myGLCD.InitLCD();
myGLCD.clrScr();
// pinMode(SS, OUTPUT);
if (!SD.begin(chipSelect)) {
return;
}
res=file.initFAT();
myGLCD.setColor(255,255,255);
myGLCD.setFont(SmallFont);
picsize_x=myGLCD.getDisplayXSize();
picsize_y=myGLCD.getDisplayYSize();
res=myGLCD.loadBitmap(0, 0, 320, 240, "splash.raw");
delay(5000);
myGLCD.clrScr();
}
void loop()
{
}
BUT.......If you remove these lines.......
#include <SD.h>
File root;
// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 53;
if (!SD.begin(chipSelect)) {
return;
}
The sketch refuses to work?????
I didnt have any of this trouble with the 1GB Transcend SD card, if anybody has any explanations I would love to hear them!!
Sorry this is long winded but I wanted to give as much information as possible.
Regards,
Graham.