Hi,
I got a problem in loading image from SD card.
The message showed up while compiling.
Initialising SD card...
Card failed, or not present
Retrying....
But everything works fine in Mega2560 with the same TFT LCD and shield module.
http://www.elecfreaks.com/store/32-tft-lcd-screen-module-tft0132-p-113.html
http://www.elecfreaks.com/store/lcd-tft01-mega-shield-v10-p-214.html
The library I used is UTFT_SdRaw.
And the sketch is modified from the SdRaw_320x240 examples.
Because the limitation of speed in changing frames, I hope to make it work on Due.
#include <SPI.h>
// SdFat lib from here :-
// https://github.com/greiman/SdFat/archive/master.zip
#include <SdFat.h>
//#include <SdStream.h>
#include <UTFT.h>
#include <UTouch.h>
#include <UTFT_Buttons.h>
#include <UTFT_SdRaw.h>
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
#define SD_CHIP_SELECT 53 // SD chip select pin
// file system object
SdFat sd;
// print stream
ArduinoOutStream cout(Serial);
int wait = 2, pressed_button;
// Initialize display
// ------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield : <display model>,19,18,17,16
// Standard Arduino Mega/Due shield : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Due : <display model>,25,26,27,28
// Teensy 3.x TFT Test Board : <display model>,23,22, 3, 4
// ElecHouse TFT LCD/SD Shield for Arduino Due : <display model>,22,23,31,33
//
// Remember to change the model parameter to suit your display module!
UTFT myGLCD(SSD1289, 38, 39, 40, 41);
// Initialize touchscreen
// ----------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield : 15,10,14, 9, 8
// Standard Arduino Mega/Due shield : 6, 5, 4, 3, 2
// CTE TFT LCD/SD Shield for Arduino Due : 6, 5, 4, 3, 2
// CTE TFT LCD/SD Shield for Arduino Due (JP10): 6, 5,32, 3, 2
// Teensy 3.x TFT Test Board : 26,31,27,28,29
// ElecHouse TFT LCD/SD Shield for Arduino Due : 25,26,27,29,30
//
//UTouch myTouch( 6, 5, 32, 3, 2);
UTouch myTouch( 6, 5, 4, 3, 2);
UTFT_SdRaw myFiles(&myGLCD);
UTFT_Buttons myButtons(&myGLCD, &myTouch);
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println(F("Initialising SD card..."));
bool mysd = 0;
// see if the card is present and can be initialized:
while (!mysd)
{
if (!sd.begin(SD_CHIP_SELECT, SPI_SIXTEENTH_SPEED)) {//SPI_FULL_SPEED
Serial.println(F("Card failed, or not present"));
Serial.println(F("Retrying...."));
}
else
{
mysd = 1;
Serial.println(F("Card initialised."));
}
}
Serial.println(F("Initialising LCD."));
myGLCD.InitLCD();
myGLCD.clrScr();
myGLCD.setFont(SmallFont);
myTouch.InitTouch();
myTouch.setPrecision(PREC_MEDIUM);
myButtons.setTextFont(BigFont);
int butskip = myButtons.addButton( 85, 219 , 70, 20, "Skip");
Serial.println(F("LCD initialised."));
// ////////////////////////////////////////////////////////////////////////////////
// Wait for GPS screen or skip button
///////////////////////////////////////////////////////////////////////////////////
Serial.println(F("Initialising LCD."));
myGLCD.InitLCD();
myGLCD.clrScr();
myGLCD.setFont(SmallFont);
myTouch.InitTouch(LANDSCAPE);
myTouch.setPrecision(PREC_MEDIUM);
myButtons.setTextFont(BigFont);
//int butskip = myButtons.addButton( 130, 100 , 70, 20, "Show");
Serial.println(F("LCD initialised."));
}
void loop()
{
char fname240[] = "SK45/fish.RAW";
myGLCD.clrScr();
myFiles.load(0, 0, 320, 240, fname240, 1);
delay(5000);
char fname320[] = "SK45/scene.RAW";
myFiles.load(0, 0, 320, 240, fname320, 1);
delay(5000);
}
Any command is appreciated.
Gary