Problem displaying JPG image on TFT Display

I have a working ESP323CAM and LoRa setup that allows you to remote control the distant camera and download taken images via LoRa that are transferred into an array, saved on SD card, and then displayed on an ILI9341 TFT display.

This works using the TFT_eFEX library which provides the necessary extra functions for the TFT_eSPI library.

However the many recent changes to the ESP32 core appear to have broken the TFT_eFEX library and this was reported on its GitHub back in February, but no fix or comments yet. It works up to ESP32 Core 2.0.14 but not beyond that, and definitely not on the most recent core 3.2.0. There are a few errors like this;

y:\Arduino2\portable\sketchbook\libraries\TFT_eFEX\TFT_eFEX.cpp: In function 'bool jpgDecode(jpg_file_decoder_t*, uint32_t (*)(JDEC*, uint8_t*, uint32_t))':
y:\Arduino2\portable\sketchbook\libraries\TFT_eFEX\TFT_eFEX.cpp:1646:41: error: invalid conversion from 'uint32_t (*)(JDEC*, uint8_t*, uint32_t)' {aka 'long unsigned int (*)(JDEC*, unsigned char*, long unsigned int)'} to 'UINT (*)(JDEC*, BYTE*, UINT)' {aka 'unsigned int (*)(JDEC*, unsigned char*, unsigned int)'} [-fpermissive]
 1646 |     JRESULT jres = jd_prepare(&decoder, reader, work, 3100, jpeg);

So the question is, are there any alternative Arduino libraries that will display a JPG from array or SD file on a TFT display ?

Can you compile with less strict conditions?
It seems it is permissive...
In some libraries I found the same problem. And it compiles with warnings, but it works...

I have no idea, how would you do that ?

I did suspect that Expressif seemed to have, as a default, dropped the use of the permissive flag.

Could be... so you would need to overwrite the default... ... sorry, but I do not know how...
But with uno's you can set the flags more strict, so my guess is thst you can also set it less strict...

Thinking out loud?

  1. Are there examples for the library, do they have the same problem?
  2. Assuming the library has a GitHub page, can you file this issue to the author of the lib?
  3. is it an option to revert to 2.0.14?

As I said in the OP, the issue appears to have been reported.

https://github.com/Bodmer/TFT_eSPI/issues/3667

1 Like

Not checked if there are specific examples for my use case, will do however. The error does appear to be an issue between TFT_eSPI and TFT_eFEX, as in not in my code.

For me its not a problem, I am quite happy with 2.0.14 as Expressif seem to have caused quite a few issues with recent so called library 'upgrades'.

However, I cannot really publish the project if potential users would need to revert their setups to the 2.0.14 ESP32 Core.

Oops, Sorry missed that,

The last commit merged is from July 6, 2024, since that day the maintainer did not have any GitHub activities. There are 200++ open issues and PR's so unlikely to be solved soon.

The library has 1200++ forks, so there might be a few that are ahead of this one.
Will be a very time consuming search.

Hence my question;

"So the question is, are there any alternative Arduino libraries that will display a JPG from array or SD file on a TFT display ?"

Have you seen this library?

This example seems to do more or less what you want: JPEGDEC/examples/esp32_jpeg/esp32_jpeg.ino at master · bitbank2/JPEGDEC · GitHub

I had not seen that library, thanks.

I got a simple text display on a TFT working, via the bb_spi_lcd library which that JPEGDEC library uses.

The display example needs a newer version of the ESP32 core, it fails on 2.0.14 with an error;

fatal error: esp_psram.h: No such file or directory

Using core 3.2.0 the display example does work. That not so much of an issue, its easy to assume others should be using an 'updated' IDE.

Documentation of the display library is fairly limited, as are the provided examples, but setting up fonts, colours and position of text seems OK.

Trying the JPEGDEC library now.

Well, that library does work, I have it displaying a 160x120.jpg file in the middle of a TFT just fine.

Tested with Arduino IDE 2.3.6 and Expressif ESP32 Core 3.2.0.

However the display library (bb_spi_lcd.h) will not co-exist on the SPI bus with the LoRa device. That should not in itself be so much of an issue since the ESP32S3 has 2 spare SPI busses, but need to setup that wiring to check.

I don't understand what that means. What are the symptoms of the problem?

Whichever SPI device you init first, display or LoRa, stops working when the other device is then initialized.

Very strange. Would you mind posting the failing code?

Might occur if the devices use different SPI-modi.

work around is to initialize (every time) before use.

Bit difficult, there is a lot of it. I also needed to modify the LoRa library I was using to allow the SPI instance to be changed, so I could try it on HSPI or FSPI. The full transfer program is circa 2,000 lines with about 8,000 lines of library code.

To simplify it all, I will need to invent a sketch that does the display image from SD card bit and has a simple LoRa RX in it, rather than the whole file transfer bit.

Now thats a thought.

I will check how long the init of display and LoRa device takes.

Sort of success with that approach, although it needed some SPI.end(); added before the SPI.begin();

This function that wrote the LoRa received image from SD card to display;

jd.loadJPEG(&lcd, JPEGDISPLAY_CENTER, JPEGDISPLAY_CENTER, ARFilenamebuff);

Only worked once, then although you could still write text to the display the image did not appear.

However the function to write the PSRAM array direct to the display did keep working;

jd.loadJPEG(&lcd, JPEGDISPLAY_CENTER, JPEGDISPLAY_CENTER, PSRAMptr, arraylength);

So some success. Think I need a simpler sketch to see if there is a way around all the init stuff, the display init is quite long, 800mS or so.