Skip to content

Slower drawBitmap function and errors while compiling for avr128db48 #29

@chradev

Description

@chradev

Hi to All

I am testing both Adafruit_ILI9341 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:

  • defining of pins for all MCUs - this part was also added to User_Setup.h of TFT_ ILI9341 library
  • adding 2 more tests for filling of screen by pixels and bitmaps
  • adding a test for moving the screen by 1 pixel row and filling the free one

For compatibility I have added following functions like in Adafruit_ILI9341 library

  • void setScrollMargins(uint16_t top, uint16_t bottom)
  • void scrollTo(uint16_t y)
  • void drawBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h)

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 Adafruit_ILI9341 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:

  • luck of ttf.print and ttf.println functions in TFT_ILI9341 library witch is very helpful for printing the texts
  • for Arduino UNO (ATMega328) and Leonardo (ATMega32u4) "Fill screen by bitmaps" is 1.6 times slower than Adafruit_ILI9341 library and approximately 2 time slower than than Adafruit_ILI9341 for avr128db48;
  • for Arduino Optiboot / avr128db48 "Fill screen by pixels" is more than 3 times slower than TFT_ILI9341 for other 2 MCUs;
  • there are multiply errors wile compiling for Arduino Optiboot / avr128db48 mainly undeclared registers like SPSR, SPDR, SPIF etc.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions