Another update on my progress (Not necessarily looking for help).
I loaded the SDFat library and configured it (as recommended above).
To learn how to use it, I copied the pertinent information from the example file called "SoftwareSpi.ino".
The beginning of this file has "#include <SPI.h>".
I am using the example file that came on a CD with my display called "Example07-ShowBMP" (as mentioned above), so I copied and pasted the pertinent lines from the "SoftwareSpi.ino" file into the "Example07-ShowBMP" and tried to run it.
It took a lot of head banging to realize the line #include <SPI.h> must be commented out, otherwise it will always result in an "initialization failed" error when executing this function:
if (!SD.begin(SD_CHIP_SELECT_PIN)) {
Serial.println("initialization failed!");
tft.setCursor(0, 0);
tft.setTextColor(WHITE);
tft.setTextSize(1);
tft.println("SD Card Init fail.");
}else
Serial.println("initialization done.");
It seems that the SDFat provides its own SPI, and the SPI.h was pushing it to use the hardware SPI, so It could never dial into the software SPI.
I still had issues after fixing this issue with this example file. It seems the bmpReadheader(File f) function has issues with the SDFat library. If I comment out the call to that function, the bitmaps are displayed, but they are shifted to the right by about 10 pixels.
I compared the serial values that are printed between the previously mentioned NANO connected to this display with hardware SPI and default SD library compared to the exact same display and SD card connected to a MEGA and using the SDFat.h file. I am including that serial output here:
NANO:
TFT LCD test
Found 0x9486 LCD driver
TFT size is 320x480
initialization done.
size 0x38436
offset 54
header size 40
bitdepth 24
compression 40
4830 ms
MEGA:
TFT LCD test
Found 0x9486 LCD driver
TFT size is 320x480
initialization done.
size 0x4D424D42
offset 66
header size 1296190786
bad bmp
I have attached the example program to this post, but I will continue pursuing this on my own.
I hope to add some serial print lines and try different things and look into the SDFat library and see if I can figure out what is going on. I am also convinced the example program I am using is not very well written, as I tried to change the size of the display and found that while they made height and width variables at the top of the program, they did not use those variables inside the function to allow the different sized displays to be easily used. I'm sure the SDFat library is fine, but it is not a plug and play with this particular display's example programs. Once I get it resolved, I intend to post better example software on the Amazon page where I bought the display. I like the display, but I must think this would annoy many customers.
I will post again if I make more progress.
ShowBMP.ino (8.77 KB)