Tiger.bmp for TFTtouchshield

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
rwarren1
 
Posts: 33
Joined: Mon Dec 26, 2011 5:50 pm

Tiger.bmp for TFTtouchshield

Post by rwarren1 »

:? When I try to load the tiger.bmp I am getting this error message::No matching function for call to file::read(uint8_t [60], int)

I am new to coding and would like to understand what the error message means. My IDE is Arduino 0022 version which I was told that this is the version for the tiger.bmp. Any help would be appreciated. Thank you.

Code: Select all

#include <SD.h>
#include <SPI.h>
#include "TFTLCD.h"

#if not defined USE_ADAFRUIT_SHIELD_PINOUT 
 #error "For use with the shield, make sure to #define USE_ADAFRUIT_SHIELD_PINOUT in the TFTLCD.h library file"
#endif

// These are the pins as connected in the shield
#define LCD_CS A3    // Chip Select goes to Analog 3
#define LCD_CD A2    // Command/Data goes to Analog 2
#define LCD_WR A1    // LCD Write goes to Analog 1
#define LCD_RD A0    // LCD Read goes to Analog 0

// The chip select pin for the SD card on the shield
#define SD_CS 5 
// In the SD card, place 24 bit color BMP files (be sure they are 24-bit!)
// There are examples in the sketch folder

// our TFT wiring
TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, 0);

// the file itself
File bmpFile;

// information we extract about the bitmap file
int bmpWidth, bmpHeight;
uint8_t bmpDepth, bmpImageoffset;

/************* HARDWARE SPI ENABLE/DISABLE */
// we want to reuse the pins for the SD card and the TFT - to save 2 pins. this means we have to
// enable the SPI hardware interface whenever accessing the SD card and then disable it when done
int8_t saved_spimode;

void disableSPI(void) {
  saved_spimode = SPCR;
  SPCR = 0;
}

void enableSPI(void) {
  SPCR = saved_spimode; 
}
/******************************************/

void setup()
{

  Serial.begin(9600);
  
  tft.reset();
  
  // find the TFT display
  uint16_t identifier = tft.readRegister(0x0);
  if (identifier == 0x9325) {
    Serial.println("Found ILI9325");
  } else if (identifier == 0x9328) {
    Serial.println("Found ILI9328");
  } else {
    Serial.print("Unknown driver chip ");
    Serial.println(identifier, HEX);
    while (1);
  }  
 
  tft.initDisplay();
  // the image is a landscape, so get into landscape mode
  tft.setRotation(1);

  Serial.print("Initializing SD card...");
 
  if (!SD.begin(SD_CS)) {
    Serial.println("failed!");
    return;
  }
  Serial.println("SD OK!");
  
  bmpFile = SD.open("tiger.bmp");

  if (! bmpFile) {
    Serial.println("didnt find image");
    while (1);
  }
  
  if (! bmpReadHeader(bmpFile)) { 
     Serial.println("bad bmp");
     return;
  }
  
  Serial.print("image size "); 
  Serial.print(bmpWidth, DEC);
  Serial.print(", ");
  Serial.println(bmpHeight, DEC);
  disableSPI();    // release SPI so we can use those pins to draw
 
  bmpdraw(bmpFile, 0, 0);
  // disable the SD card interface after we are done!
  disableSPI();
}


void loop()
{

}

/*********************************************/
// This procedure reads a bitmap and draws it to the screen
// its sped up by reading many pixels worth of data at a time
// instead of just one pixel at a time. increading the buffer takes
// more RAM but makes the drawing a little faster. 20 pixels' worth
// is probably a good place

#define BUFFPIXEL 20

void bmpdraw(File f, int x, int y) {

  enableSPI();     // enable the hardware SPI to talk to the SD card
  bmpFile.seek(bmpImageoffset);
  disableSPI();    // release it so we can use those pins
  
  uint32_t time = millis();
  uint16_t p;
  uint8_t g, b;
  int i, j;
  
  uint8_t sdbuffer[3 * BUFFPIXEL];  // 3 * pixels to buffer
  uint8_t buffidx = 3*BUFFPIXEL;
  
  Serial.print("rotation = "); Serial.println(tft.getRotation(), DEC);
  
  for (i=0; i< bmpHeight; i++) {
    // bitmaps are stored with the BOTTOM line first so we have to move 'up'

    if (tft.getRotation() == 3) {
      tft.writeRegister(TFTLCD_ENTRY_MOD, 0x1028);
      tft.goTo(x+i, y); 
    } else if  (tft.getRotation() == 2) {
      tft.writeRegister(TFTLCD_ENTRY_MOD, 0x1020);
      tft.goTo(x+bmpWidth, y+i); 
    } else if  (tft.getRotation() == 1) {
      tft.writeRegister(TFTLCD_ENTRY_MOD, 0x1018);
      tft.goTo(x+bmpHeight-1-i, y); 
    } else if  (tft.getRotation() == 0) {
      tft.writeRegister(TFTLCD_ENTRY_MOD, 0x1030);
      tft.goTo(x, y+bmpHeight-i); 
    }
    
    for (j=0; j<bmpWidth; j++) {
      // read more pixels
      if (buffidx >= 3*BUFFPIXEL) {
        enableSPI();     // enable the hardware SPI to talk to the SD card
        bmpFile.read(sdbuffer, 3*BUFFPIXEL);
        disableSPI();    // release it so we can use those pins
        buffidx = 0;
      }
      
      // convert pixel from 888 to 565
      b = sdbuffer[buffidx++];     // blue
      g = sdbuffer[buffidx++];     // green
      p = sdbuffer[buffidx++];     // red
      
      p >>= 3;
      p <<= 6;
      
      g >>= 2;
      p |= g;
      p <<= 5;
      
      b >>= 3;
      p |= b;
     
       // write out the 16 bits of color
      tft.writeData(p);
    }
  }
  tft.writeRegister(TFTLCD_ENTRY_MOD, 0x1030);
  Serial.print(millis() - time, DEC);
  Serial.println(" ms");
}

boolean bmpReadHeader(File f) {
   // read header
  uint32_t tmp;
  
  if (read16(f) != 0x4D42) {
    // magic bytes missing
    return false;
  }
 
  // read file size
  tmp = read32(f);  
  Serial.print("size 0x"); Serial.println(tmp, HEX);
  
  // read and ignore creator bytes
  read32(f);
  
  bmpImageoffset = read32(f);  
  Serial.print("offset "); Serial.println(bmpImageoffset, DEC);
  
  // read DIB header
  tmp = read32(f);
  Serial.print("header size "); Serial.println(tmp, DEC);
  bmpWidth = read32(f);
  bmpHeight = read32(f);

  
  if (read16(f) != 1)
    return false;
    
  bmpDepth = read16(f);
  Serial.print("bitdepth "); Serial.println(bmpDepth, DEC);

  if (read32(f) != 0) {
    // compression not supported!
    return false;
  }
  
  Serial.print("compression "); Serial.println(tmp, DEC);

  return true;
}

/*********************************************/

// These read data from the SD card file and convert them to big endian 
// (the data is stored in little endian format!)

// LITTLE ENDIAN!
uint16_t read16(File f) {
  uint16_t d;
  uint8_t b;
  b = f.read();
  d = f.read();
  d <<= 8;
  d |= b;
  return d;
}


// LITTLE ENDIAN!
uint32_t read32(File f) {
  uint32_t d;
  uint16_t b;
 
  b = read16(f);
  d = read16(f);
  d <<= 16;
  d |= b;
  return d;
}


User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Tiger.bmp for TFTtouchshield

Post by adafruit_support_bill »

Is that the only error message? The first errors are generally the most relevant. Scroll to the top of the list and post the whole thing.

The most likely problem is that the TFTLCD library is not properly installed.

rwarren1
 
Posts: 33
Joined: Mon Dec 26, 2011 5:50 pm

Re: Tiger.bmp for TFTtouchshield

Post by rwarren1 »

:shock: The entire error message is, "TFT_Shield:150 error:No matching function for call to file::read(unit8_t [60], int'

Then it further states, "C:\Users\Kween2\downloads\arduino-0022\arduino-0022\libraries\SD/SD.h:31 Note candidates are virtual int file::read

The last error line is, "bmpfile, read (sdbuffer, 3*BUFFPIXEL);

Thanks,

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Tiger.bmp for TFTtouchshield

