File not found (.bmp) Using Adafruit_ImageReader Library

This one is urgent, because it’s necessary for a final in an electronics class, due this week. I’ve been doing fine all semester and I have a program that should work, but the ST7798 display isn’t showing the bitmap image for my program. I went and took one of the examples out of the library and converted the program for the ST7735 to the ST7789 and it initializes fine, and the fillScreen works fine and fills the screen with blue, but the image doesn’t display right after. It just goes black. The serial monitor indicates that the files weren’t found. Fine. I changed every file name to the same file in the program and made certain that that bitmap file was found on the SD card and readable on my computer. Also, the image reading library, mentioned below, came up empty when installed through the IDE and was fixed with a manual GITHUB install. Why won’t it display the image? How do I fix it? Any help is appreciated! Additional info:

OS: Windows 10
IDE: 1.8.9
SD card: 8GB MicroSDHC
SD Format: Fat32 (windows doesn’t like to format in Fat16 without going through the CMD)
Libraries:
SPI.h
SD.h
AdafruitGFX.h
Adafruit_ST7789.h
Adafruit_ImageReader.h
(All up to date)
Board: Arduino Uno
Display: 240x240 TFT display ST7789 w/uSD card (Adafruit)

Program:
// Adafruit_ImageReader test for Adafruit ST7735 TFT Breakout for Arduino.
// Demonstrates loading images to the screen, to RAM, and how to query
// image file dimensions.
// Requires three BMP files in root directory of SD card:
// rgbwheel.bmp, miniwoof.bmp and wales.bmp.
// As written, this uses the microcontroller’s SPI interface for the screen
// (not ‘bitbang’) and must be wired to specific pins (e.g. for Arduino Uno,
// MOSI = pin 11, MISO = 12, SCK = 13). Other pins are configurable below.

#include <SPI.h>
#include <SD.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library
#include <Adafruit_ImageReader.h> // Image-reading functions

// TFT display and SD card share the hardware SPI interface, using
// ‘select’ pins for each to identify the active device on the bus.

#define SD_CS 4 // SD card select pin
#define TFT_CS 10 // TFT select pin
#define TFT_DC 8 // TFT display/command pin
#define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin

Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
Adafruit_ImageReader reader; // Class w/image-reading functions
Adafruit_Image img; // An image loaded into RAM
int32_t width = 0, // BMP image dimensions
height = 0;

void setup(void) {

ImageReturnCode stat; // Status from image-reading functions

Serial.begin(9600);
#if !defined(ESP32)
while(!Serial); // Wait for Serial Monitor before continuing
#endif

tft.init(240, 240); // Initialize screen

Serial.print(F(“Initializing SD card…”));
if(!SD.begin(SD_CS)) {
Serial.println(F(“failed!”));
for(;;); // Loop here forever
}
Serial.println(F(“OK!”));

// Fill screen blue. Not a required step, this just shows that we’re
// successfully communicating with the screen.
tft.fillScreen(ST77XX_BLUE);

// Load full-screen BMP file ‘rgbwheel.bmp’ at position (0,0) (top left).
// Notice the ‘reader’ object performs this, with ‘tft’ as an argument.
Serial.print(F(“Loading centerImage.bmp to screen…”));
stat = reader.drawBMP("/centerImage.bmp", tft, 0, 0);
reader.printStatus(stat); // How’d we do?

// Query the dimensions of image ‘miniwoof.bmp’ WITHOUT loading to screen:
Serial.print(F(“Querying centerImage.bmp image size…”));
stat = reader.bmpDimensions("/centerImage.bmp", &width, &height);
reader.printStatus(stat); // How’d we do?
if(stat == IMAGE_SUCCESS) { // If it worked, print image size…
Serial.print(F("Image dimensions: "));
Serial.print(width);
Serial.write(‘x’);
Serial.println(height);
}

// Load small BMP ‘wales.bmp’ into a GFX canvas in RAM. This should fail
// gracefully on Arduino Uno and other small devices, meaning the image
// will not load, but this won’t make the program stop or crash, it just
// continues on without it. Should work on Arduino Mega, Zero, etc.
Serial.print(F(“Loading centerImage.bmp to canvas…”));
stat = reader.loadBMP("/centerImage.bmp", img);
reader.printStatus(stat); // How’d we do?

delay(2000); // Pause 2 seconds before moving on to loop()
}

