SD Card Error with Adafruit_GFX Library

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
deisterhold
 
Posts: 9
Joined: Sun Oct 06, 2013 10:46 am

SD Card Error with Adafruit_GFX Library

Post by deisterhold »

I'm working on a project where I wish to create a basic graphical user interface using an Arduino Esplora and the TFT Screen for it (ST7735). On the back of the screen is a slot for a micro sd card that stores the images I'm using. I can display the set of 6 images 5 times before the images stop being displayed. The error that I get from the serial monitor is "loadImage: file not found: cbs.bmp". I'm wondering since the screen and the sd card both use SPI if there is are issues switching between the two. The other possibility I think that might be causing the issue would be a memory leak somewhere in the TFT library and once the chip is out of RAM the images can't be read into memory. I've included a video of the issue occurring at the link below.

Here is the source code and the images on the SD Card.
https://www.dropbox.com/s/2o8ymn0j1hylhwd/GUI.zip?dl=0

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: SD Card Error with Adafruit_GFX Library

Post by adafruit_support_rick »

I don't know what the problem is. You could try the free_ram() function in this tutorial to monitor your free space. See if you really are leaking sram.
https://learn.adafruit.com/memories-of- ... ree-memory

BTW, do you want to use width for both the xPos and yPos calculations?

Code: Select all

  xPos = xPos % (EsploraTFT.width());
  yPos = yPos % (EsploraTFT.width());

User avatar
deisterhold
 
Posts: 9
Joined: Sun Oct 06, 2013 10:46 am

Re: SD Card Error with Adafruit_GFX Library

Post by deisterhold »

Ok. I have implemented the freeRam() function to display how much RAM is left after each image is drawn. It seems that everytime I load a picture and draw it to the screen I lose 31 bytes of RAM that I should be getting back. I finally figured out the issue is in "Adafruit_GFX.h" on line 283. The image file is never closed, it is only replaced when a new image is loaded.

After adding,

Code: Select all

img._bmpFile.close();
, to the file all of the RAM that was used when drawing the image is deallocated. I have attached the updated file so that others can benefit from this. I'm not sure if you want me to report my findings to Arduino so they can fix the issue or if Adafruit is able to get the fix out more efficiently.

Thanks
-Daniel
Attachments
Adafruit_GFX.h
(11.49 KiB) Downloaded 116 times

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

Return to “General Project help”