Post by adafruit_support_bill »

OK, looks like you need to update the SD library. Follow the instructions in the tutorial:http://www.ladyada.net/products/tfttouchshield/
You'll also need to download our SD library modifyied to allow faster reads (these changes will be added to arduino v23) but for now you can download the new library here . Download the library by clicking the Downloads button and uncompressing the folder. Replace the files in your ArduinoIDE/libraries/SD folder and restart the IDE.

rwarren1
 
Posts: 33
Joined: Mon Dec 26, 2011 5:50 pm

Re: Tiger.bmp for TFTtouchshield

Post by rwarren1 »

:( Well I downloaded the SD (New) library and I'm still not able to get an SD Card reading. It worked perfectly ONE time. But since then, it doesn't seem to locate my SD Card. I've verified that the card is seated correctly in its holder. I have an 8 GB Kingston mini (tiny) SD Card. My wiring is: #define SD_CS 5. And I have also changed the chipSelect to 5. Any other advise is greatly appreciated. My goal is to download the tiger.bmp for arduino version 0022. Thanks

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Tiger.bmp for TFTtouchshield

Post by adafruit_support_bill »

It worked perfectly ONE time. But since then, it doesn't seem to locate my SD Card.
If it worked once, then you have the right library. What is the exact text of the error message you are getting?

rwarren1
 
Posts: 33
Joined: Mon Dec 26, 2011 5:50 pm

Re: Tiger.bmp for TFTtouchshield

Post by rwarren1 »

:( The exact text of the error message I am getting is this: Initializing SC Card...initialization failed. Is a card inserted, is your wiring correct, did you change the chipSelect pin to match your shield or module?

I am using the adafruit TFT Touchscreen with the Arduino 1.0 version which I was told is the version that is suppose to be compatible for the tiger.bmp. I've tried #define SD_CS 5 and chipSelect 5. I have also tried #define SD_CS 10 and chipSelect 10 of which neither works.

I can get the graphicstest to run on the Adafruit shield, and the Tftpaintshield to run.

How do you format a (tiny) SD Card into a FAT16/FAT32 file system? Thanks.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Tiger.bmp for TFTtouchshield

Post by adafruit_support_bill »

I've tried #define SD_CS 5 and chipSelect 5. I have also tried #define SD_CS 10 and chipSelect 10 of which neither works.
You said it worked once. That means that the chip-select was correct at the time. Making random changes to the chip-select is not going to help matters.

The CS for the TFTTouchShield is 5. Go back to the configuration that worked and we can try to diagnose the card problem.

rwarren1
 
Posts: 33
Joined: Mon Dec 26, 2011 5:50 pm

Re: Tiger.bmp for TFTtouchshield

Post by rwarren1 »

:x I went back to #define SD_CS 5 and chipSelect 5 yet it still is giving me an error. The error says, "Initializing SD card...initialization failed. Things to check are: is a card inserted?, Is your wiring correct?, and did you change the chipSelect pin to match your shield or module?

The sketch itself compiles. Thanks

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Tiger.bmp for TFTtouchshield

Post by adafruit_support_bill »

What steps did you take between the time that it worked and the time it stopped working? Did you remove the card from the shield?

Are you still able to read/write to the card from your computer? Do you have any other SD cards to try?

rwarren1
 
Posts: 33
Joined: Mon Dec 26, 2011 5:50 pm

Re: Tiger.bmp for TFTtouchshield

Post by rwarren1 »

:roll: I removed the microSD Card in order to replace it with an 8GB card. And since then, the shield stopped locating my card. My laptop does not have a slot for an SD Card so I'm aware that even if the shield does locate my card, it will tell me that it was unable to find a FAT16/FAT32 file system. I will go out today and purchase another microSD Card and let you know what happens. Thanks for your time and I hope to hear back from you again.

rwarren1
 
Posts: 33
Joined: Mon Dec 26, 2011 5:50 pm

Re: Tiger.bmp for TFTtouchshield

Post by rwarren1 »

:| I just so happened to have an extra microSD Card. Everytime I put it in the shield slot, it doesn't work. I'm beginning to believe it's a hardware problem with the shield itself. Any other suggestions would be appreciated. Thanks,

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”