void loop() {
for(int r=0; r<4; r++) { // For each of 4 rotations…
tft.setRotation(r); // Set rotation
tft.fillScreen(0); // and clear screen

// Load 4 copies of the ‘miniwoof.bmp’ image to the screen, some
// partially off screen edges to demonstrate clipping. Globals
// ‘width’ and ‘height’ were set by bmpDimensions() call in setup().
for(int i=0; i<4; i++) {
reader.drawBMP("/centerImage.bmp", tft,
(tft.width() * i / 3) - (width / 2),
(tft.height() * i / 3) - (height / 2));
}

delay(1000); // Pause 1 sec.

// Draw 50 Welsh dragon flags in random positions. This has no effect
// on memory-constrained boards like the Arduino Uno, where the image
// failed to load due to insufficient RAM, but it’s NOT fatal.
for(int i=0; i<50; i++) {
// Rather than reader.drawBMP() (which works from SD card),
// a different function is used for RAM-resident images:
img.draw(tft, // Pass in tft object
(int16_t)random(-img.width() , tft.width()) , // Horiz pos.
(int16_t)random(-img.height(), tft.height())); // Vert pos
// Reiterating a prior point: img.draw() does nothing and returns
// if the image failed to load. It’s unfortunate but not disastrous.
}

delay(2000); // Pause 2 sec.
}
}

Status indicator:
C:\Users\user\Downloads\Adafruit_ImageReader-master\Adafruit_ImageReader-master\examples\BreakoutST7735-128x128\BreakoutST7735-128x128.ino: In function ‘void setup()’:

C:\Users\user\Downloads\Adafruit_ImageReader-master\Adafruit_ImageReader-master\examples\BreakoutST7735-128x128\BreakoutST7735-128x128.ino:55:54: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

stat = reader.drawBMP("/centerImage.bmp", tft, 0, 0);

^

C:\Users\user\Downloads\Adafruit_ImageReader-master\Adafruit_ImageReader-master\examples\BreakoutST7735-128x128\BreakoutST7735-128x128.ino:60:66: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

stat = reader.bmpDimensions("/centerImage.bmp", &width, &height);

^

C:\Users\user\Downloads\Adafruit_ImageReader-master\Adafruit_ImageReader-master\examples\BreakoutST7735-128x128\BreakoutST7735-128x128.ino:74:48: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

stat = reader.loadBMP("/centerImage.bmp", img);

^

C:\Users\user\Downloads\Adafruit_ImageReader-master\Adafruit_ImageReader-master\examples\BreakoutST7735-128x128\BreakoutST7735-128x128.ino: In function ‘void loop()’:

C:\Users\user\Downloads\Adafruit_ImageReader-master\Adafruit_ImageReader-master\examples\BreakoutST7735-128x128\BreakoutST7735-128x128.ino:91:46: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

(tft.height() * i / 3) - (height / 2));

^

Sketch uses 25056 bytes (77%) of program storage space. Maximum is 32256 bytes.
Global variables use 1217 bytes (59%) of dynamic memory, leaving 831 bytes for local variables. Maximum is 2048 bytes.

Please use code tags when you post code or warning/error messages. To do this, click the </> button on the forum toolbar, then paste the text you want to be in the code tags. Finally, move the cursor out of the code tags before adding any additional text you don’t want to be in the code tags. If your browser doesn’t show the posting toolbar, then you can manually add the code tags like this:
[code]``[color=blue]// your code is here[/color]``[/code]

The reason for doing this is that, without code tags, the forum software can interpret parts of your code as markup (the smiley face in your code above, for example), leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier for us to read your code and to copy it to the IDE or editor.

Using code tags and other important information is explained in the “How to use this forum” post. Please read it.

FallingShells:

  // Load full-screen BMP file 'rgbwheel.bmp' at position (0,0) (top left).

// Notice the ‘reader’ object performs this, with ‘tft’ as an argument.
  Serial.print(F(“Loading centerImage.bmp to screen…”));
  stat = reader.drawBMP("/centerImage.bmp", tft, 0, 0);

From the SD library documentation:
https://www.arduino.cc/en/Reference/SD

It uses short 8.3 names for files.

This means the first part of the filename can be at most 8 characters and the extension at most 3 characters. The first part of your filename is 11 characters long, so it is not compatible with the SD library.

pert:
Please use code tags when you post code or warning/error messages. To do this, click the </> button on the forum toolbar, then paste the text you want to be in the code tags. Finally, move the cursor out of the code tags before adding any additional text you don’t want to be in the code tags. If your browser doesn’t show the posting toolbar, then you can manually add the code tags like this:

[code]

[color=blue]// your code is here[/color]

[/code]

The reason for doing this is that, without code tags, the forum software can interpret parts of your code as markup (the smiley face in your code above, for example), leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier for us to read your code and to copy it to the IDE or editor.

Using code tags and other important information is explained in the “How to use this forum” post. Please read it.

From the SD library documentation:
https://www.arduino.cc/en/Reference/SDThis means the first part of the filename can be at most 8 characters and the extension at most 3 characters. The first part of your filename is 11 characters long, so it is not compatible with the SD library.

This fixed the image presentation, after troubleshooting a few more minor issues with my program, I got everything fully functional. Thank you so much. Kudos to you. I will remember to insert the code in code format in the future. Goodnight.

You’re welcome. I’m glad to hear it’s working now. Enjoy!
Per