Getting Jpg image from SD_card to sprite (or memory) - ESP32 #2199
-
Hi, I am new to TFT. I have a set of 9 openstreetmap tiles 256 x 256 pixels Jpeg, stored ion a SD_card and would like to put them in memory to be able to move the displayed portion of the map on the TFT screen smoothly. I have tried to put the transfert the images in a series sprites, but was unsuccessful. I am not shure if its the proper approach. Here is the code for simple jpeg file, based on the Jpg_decoder SD__card esemple. `// Example for library: // This example if for an ESP8266 or ESP32, it renders a Jpeg file // Include the jpeg decoder library // Include SD //#define SD_CS 4 // Include the TFT library https://github.com/Bodmer/TFT_eSPI TFT_eSprite spr = TFT_eSprite(&tft); // This next function will be called during decoding of the jpeg file to //Serial.println(w); // 16... last 12 // This function will clip the image block rendering automatically at the TFT boundaries // This might work instead if you adapt the sketch to use the Adafruit_GFX library // Return 1 to decode next block void setup() // Initialise SD before TFT // Initialise the TFT // 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 spr.createSprite(256, 256); void loop() // Time recorded for test purposes // Get the width and height in pixels of the jpeg if you wish // Draw the image, top left at 0,0 TJpgDec.drawSdJpg(0, 0, "/EagleEye.jpg"); t = millis() - t; // Wait before drawing again |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I suspect that sprite creation fails since 128kbytes of RAM will be required. If you have onboard PSRAM then it must be enabled. Try a smaller sprite, say 256x64. |
Beta Was this translation helpful? Give feedback.
-
To check for successful creation you can use code like this:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for those Email.
Setting the colour depth to 8 bits makes the sprite work. : spr.setColorDepth(8); 256 x 256 bytes is OK
With 16 bit, the size is limited to about half (not completely tested).
Setting the PSRAM to true did not help. spr.setAttribute(PSRAM_ENABLE, true);
My board is an ESPDUINO-32 HW-729 with the ESP32-D0WDQ6 (revision
I have checked the PRAM with the following command and it told PSRAM size = 0, although
Serial.printf("PSRAM Total heap %d, PSRAM Free Heap %d\n",ESP.getPsramSize(),ESP.getFreePsram());
This code also give me PSRAM not available….
if(psramInit()){
Serial.println("\nPSRAM is correctly initialized");
}else{
Serial.println("PSRAM not available");
}
I have the latest arduino version and ESP-IDE. I assume that the PSRAM is activated by default and that I don’t have to upload any special library other may be #include <Arduino.h>…
I will keep looking.
Any suggestion is appreciated.
Sylvain
… Le 24 nov. 2022 à 18:09, Bodmer ***@***.***> a écrit :
To check for successful creation you can use code like this:
if (img.createSprite(100, 100) == nullptr) Serial.println("Sprite NOT created, insufficient RAM!");
else Serial.println("YES! Sprite created.");
—
Reply to this email directly, view it on GitHub <#2199 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AIWMIQO4IU7JCNCFT7RG3MTWJ7YQ7ANCNFSM6AAAAAASJGJHX4>.
You are receiving this because you authored the thread.
|
Beta Was this translation helpful? Give feedback.
-
Just found this. My ESP32 version does not have PSRAM according to this. https://www.upesy.com/blogs/tutorials/get-more-ram-on-esp32-with-psram <https://www.upesy.com/blogs/tutorials/get-more-ram-on-esp32-with-psram>
I would need Oe of those.
ESP32-WROVER-B
ESP32-WROVER
Thanks again.
Sylvain
… Le 24 nov. 2022 à 19:24, S Lareau ***@***.***> a écrit :
Thanks for those Email.
Setting the colour depth to 8 bits makes the sprite work. : spr.setColorDepth(8); 256 x 256 bytes is OK
With 16 bit, the size is limited to about half (not completely tested).
Setting the PSRAM to true did not help. spr.setAttribute(PSRAM_ENABLE, true);
My board is an ESPDUINO-32 HW-729 with the ESP32-D0WDQ6 (revision
I have checked the PRAM with the following command and it told PSRAM size = 0, although
Serial.printf("PSRAM Total heap %d, PSRAM Free Heap %d\n",ESP.getPsramSize(),ESP.getFreePsram());
This code also give me PSRAM not available….
if(psramInit()){
Serial.println("\nPSRAM is correctly initialized");
}else{
Serial.println("PSRAM not available");
}
I have the latest arduino version and ESP-IDE. I assume that the PSRAM is activated by default and that I don’t have to upload any special library other may be #include <Arduino.h>…
I will keep looking.
Any suggestion is appreciated.
Sylvain
> Le 24 nov. 2022 à 18:09, Bodmer ***@***.*** ***@***.***>> a écrit :
>
>
> To check for successful creation you can use code like this:
>
> if (img.createSprite(100, 100) == nullptr) Serial.println("Sprite NOT created, insufficient RAM!");
> else Serial.println("YES! Sprite created.");
> —
> Reply to this email directly, view it on GitHub <#2199 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AIWMIQO4IU7JCNCFT7RG3MTWJ7YQ7ANCNFSM6AAAAAASJGJHX4>.
> You are receiving this because you authored the thread.
>
|
Beta Was this translation helpful? Give feedback.
I suspect that sprite creation fails since 128kbytes of RAM will be required. If you have onboard PSRAM then it must be enabled. Try a smaller sprite, say 256x64.