bitbank2 / JPEGDEC

An optimized JPEG decoder suitable for microcontrollers and PCs.
Apache License 2.0
390 stars 46 forks source link

M5 stack #19

Closed kd8bxp closed 3 years ago

kd8bxp commented 3 years ago

examples for some of the M5Stack devices. These are slightly modified versions of the adafruit_gfx_demo.
Extra Images were included:
The Star Ship ENTERPRISE "NCC-1701" from http://clipart-library.com/clip-art/uss-enterprise-silhouette-11.htm
And an image of "Batman" from http://clipart-library.com/clipart/batman-clip-art_19.htm

The JPEGDraw function was changed for use with the M5Stack devices.

M5.Lcd.drawBitmap((int16_t)pDraw->x, (int16_t)pDraw->y, (int16_t)pDraw->iWidth, (int16_t)pDraw->iHeight, pDraw->pPixels);

Another small change was to add a check if the image had a thumbnail or not, and call the correct jpg decode routine.
if (jpeg.hasThumb()) {jpeg.decode(iCenterX[i],iCenterY[i],JPEG_EXIF_THUMBNAIL | iOption[i]); } else { jpeg.decode(iCenterX[i],iCenterY[i], iOption[i]); }

To display the other images, uncomment the image you want to display, comment the others.
Also uncomment the line with the name of the image you want to display, and comment the others.
if (jpeg.openFLASH((uint8_t )thumb_test, sizeof(thumb_test), JPEGDraw))
//if (jpeg.openFLASH((uint8_t
)ncc1701, sizeof(ncc1701), JPEGDraw))
//if (jpeg.openFLASH((uint8_t *)batman, sizeof(batman), JPEGDraw))

M5Stack, M5Core2 and M5Fire sketches are almost the same, the difference is how you start the screen on the Fire, and M5Core2.
M5StickC and M5StickCPlus are the same with the difference being which library is used (either M5StickC.h or M5StickkCPlus.h) and display size between the two devices.

Tested on:
M5Stack Gray
M5Stack Fire
M5StickC
M5StickC Plus
M5Core2

Untested: (should work with M5Stack, but unable to test)
M5Stack Basic (should work)
M5Go Lite
M5Go

bitbank2 commented 3 years ago

I'm happy to merge your example sketches. The only criticism I have is the size of the sample images you chose. Images that are much higher resolution than the TFT display and bigger than 80K bytes each probably shouldn't be added to an Arduino library. Let me know if you plan to make the total "weight" of this change a little lighter.

kd8bxp commented 3 years ago

Fair enough, and I will resize the images to be more manageable.

kd8bxp commented 3 years ago

I also included the resized images, I think this is the best I can do. I replaced one of the batman images with another, because even after resizing the file was still 400+k.

bitbank2 commented 3 years ago

Thanks for reducing the file sizes and for sharing your demo sketches

kd8bxp commented 3 years ago

Thank you for sharing/creating this to start with. Happy I was able to give a little back, and hope others will enjoy using these with the M5Stack devices. Thank you.