-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cant read from SD #78
Comments
H i Yiungyiung, Did you manage to solve this issue as I cannot seem to solve it either? I'm using an ESP32, ILI9341, which I can control with fill back grounds, draw lines etc. I can read text files and display them from the SD card using Serial.print, but no matter what I try for JPEGs, it says "Jpeg file not found" I reverted back to the Arduino 1.8 IDE, removed all the libraries and reinstalled. This has made no difference. Current library list is:
Test calls:
Thanks |
Actually yes and no, Its not a library issue btw lol So the idk much abt electronics and stuff but I found out that either they work individually or don't work at all what worked for me for reading all the Images in an array before the intialisation of TFT and then displaying it. I didn't try changing the address for one of em but if you are successful please do tell me. #include <Adafruit_GFX.h> #define TFT_CS 14 Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST); #define MAX_FILES 5 // Maximum number of files to handle File jpegFiles[MAX_FILES]; // Array to hold File objects for JPEG files Serial.print("Initializing SD card..."); File root = SD.open("/"); // open SD card main root root.close(); // close the opened root // initialize ST7735S TFT display tft.close(); for(int i= 0;i<=fileCount;i++) void loop() { void renderJPEG(int xpos, int ypos) { // Jpeg images are drawn as a set of image blocks (tiles) called Minimum Coding Units (MCUs) // record the current time so we can measure how long it takes to draw an image // save the coordinate of the right and bottom edges to assist image cropping // read each MCU block until there are no more
} // calculate how long it took to draw the image // print the results to the serial port void birthdayLights() { void animateText(const String& text, int16_t x, int16_t y, const uint16_t* colors, int numColors, uint16_t delay_ms) { // Center the text vertically // Draw the first line of text ("Happy Birthday") with each alphabet in a different color // Draw the second line of text ("Satviki") with each alphabet in a different color |
I simply reversed the order so the tft.begin() is first then SD card initialization and that worked! I am using the Pi Pico. // The jpeg image can be scaled by a factor of 1, 2, 4, or 8 // The decoder must be given the exact name of the rendering function above |
I have an st7789 240 * 240 screen
my connections are
#define TFT_MISO -1
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS 14 // Chip select control pin
#define TFT_DC 21 // Data Command control pin
#define TFT_RST 4 // Reset pin (could connect to RST pin)
in usersetup
I have a micro sd card adapter
with connections
as
miso 19
mosi 23
cs 5
clk 18
I am not able to read from sd card as its saying file not found,
if I use the esp32 example in tft_espi, my display doesn't work and if I try to use the example in tjpegdecoder I cant get the sdcard to work
// Example for library:
// https://github.com/Bodmer/TJpg_Decoder
// This example if for an ESP8266 or ESP32, it renders a Jpeg file
// that is stored in a SD card file. The test image is in the sketch
// "data" folder (press Ctrl+K to see it). You must save the image
// to the SD card using you PC.
// Include the jpeg decoder library
#include <TJpg_Decoder.h>
// Include SD
#define FS_NO_GLOBALS
#include <FS.h>
#ifdef ESP32
#include "SPIFFS.h" // ESP32 only
#endif
#define SD_CS 5
// Include the TFT library https://github.com/Bodmer/TFT_eSPI
#include "SPI.h"
#include <TFT_eSPI.h> // Hardware-specific library
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
// This next function will be called during decoding of the jpeg file to
// render each block to the TFT. If you use a different TFT library
// you will need to adapt this function to suit.
bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t* bitmap)
{
// Stop further decoding as image is running off bottom of screen
if ( y >= tft.height() ) return 0;
// This function will clip the image block rendering automatically at the TFT boundaries
tft.pushImage(x, y, w, h, bitmap);
// This might work instead if you adapt the sketch to use the Adafruit_GFX library
// tft.drawRGBBitmap(x, y, bitmap, w, h);
// Return 1 to decode next block
return 1;
}
void setup()
{
Serial.begin(115200);
Serial.println("\n\n Testing TJpg_Decoder library");
// Initialise SD before TFT
if (!SD.begin(SD_CS)) {
Serial.println(F("SD.begin failed!"));
while (1) delay(0);
}
Serial.println("\r\nInitialisation done.");
// Initialise the TFT
tft.begin();
tft.setTextColor(0xFFFF, 0x0000);
tft.fillScreen(TFT_BLACK);
tft.setSwapBytes(true); // We need to swap the colour bytes (endianess)
// The jpeg image can be scaled by a factor of 1, 2, 4, or 8
TJpgDec.setJpgScale(1);
// The decoder must be given the exact name of the rendering function above
TJpgDec.setCallback(tft_output);
}
void loop()
{
tft.fillScreen(TFT_RED);
// Time recorded for test purposes
uint32_t t = millis();
// Get the width and height in pixels of the jpeg if you wish
uint16_t w = 0, h = 0;
TJpgDec.getSdJpgSize(&w, &h, "/Baboon40.jpg");
Serial.print("Width = "); Serial.print(w); Serial.print(", height = "); Serial.println(h);
// Draw the image, top left at 0,0
TJpgDec.drawSdJpg(0, 0, "/Baboon40.jpg");
// How much time did rendering take
t = millis() - t;
Serial.print(t); Serial.println(" ms");
// Wait before drawing again
delay(2000);
}
The text was updated successfully, but these errors were encountered: