Pages: [1]   Go Down
Author Topic: Arduino TFT library problem  (Read 632 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys! I'm using the new Arduino TFT screen, the BMP display feature seems to be faulty.
I'm using the following code to display multiple bitmap images, which is modified from TFTBitmapLogo example

#include <SPI.h>
#include <SD.h>
#include <TFT.h>  // Arduino LCD library

// pin definition for the Uno
#define sd_cs  4
#define lcd_cs 10
#define dc     9
#define rst    8 

// pin definition for the Leonardo
//#define sd_cs  8
//#define lcd_cs 7
//#define dc     0
//#define rst    1 

TFT TFTscreen = TFT(lcd_cs, dc, rst);

// 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.background(255, 255, 255);

  // initialize the serial port: it will be used to
  // print some diagnostic info 

  // 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.
  if (!SD.begin(sd_cs)) {
  // initialize and clear the GLCD screen
  TFTscreen.background(255, 255, 255);

  // now that the SD card can be access, try to load the
  // image file.
    logo = TFTscreen.loadImage("lg0.bmp");
    if (!logo.isValid()) {
    TFTscreen.image(logo, 0, 0);
    logo = TFTscreen.loadImage("lg1.bmp");
    if (!logo.isValid()) {
    TFTscreen.image(logo, 0, 0);

void loop() {

Typically the "logo.isValid()" goes false after 3~4 times. If I put more "Serial.print()" or "TFTscreen.println()" in the code, it'll go false after 0~1 time. I suspect there's a memory leak somewhere.

In another project I'm doing, I use Fat16 for SD read and a customized image display function, I can switch images as many times as I've tried. So this shouldn't be a hardware issue.

Btw in this page the connection diagram right above "Code" title is wrong, pins for SD are not connected, so it's impossible to display BMP if following the instruction.

Pages: [1]   Go Up
Jump to: