Pages: 1 [2]   Go Down
Author Topic: Arduino 1.77" SPI LCD Module with SD Just will not work?faulty?  (Read 2875 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All, been reading this with interest and have two TFT modules bought via RS Components, certified Arduino genuine part. Both these modules have four 'dead' horizontal stripes.Tested both with the MEGA 2560 and both give the same fault as described above.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's a funny thing. Just disconnected the Back light and you'd think the back light would go out. Actually, no, it does not! In fact, it gets brighter.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've had the same problem! I've downloaded arduino software nightly build and the stripes…are gone away! But i've had another problem...the tftbitmaplogo example not functioning. "File arduino.bmp not found". I've deleted the function loadimage and substituted with the function bmpDraw founded in the adafruit library Adafruit_ST7735 downloaded from adafruit website spitfbitmap. Full code here:

Code:
/*

 Arduino TFT Bitmap Logo example

 This example reads an image file from a micro-SD card
 and draws it on the screen, at random locations.

 In this sketch, the Arduino logo is read from a micro-SD card.
 There is a .bmp file included with this sketch.
 - open the sketch folder (Ctrl-K or Cmd-K)
 - copy the "arduino.bmp" file to a micro-SD
 - put the SD into the SD slot of the Arduino TFT module.

 This example code is in the public domain.

 Created 19 April 2013 by Enrico Gueli

 http://arduino.cc/en/Tutorial/TFTBitmapLogo

 */

// include the necessary libraries
#include <SPI.h>
#include <SD.h>
#include <TFT.h>

// 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


// this variable represents the image to be drawn on screen

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


void setup() {
  pinMode(10, OUTPUT);
  // initialize the GLCD and show a message
  // asking the user to open the serial line

  // 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
  }



  // 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!");
 
 
  MyLoadImage("arduino.bmp",50,50);
}

void loop() {

}

void MyLoadImage(char *filename, uint8_t x, uint8_t y){
  #define BUFFPIXEL 20
 
  File     bmpFile;
  int      bmpWidth, bmpHeight;   // W+H in pixels
  uint8_t  bmpDepth;              // Bit depth (currently must be 24)
  uint32_t bmpImageoffset;        // Start of image data in file
  uint32_t rowSize;               // Not always = bmpWidth; may have padding
  uint8_t  sdbuffer[3*BUFFPIXEL]; // pixel buffer (R+G+B per pixel)
  uint8_t  buffidx = sizeof(sdbuffer); // Current position in sdbuffer
  boolean  goodBmp = false;       // Set to true on valid header parse
  boolean  flip    = true;        // BMP is stored bottom-to-top
  int      w, h, row, col;
  uint8_t  r, g, b;
  uint32_t pos = 0, startTime = millis();
 
  bmpFile = SD.open(filename);
  if(bmpFile != NULL){
    Serial.println("File caricato!");
  }
 
  tft.begin();
  tft.background(0,0,0);
 
  if(read16(bmpFile) == 0x4D42) {
    Serial.print("File size: "); Serial.println(read32(bmpFile));
    (void)read32(bmpFile); // Read & ignore creator bytes
    bmpImageoffset = read32(bmpFile); // Start of image data
    Serial.print("Image Offset: "); Serial.println(bmpImageoffset, DEC);
    // Read DIB header
    Serial.print("Header size: "); Serial.println(read32(bmpFile));
    bmpWidth  = read32(bmpFile);
    bmpHeight = read32(bmpFile);
   
    if(read16(bmpFile) == 1) {
      bmpDepth = read16(bmpFile); // bits per pixel
      Serial.print("Bit Depth: "); Serial.println(bmpDepth);
      if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed

        goodBmp = true; // Supported BMP format -- proceed!
       
        Serial.print("Image size: ");
        Serial.print(bmpWidth);
        Serial.print('x');
        Serial.println(bmpHeight);

        // BMP rows are padded (if needed) to 4-byte boundary
        rowSize = (bmpWidth * 3 + 3) & ~3;

        // If bmpHeight is negative, image is in top-down order.
        // This is not canon but has been observed in the wild.
        if(bmpHeight < 0) {
          bmpHeight = -bmpHeight;
          flip      = false;
        }

        // Crop area to be loaded
        w = bmpWidth;
        h = bmpHeight;
        if((x+w-1) >= tft.width())  w = tft.width()  - x;
        if((y+h-1) >= tft.height()) h = tft.height() - y;
       
        Serial.print("TFT width: ");
        Serial.println(tft.width());
        Serial.print("TFT height: ");
        Serial.println(tft.height());
       
        // Set TFT address window to clipped image bounds
        tft.setAddrWindow(x, y, x+w-1, y+h-1);

        for (row=0; row<h; row++) { // For each scanline...

          // Seek to start of scan line.  It might seem labor-
          // intensive to be doing this on every line, but this
          // method covers a lot of gritty details like cropping
          // and scanline padding.  Also, the seek only takes
          // place if the file position actually needs to change
          // (avoids a lot of cluster math in SD library).
          if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
            pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
          else     // Bitmap is stored top-to-bottom
            pos = bmpImageoffset + row * rowSize;
          if(bmpFile.position() != pos) { // Need seek?
            bmpFile.seek(pos);
            buffidx = sizeof(sdbuffer); // Force buffer reload
          }

          for (col=0; col<w; col++) { // For each pixel...
            // Time to read more pixel data?
            if (buffidx >= sizeof(sdbuffer)) { // Indeed
              bmpFile.read(sdbuffer, sizeof(sdbuffer));
              buffidx = 0; // Set index to beginning
            }

            // Convert pixel from BMP to TFT format, push to display
            b = sdbuffer[buffidx++];
            g = sdbuffer[buffidx++];
            r = sdbuffer[buffidx++];
           
           
           
            tft.pushColor(tft.Color565(r,g,b));
          } // end pixel
        } // end scanline
      }
    }
  }

}

