I am trying to display a .bmp file on my 2.0 TFT SPI display. I have followed all the tutorials on displaying images and i can get all of them to work just fine. The problem is that the .bmp file i am trying to display is not on the root of the SD card but instead within a folder. I have tried using the reader.drawBMP() methods by suppling the path & filename but no image is rendered. Any help would be apprecaited. For context, the image is located at /001/image.bmp. Code below:
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SdFat.h> // SD card & FAT filesystem 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
#define BUFFPIXEL 20
SdFat SD; // SD card filesystem
Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
void setup(void) {
ImageReturnCode stat;
Serial.begin(9600);
#if !defined(ESP32)
while (!Serial);
#endif
tft.init(240, 320); // Init ST7789 320x240
tft.setRotation(1);
tft.setTextWrap(true);
tft.fillScreen(ST77XX_WHITE);
Serial.print(F("Initializing filesystem..."));
// SD card is pretty straightforward, a single call...
if (!SD.begin(SD_CS)) {
Serial.println(F("SD begin() failed"));
return;
}
}
void loop() {
//Add a border to the display:
//tft.drawRoundRect(2,2,316,236,4,ST77XX_RED);
//tft.drawRoundRect(4,4,312,232,4,ST77XX_RED);
//Draw the image:
reader.drawBMP("/001/image.bmp",tft,4,4);
}