From dbb404a63f5963027e83b6a287befe1bb0d52804 Mon Sep 17 00:00:00 2001 From: sfromis <47082390+sfromis@users.noreply.github.com> Date: Thu, 10 Oct 2024 23:13:07 +0200 Subject: [PATCH] Fixing build error xdrv_13_display.ino with JPEG_PICTS On ESP32, with `#define JPEG_PICTS` without the scripter, build fails due to the function `Draw_jpeg` being defined after use. Order swapped to satisfy the compiler. Change tested to compile without errors, but not being 100% sure of when/how it is supposed to work, no verification of this. --- .../tasmota_xdrv_driver/xdrv_13_display.ino | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_13_display.ino b/tasmota/tasmota_xdrv_driver/xdrv_13_display.ino index 545040ef9a17..a7afe6d47d99 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_13_display.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_13_display.ino @@ -2442,6 +2442,28 @@ void Draw_RGB_Bitmap(char *file, uint16_t xp, uint16_t yp, uint8_t scale, bool i #ifdef ESP32 #ifdef JPEG_PICTS #define JPG_DEFSIZE 150000 +void Draw_jpeg(uint8_t *mem, uint16_t jpgsize, uint16_t xp, uint16_t yp, uint8_t scale) { + if (mem[0] == 0xff && mem[1] == 0xd8) { + uint16_t xsize; + uint16_t ysize; + get_jpeg_size(mem, jpgsize, &xsize, &ysize); + //AddLog(LOG_LEVEL_INFO, PSTR("Pict size %d - %d - %d"), xsize, ysize, jpgsize); + scale &= 3; + uint8_t fac = 1 << scale; + xsize /= fac; + ysize /= fac; + renderer->setAddrWindow(xp, yp, xp + xsize, yp + ysize); + uint8_t *rgbmem = (uint8_t *)special_malloc(xsize * ysize * 2); + if (rgbmem) { + //jpg2rgb565(mem, jpgsize, rgbmem, JPG_SCALE_NONE); + jpg2rgb565(mem, jpgsize, rgbmem, (jpg_scale_t)scale); + renderer->pushColors((uint16_t*)rgbmem, xsize * ysize, true); + free(rgbmem); + } + renderer->setAddrWindow(0, 0, 0, 0); + } +} + void Draw_JPG_from_URL(char *url, uint16_t xp, uint16_t yp, uint8_t scale) { uint8_t *mem = 0; WiFiClient http_client; @@ -2484,28 +2506,6 @@ void Draw_JPG_from_URL(char *url, uint16_t xp, uint16_t yp, uint8_t scale) { } if (mem) free(mem); } - -void Draw_jpeg(uint8_t *mem, uint16_t jpgsize, uint16_t xp, uint16_t yp, uint8_t scale) { - if (mem[0] == 0xff && mem[1] == 0xd8) { - uint16_t xsize; - uint16_t ysize; - get_jpeg_size(mem, jpgsize, &xsize, &ysize); - //AddLog(LOG_LEVEL_INFO, PSTR("Pict size %d - %d - %d"), xsize, ysize, jpgsize); - scale &= 3; - uint8_t fac = 1 << scale; - xsize /= fac; - ysize /= fac; - renderer->setAddrWindow(xp, yp, xp + xsize, yp + ysize); - uint8_t *rgbmem = (uint8_t *)special_malloc(xsize * ysize * 2); - if (rgbmem) { - //jpg2rgb565(mem, jpgsize, rgbmem, JPG_SCALE_NONE); - jpg2rgb565(mem, jpgsize, rgbmem, (jpg_scale_t)scale); - renderer->pushColors((uint16_t*)rgbmem, xsize * ysize, true); - free(rgbmem); - } - renderer->setAddrWindow(0, 0, 0, 0); - } -} #endif // JPEG_PICTS #endif // ESP32