uint16_t read16(File f) {
  uint16_t result;
  ((uint8_t *)&result)[0] = f.read(); // LSB
  ((uint8_t *)&result)[1] = f.read(); // MSB
  return result;
}

uint32_t read32(File f) {
  uint32_t result;
  ((uint8_t *)&result)[0] = f.read(); // LSB
  ((uint8_t *)&result)[1] = f.read();
  ((uint8_t *)&result)[2] = f.read();
  ((uint8_t *)&result)[3] = f.read(); // MSB
  return result;
}

And tada! Here is the damned logo!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, thanks Gnerpo, was looking for a hardware fault but you've nailed it. Keira is the way, Nightly of course!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please note that the wire's connection are for arduino uno. Bye!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
I've try to use arduino nightly but when i launch the exe, i've the error "Launch4j An error occurred while starting the application"
I download the last version of java 64 bit, but i have the same pb. I try on two PC.

I'm on windows 7.

one day perhaps, my tft screen will working... :-(



Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everybody !

I've find a solution to fix this problem on the french forum (special thanx to Alexnesnes). I've just dl arduino 1.5.5 (beta) and miracle, the tft screen works correctly.

After many hour on this problem, the solution is too easy

The screen init is on iniG(). This initialisation is more adaptated for this tft screen model.

Thanks everybody for your answers.

Have a nice day!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have the same problem!
After 40 years working with elctronics components I think a made wiring exactly.
But my TFT doesn't work!
I think it is briked.


I read all your topic and also I made the same things as you.
I think it is or a library problem or that it's broken.
bye  smiley-cry
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok.
I resolved it thanks to support@arduino.cc
It was a software problem.
I downloaded latest version of IDE (1.5.6-r2) and so
it is working!
 smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

good stuff. Mine was actually a faulty screen. Ordered some more and they were fine.
Logged

Pages: 1 [2]   Go Up
Jump to: