Go Down

Topic: New graphics library for NodeMCU (ESP8266), ESP32 and SPI based TFT displays (Read 10197 times) previous topic - next topic

tsjim


Hello Bodmer!

Thank you SO MUCH for all your work on this stuff.  My project is going to ROCK because of you.

Can you or anyone tell me why I'm getting these artifacts when I try to display JPG images with your libraries?











Here's my code (based on your NodeMCU_Jpeg example sketch):

Code: [Select]


#define FS_NO_GLOBALS
#define TFT_BLACK 0
#include <FS.h>
#include <JPEGDecoder.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI();

void setup()
{
  Serial.begin(9600); // Used for messages and the C array generator
  delay(10);
  Serial.println("NodeMCU decoder test!");
  tft.begin();
  tft.setRotation(0);  // 0 & 2 Portrait. 1 & 3 landscape
  tft.fillScreen(TFT_BLACK);
  if (!SPIFFS.begin()) {
    Serial.println("SPIFFS initialisation failed!");
    while (1) yield(); // Stay here twiddling thumbs waiting
  }
  Serial.println("\r\nInitialization done.");
  listFiles(); // Lists the files so you can see what is in the SPIFFS
}

void loop()
{
  tft.setRotation(0);  // portrait
 
  // Display Gear Image
  tft.fillScreen(TFT_BLACK);
  drawJpeg("/t5_gear.jpg", 0, 0);
  delay(2000);

  //Display Water Day image
  tft.fillScreen(TFT_BLACK);
  drawJpeg("/waterday.jpg", 0, 0);
  delay(2000);
}



I have attached both of the original 240x320 JPG image files to this message...maybe there's something wrong with how they are encoded?  I cannot figure this out.

Thank you so much for your help!


bodmer

Hi tsjim,

Assuming the library example images display OK, then I suspect the encoding format is the problem.

It looks like the MCU size is 8x8 whereas the examples I have tested are 16x16.

It looks like you have used Photoshop to encode the jpeg, perhaps try a different image edit program and try that.

I do not have access to my Arduino stuff at the moment so cannot test. If there is a bug in the 8x8 decoding then I will see if I can track it down.  The other possibility is that the SPI clock frequency is too high for the display. Try 27MHz if you think that may be the case.

Formerly Rowboteer (now a broken user profile!)

bodmer

Hi tsjim,

I checked the JPEGDecoder library with you files and get the same results on a NodeMCU and a Mega with a different graphics library so the problem must be in the JPEGDecoder library somewhere. The images are encoded as 8x8 MCU blocks and it looks like the decoder does not like this.  I used IrfanView to re-saved one of the files and this turned it into a 16x16 MCU size and this renders fine.  It also renders faster.  See attached.

I have not managed to track down this bug so the only work-around is to use jpeg files encoded in 16x16 MCU blocks.  I will post this as an issue on Github.
Formerly Rowboteer (now a broken user profile!)

bodmer

Hi tsjim,

I have tracked down the bug and corrected it in the picojpeg.c code.

Download the latest JPEGDecoder library via the IDE Library manager (now at 1.7.7). It may take a day for the IDE to see the latest version.  Or download a copy direct from Github.

The 8x8 MCU sized jpegs should render OK now.

Tip: The original Jpeg was 80kbytes, if you reduce the quality to make it 20kbytes then it will render faster when loading from SPIFFS.
Formerly Rowboteer (now a broken user profile!)

tsjim


Hi Bodmer...

That was it!  It works perfectly now.  Awesome.

Thank you very much!

bodmer

I have added Espressif ESP32 processor support to the TFT_eSPI library.

So far this has been tested with an ILI9341 based display.
Formerly Rowboteer (now a broken user profile!)

Go Up