Bodmer / TJpg_Decoder

Jpeg decoder library based on Tiny JPEG Decompressor
Other
227 stars 43 forks source link

Refuses to open file from from SD card #81

Closed TheRegularDX closed 3 weeks ago

TheRegularDX commented 3 weeks ago

As the title says, it will always give the Jpeg file not found error. i am using an ESP32S3 with an sd card connected as SD MMC below is a simple code i wrote to test this

#include <SD_MMC.h>
#include <TJpg_Decoder.h>

#define SD_DATA 40
#define SD_CLK 39
#define SD_CMD 38

bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap) {

  return true;
}
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  SD_MMC.setPins(SD_CLK, SD_CMD, SD_DATA);
  if (!SD_MMC.begin("/sdcard", true)) {  
    Serial.println("Card failed, or not present");
    return;
  }
  Serial.println("SD card initialized via SDMMC.");

  TJpgDec.setJpgScale(1);
  TJpgDec.setCallback(tft_output);

  uint16_t w = 0, h = 0;
  TJpgDec.getSdJpgSize(&w, &h, "/a.jpg");
  Serial.print("Width = "); Serial.print(w); Serial.print(", height = "); Serial.println(h);
}

void loop() {
  // put your main code here, to run repeatedly:

}
TheRegularDX commented 3 weeks ago

a.jpg exists and is located at the root folder of the sd card, which is formatted as FAT32

TheRegularDX commented 3 weeks ago

figured it out, adding File jpegFile = SD_MMC.open("/a.jpg"); solved the issue lole