Skip to content

Commit

Permalink
Fixing build error xdrv_13_display.ino with JPEG_PICTS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sfromis authored Oct 10, 2024
1 parent cc6ec36 commit dbb404a
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions tasmota/tasmota_xdrv_driver/xdrv_13_display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit dbb404a

Please sign in to comment.