Bodmer / TFT_ILI9341

A fast Arduino IDE compatible graphics and fonts library including a driver for the ILI9341 based TFT displays.
112 stars 33 forks source link

Slower drawBitmap function and errors while compiling for avr128db48 #29

Open chradev opened 1 year ago

chradev commented 1 year ago

Hi to All

I am testing both AdafruitILI9341 and TFT ILI9341 libraries for Arduino UNO (ATMega328), Leonardo (ATMega32u4) and Optiboot (avr128db48) MCUs modifying Adafruit grapic test and got following results:

UniedTestResuls

The main modifications in the sketch are:

For compatibility I have added following functions like in Adafruit_ILI9341 library

and every thing works fine excluding impossibility to compile the sketch for Optiboot / avr128db48 in case of using TFT_ ILI9341 library

Moving and filling are made by drawBitmap for AdafruitILI9341 and fastPixel for TFT ILI9341 functions

void drawBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h) {
  int16_t i, j;
  tft.fastSetup();
  for (j = 0; j < h; j++) {
    for (i = 0; i < w; i++ ) {
      tft.fastPixel(x + i, y + j, bitmap[i + j * ILI9341_TFTWIDTH]);
    }
  }
}

void loop() {
#ifdef LIB_Adafruit_ILI9341
  tft.scrollTo(y);
  for (uint8_t x = 0; x < ILI9341_TFTWIDTH; x++) {
    data[x] = y + x << 5;
  }
  tft.drawRGBBitmap(0, y, data, ILI9341_TFTWIDTH, 1);
#elif defined(LIB_TFT_ILI9341)
  scrollTo(y);
  for (uint8_t x = 0; x < ILI9341_TFTWIDTH; x++) {
    tft.fastPixel(x, y, y + x << 5);
  }
#else
#endif
  y++;
  if (y >= ILI9341_TFTHEIGHT) {
    // full screen is scrolled
    y = 0;
  }
}

Full Arduino sketch: Unified_ili9340_Graphic_Test.ino.txt. For testing rename it (Unified_ili9340_Graphic_Test.ino) and put it in same name folder (Unified_ili9340_Graphic_Test).

I noticed following issues for TFT_ILI9341 library:

I understand that last issue may require porting but it is probably relatively simpler because of MCUs similarity while the first one is a case of complete compatibility. The rest 2 issues are probably my faults in using TFT_ILI9341 library.

Any advises and suggestions will be appreciated. Thanks in advance!

Best regards Chris

chradev commented 1 year ago

The test was alredy on GitHub: Unified ILI9341 Graphic Test