Trouble with displaying images on a TFT LCD

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Trouble with displaying images on a TFT LCD

Postby akelleher » Sun May 13, 2012 2:46 pm

For an English project, I decided to use the 20x4 character LCD to display a word and its definition, and the 1.8" TFT LCD to display a picture related to the word.

Code: Select all
void setup(void) {
  tft.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab
  lcd.begin(20, 4);
  SD.begin(SD_CS);
tft.fillScreen(ST7735_BLACK);
lcd.setCursor(3,0);
lcd.print("English Project");
lcd.setCursor(3,2);
lcd.print("Alex Kelleher");
delay(3000);
lcd.clear();
}

void loop() {
drawGlee();
drawDelight();
drawCheerful();
drawGlad();
drawImpartial();
drawLament();
}

void drawGlee(){
  bmpDraw("glee.bmp",0,0);
  lcd.clear();
  lcd.setCursor(8,0);
  lcd.print("Glee");
  lcd.setCursor(2,2);
  lcd.print("Great delight or");
  lcd.setCursor(6,3);
  lcd.print("pleasure");
  delay(3000);
}


drawDelight(), drawCheerful(), etc. all follow the same format as drawGlee(); bmpDraw() is copied from the example in the ST7735 library.

This code works fine. It displays the initial nameplate with a black TFT, and then cycles through the six words with their corresponding images.

The problem comes when I add one more word. If I add
Code: Select all
void drawDejection(){
  bmpDraw("dejection.bmp",0,0);
  lcd.clear();
  lcd.setCursor(4,0);
  lcd.print("Dejection");
  lcd.setCursor(1,2);
  lcd.print("Lowness of spirits");
  delay(3000);
}

and call it from loop() right after the others, it breaks. All it does is show the nameplate with the black TFT, and then the character LCD clears, and then nothing else happens. But if I get rid of drawDejection(), it works fine again.

I'm really clueless about why this is happening. Thanks in advance.
akelleher
 
Posts: 3
Joined: Sun May 13, 2012 2:14 pm

Re: Trouble with displaying images on a TFT LCD

Postby adafruit_support_bill » Sun May 13, 2012 3:58 pm

The problem is likely related to your filename: "dejection.bmp".
The SD library only supports file names with up to 8 characters and a 3 character extension.
User avatar
adafruit_support_bill
 
Posts: 16644
Joined: Sat Feb 07, 2009 9:11 am

Re: Trouble with displaying images on a TFT LCD

Postby akelleher » Sun May 13, 2012 4:29 pm

Hmm, that explains a different problem I was having, but doesn't fix the main issue. Even with the file renamed to deject.bmp, the same thing happens. It seems that I can only have six at once- if I get rid of both the call and declaration for, as an example, drawImpartial(), then it works fine with drawDejection(). I have ten words total, and any six will work at once, but no more.

If I leave the function declarations for seven words in, but only call six, the program still breaks-- a function that's not called causes it to break. So I'm really confused.
akelleher
 
Posts: 3
Joined: Sun May 13, 2012 2:14 pm

Re: Trouble with displaying images on a TFT LCD

Postby adafruit_support_bill » Mon May 14, 2012 4:48 am

If I leave the function declarations for seven words in, but only call six, the program still breaks-- a function that's not called causes it to break. So I'm really confused.

That sounds like a memory problem. There is not a lot of RAM in the Arduino, and when you run out, unpredictable things happen. Some helpful info here:http://itp.nyu.edu/~gpv206/2008/04/making_the_most_of_arduino_mem.html
User avatar
adafruit_support_bill
 
Posts: 16644
Joined: Sat Feb 07, 2009 9:11 am

Re: Trouble with displaying images on a TFT LCD

Postby akelleher » Mon May 14, 2012 9:40 pm

You're right, it turned out that I was running out of memory. Getting rid of extra string literals got me up to 9 out of 10 words (so close!), but no farther, so I ended up using PROGMEM from that link.

It also might be a good idea to mention that the SD library only supports 8 character filenames in the TFT LCD tutorial.

Thanks again.
akelleher
 
Posts: 3
Joined: Sun May 13, 2012 2:14 pm


Return to Arduino

Who is online

Users browsing this forum: ArekKindAcere and 4 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [113]

Raspberry Pi[82]
 
FLORA[24]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[12]
Arduino[60]
 
NETduino[14]
 
Android[6]
 
BeagleBone[23]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[39]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[9]


 
Breakout Boards[35]
LCDs & Displays[49]
Components & Parts[70]
Batteries & Power[54]
EL Wire/Tape/Panel[52]
LEDs[112]
 
Wireless[16]
Cables[66]
 
Lasers[6]
Sensors/Parts[147]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[41]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[25]


 
Stickers[41]
 
Skill badges[55]
 
Books[26]
 
Circuit Playground[7]
 
Gift Certificates[4]