Displaying Bitmap on 3.5 tft LCD shield

Alight guys, I need some help here. I am working in unfamiliar territory and not a strong programmer. Several days spent trying to figure this out, maybe someone with more skill can give me assist.

I have an Arduino Mega 2560 and a 3.5 inch 320x480 tft LCD shield.Display link

I was able to easily get the display working. So I am able to draw text, colors, lines, ect. The problem is I want to display a Bitmap file first, use that as my background and change text on top of that. And drawing bitmaps is where I’m having trouble. I have a few files so they are stored on the SD card.
Now this particular shield has the SD card pins to 10,11,12,13 which works on my uno but not this MEGA because the SPI pins are somewhere else. I need the pins, MEGA it is. So I’m using SoftwareSPI, which works! I have included the code that reads the root directory on the SD card and draws each bitmap one after the next, I can do this successfully.

With my limited programming experience I can only start by trying to modify example script on this complex stuff. This example script i am working with has way more than I need, but thinning out tasks that are not things I need just end up with errors. I just need to load one image of my choice by defining a bitmap in a variable. My intention was to package this up in a function and call it with a “bitmap.bmp” variable to load on the display.

tried posing code, it’s too long so I’m it’s attached? Im using the MCUFriend_kbv library Github specifically the showBMP_not_Uno example.

Thanks in advance for any help.

showBMP_not_Uno.ino (9.79 KB)

If you only want to display one known image you don't need to search a directory. Just use a fixed file path and name.

There is little point in simplifying the showBMP function. Your Mega has plenty of Flash.

Explain exactly what you want to do.

David.

David, thanks for the reply.

I have about 4 or 5 Bitmaps on the SD card. My intention is to find a way to display one at a time on command. They are background graphics for different "menus", switch screens in my program I need to first load a bitmap.

Perhaps I'm not using the draw BMP function correctly. I've tried modifying the sample code, replacing variables with known file names, no luck, end up creating more errors than I can fix.

I was concerned if I converted the BMP to an array? And putting it i a .h file that's attached might consume too much onboard resources.

Just use standard 24-bit colour BMP files. e.g. as produced by PC programs.
Save to your SD card.

Access each BMP file by name. Note that <SD.h> will not like long filenames. Use ########.BMP style for names.
<SdFat.h> might be ok with long names.

David.

I guess that is where I am struggling. I cannot seem to find a command to draw a bitmap with my particular libraries and configuration. And this example ino does it in a way that's beyond me

Maybe you can convert the bitmaps into Hex and reference the hex file from your main program?
Here is a tool to do bitmap to hex converstion