M5Paper: How to display large jpg image from web (or download it to SD card)
-
Hello!
I am new to m5stack, arduino/micropython and ESP32 development overall, and I was wondering if anybody here could help me and give me advice what would be best way to go about displaying larger jpg images (~1MB) directly from web on m5paper.
I was able to draw small example image "flower.jpg" using
canvas.drawJpgUrl("https://m5stack.oss-cn-shenzhen.aliyuncs.com/image/example_pic/flower.jpg");
But I understand I cant draw larger images this way, directly from the web, so I was thinking I would download the image to SD card first and then display it (since that works for large images)
Any ideas if there is a better way to do this and what I should look into?
Thank you!
PS: I found that maybe I could modify this example to download images, but it is a bit complicated for me to understand everything:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266HTTPClient/examples/StreamHttpClient/StreamHttpClient.ino -
Hello @doubleness
M5Paper has 8MB of PSRAM on board of which 4MB can be used at the time. (The limitation is ESP32 which only can map 4MB at the time).
Andcanvas.drawJpgUrl()
already makes use of PSRAM by callingps_malloc()
:uint8_t *p = (uint8_t*)ps_malloc(size); if(p == NULL) { log_e("Memory overflow."); return 0; }
In my test I was able to directly download and display jpgs up to about 4MB. (No SD card involved.)
Thanks
Felix -
@felmue Thanks Felix, I tested different urls with several jpg images and it is really working.
I was probably testing either images with wrong format or simply didn't wait long enough until the image is drawn. And not sure why, I was under impression that images need to be smaller than 50KB ... my bad.
Thanks again, you saved me a lot of headache :)