7in LCD with Mega 2560 and CTE Shield

I'm fairly new to this and need your guidance to get started.

Here's my hardware list:

  1. Arduino Mega 2560
  2. 7.0" TFT LCD module Font IC 800x480 SSD1963
  3. CTE TFT/SD Shield for Arduino MEGA 2560

Here's what I did:

  1. Downloaded UTFT henning library from here Electronics - Henning Karlsen
  2. used the sketch UTFT_Demo_800x480.ino
  3. uncomment "#define CTE_DUE_SHIELD 1" in the HW_ARM_defines.h in the \hardware\arm folder of the UTFT library
  4. changed the pinout to : UTFT myGLCD(CPLD,25,26,27,28);
  5. provided external power supply to Arduino Mega 2560 (tried 12v DCC and USB)

The screen lights up but only shows the below. What am I doing wrong?

Cheers,

GFreak123:
4) changed the pinout to : UTFT myGLCD(CPLD,25,26,27,28);

Should be :-

UTFT myGLCD(CTE70,25,26,27,28);

Regards,

Graham

EDIT: PS, when you get around to wanting to draw pictures from SD at a reasonable speed, I have something in the pipeline :wink:

Music to my ears! Let me try that and revert back.

Should I be using Arduino 1.0.6 or 1.5.8 Beta?

ghlawrence2000:
Should be :-

UTFT myGLCD(CTE70,25,26,27,28);

That didn't work mate. Screen still blank as shown in first pic.

OPS.......... :stuck_out_tongue:

Sorry!

Correction, should be :-

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

Should you be using 1.0.6 or 1.5.8? Well, depends if you have problems getting touch to work, 1.0.6 seems to be more reliable with the MEGA....

Best wishes,

Graham

You my friend, are a genius! Thank you very much :slight_smile:

Works like a charm!

ghlawrence2000:
EDIT: PS, when you get around to wanting to draw pictures from SD at a reasonable speed, I have something in the pipeline :wink:

Hey Graham,

I am trying to draw from a FAT32 SD Card, can you please help? I don't think Henning Karlsen's libraries support FAT32 and >2GB. Thanks for your help.

Happy New Year!

Yes, you are right, it does not. It doesn't support folders either...

ftp://ghlawrence.myftp.org:2121

That is my library so far. I am just in the process of making it ready for 'release', with examples and instructions and everything..... So far it is lacking the instructions.... and the examples won't work without the image files.....

Any problems, let me know via PM since email notifications are STILL not working :frowning:

Regards,

Graham

Ok I'm getting somewhere! Can the SD card also read BMP? Or does it have to be a RAW File?

Anyway I could improve the RAW File Resolution?

.raw only, but you can use the command line version of Henning's convert tool if you have LOTS of BMP's you need to convert :wink:

Improve resolution? What do you mean? I have 2 displays, 800480 and 320240, all the images I have displayed look ok?

Regards,

Graham

Sorry I misused the term resolution.

What I meant was, I had a bitmap that I downloaded and convert to RAW using Henning's tool. When it showed up on my TFT it looked very weird (like it lost some color?)

myFiles.load(x coordinate, y coordinate, image-x-size, image-y-size, fname[, buffer-size-multiplier, invert colour]);

x coordinate, y coordinate = screen coordinates
image-x-size, image-y-size = size of image
fname = image filename
buffer-size-multiplier = 1 by default (buffer = image-x-sizebuffer-size-multiplier2) (try 2, 4, 6, 8 )
invert colour = 0 by default (try 1 if colour wrong)

You have downloaded UTFT_SdRaw?

All I can suggest if you think colour is not as it should be, is change invert colour to 1.

Regards,

Graham

Edit: Download and rename SK400500.raw.txt to SK400500.raw put it on your sd-card not in a folder. Run that sketch.
Be aware that SK400500.raw is already inverted colour compared to the output from Henning's converter! This should CLEARLY demonstrate the buffer and invert colour features.

#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);

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

UTFT_SdRaw myFiles(&myGLCD);

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_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);
  Serial.println(F("LCD initialised."));
  char fname240[] = "SK400500.RAW";
  myGLCD.clrScr();
  long mytime = millis();
  myFiles.load(0, 0, 240, 240, fname240);
  long mytime1 = millis() - mytime;
  cout << F("Time to draw 240x240 raw (no extra buffer) (non inverted colour) ") << mytime1 << F(" ms") << endl;
  delay(5000);
  myGLCD.clrScr();
  mytime = millis();
  myFiles.load(0, 0, 240, 240, fname240, 1, 0); // <== default bufmult and inv-colour
  mytime1 = millis() - mytime;
  cout << F("Time to draw 240x240 raw (no extra buffer) (non inverted colour) ") << mytime1 << F(" ms") << endl;
  delay(5000);
  myGLCD.clrScr();
  mytime = millis();
  myFiles.load(0, 0, 240, 240, fname240, 1, 1); // <== default bufmult
  mytime1 = millis() - mytime;
  cout << F("Time to draw 240x240 raw (no extra buffer) (inverted colour) ") << mytime1 << F(" ms") << endl;
  delay(5000);
  mytime = millis();
  myFiles.load(0, 0, 240, 240, fname240, 8, 1);
  mytime1 = millis() - mytime;
  cout << F("Time to draw 240x240 raw (8*buffer) (inverted colour) ") << mytime1 << F(" ms") << endl;
  delay(5000);
  cout << F("Thanks for watching!") << endl;
  myGLCD.clrScr();
  myGLCD.setFont(BigFont);
  myGLCD.setColor(VGA_GREEN);
  myGLCD.print("Thanks for watching!", CENTER, 111);
}

void loop()
{
}

SK400500.raw.txt (113 KB)

Graham,

If you're ever in Dubai, a round of beer is on me! Invert Color was set to 1, switched it to zero and BAM! Colors are awesome!

Ran a loop to go compare buffer size multipliers and couldn't notice a visual difference. Maybe I'm color blind? lol

GFreak123:
Ran a loop to go compare buffer size multipliers and couldn't notice a visual difference. Maybe I'm color blind?

The buffer multiplier has a (small) benefit in terms of draw speed. On the DUE where multiplier values of 32 can be used, the draw speed can be reduced significantly by increasing the buffer size.

Glad you got it working! ;D

Regards,

Graham

I see.

Is there a way to dim the screen or switch it off while it draws the image from the SD card?

Unfortunately, no.

There are some ideas scattered around the forum for how to implement PWM control of the backlight which would do what you require. By default, UTFT only supports variable brightness or screen off on the CPLD displays.

Graham

Hello,
I am trying to run the same screen, but when I can not compile the software.

In file included from UTFT.cpp:45:0:
UTFT.h:179:42: fatal error: hardware/avr/HW_AVR_defines.h: No such file or directory
#include "hardware/avr/HW_AVR_defines.h"
^
compilation terminated.
Error compiling.

I got this message. Tried to add files, put it in the library directory but the same error message appears.

What I have to do?

I fixed it, but the screen did not get run. I've tried with DUE and MEGA shield without any success.

Are you using an additional AC/DC power supply? Something like 9-12V 500mA-1000mA will be fine.
What initialiser are you using?

UTFT myglcd(?,?,?,?,?);

Help us to help you!!

Regards,

Graham

Yes I use external power supply 9V/3W.

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

also tried with

UTFT myGLCD(CTE70,25,26,27,28);

I think it could be hardware problem ( damaged ) with the display.
Tried with arduino IDE 1.6, IDE 1.58, IDE 1.53 always the same.

"#define CTE_DUE_SHIELD 1" is uncommented.

When the backlight is on? Because it is always off.

Hello,

I really need this help I have look into the form and I am not getting what you said because I have try almost everything to get the SD to work on the MAGA shield on to the MAGA Board, but I am not understand how to get the SD to work on the MAGA shield or on the SainSmart 7 ' in TFT LCD Display SD card reader. Could you please explain what I have to do and show me explain, that would help out lot or some kind of video that would actually show step by step how to make it work, really need this help it for my college project and I would like to get it to work some how so please help me out that would be the best thing that will make me understand it all very well.

Also i have other SainSmart 7 ' in TFT LCD Display for Arduino Mega that is the touch screen version and what is the id for that one ( w9864g6jh-6) that would also help me to understand how that one work too.

thank you for your time,

Mikey

really really need this help I am try to make it for my project final project at my college it a galley show case too so please right back as soon as possible

have a great day.