arduino ili9341 faster draw

Hello ,

i want that my ili9341 display with spi draws faster.
i use adafruit libary and run the graphics test example but for example when it makes te screen blue it takes 2 seconds to do that.
But when i draw a bmp it takes 3 seconds and thats is a little bit slow.
so what can i do to make it draw faster?
Will overclock it to 40 mhz work?
what have i to do to make it faster?

Can anyone help me?

thanks

You might take a look at the algorithms used. Often the standard libraries have generic code that works for more than once LCD. It is possible that you can optimize the library for faster displaying. Takes some time but can be fun (imho)

Have a look at this thread to see how to approach optimization for a display

For ILI9341 on Arduino Due, this post: ILI9341(new)SPI library for Due supporting DMA transfer(Uno, Mega,.. compatible) - Displays - Arduino Forum

Speed... like this?

PD: MEGA or UNO = slow

@TFTLCDCyg
that's quite fast ...

TFTLCDCyg:
For ILI9341 on Arduino Due, this post: ILI9341(new)SPI library for Due supporting DMA transfer(Uno, Mega,.. compatible) - Displays - Arduino Forum

Speed... like this?

PD: MEGA or UNO = slow

yes speed like that.
What makes it so fast?

the amount of mhz?
or the amount of ram?

It depends on MHz but the most speed gain is from the usage of DMA available in Due's CPU. And also on how well is the library optimized for a certain display.
Btw. there is (probably even faster) ILI9341_t3 library for Teensy 3.1 which uses FIFO buffers for speedy transfers. And the fastest I've seen on Mega is this (not ILI9341 though).

Double check your SPI clock settings...

pito:
Double check your SPI clock settings...

how to dounle check my spi settings?

MarekB:
It depends on MHz but the most speed gain is from the usage of DMA available in Due's CPU. And also on how well is the library optimized for a certain display.
Btw. there is (probably even faster) ILI9341_t3 library for Teensy 3.1 which uses FIFO buffers for speedy transfers. And the fastest I've seen on Mega is this (not ILI9341 though).

what do u mean with dma in the dues cpu?

and so what have i to do to make it show for example bmps faster?
I dont want to buy a arduino due.

DMA - Direct memory access - Wikipedia

Due's CPU has a DMA controller. Uno, Mega, Nano and other AVR-ish Arduinos do not have it so you just can't speed up SPI CPU->TFT transfer on them.

If you need SPI, then I guess only ARM-based boards (like Due or Teensy) can push the pixels fast enough.

I dont want to buy a due or teensy.
can i buy a for example a single atsam3x8c with less pins or another chip like that?
and put on that chip the bootloader?
and if i put the bootloader on it will all the arduino functions work?

Bumb

I mean if any woult know a answer on this:

arduino123456789:
I dont want to buy a due or teensy.
can i buy a for example a single atsam3x8c with less pins or another chip like that?
and put on that chip the bootloader?
and if i put the bootloader on it will all the arduino functions work?
2

arduino123456789:
how to dounle check my spi settings?

Have you checked it already?

Think it is time to post a minimal sketch that is too slow in your opinion

  • attach a zip of the adafruit library used

does adafruit provide a tutorial page about this LCD?
normally they do

the tutorial for my display is:

the libary i am using:
https://github.com/adafruit/Adafruit_ILI9341/archive/master.zip
in this zip are the examples too.(i use the graphicstest example)

but can i use for example a single ATSAM3U4CA-AU becouse it use less pins?
and burn the bootloader on it?
should then all the arduino functions work?

A quick look at the library shows it uses 8Mhz SPI (DIV2) when HW spi constructor is used.

The library does only support very few higher level functions and you could add those functions.


an interesting speedup might be replacing all digitalWrite() with direct port manipulation.

void digitalWrite(uint8_t pin, uint8_t val)
{
	uint8_t timer = digitalPinToTimer(pin);
	uint8_t bit = digitalPinToBitMask(pin);
	uint8_t port = digitalPinToPort(pin);
	volatile uint8_t *out;

	if (port == NOT_A_PIN) return;

	// If the pin that support PWM output, we need to turn it off
	// before doing a digital write.
	if (timer != NOT_ON_TIMER) turnOffPWM(timer);

	out = portOutputRegister(port);

	uint8_t oldSREG = SREG;
	cli();

	if (val == LOW) {
		*out &= ~bit;
	} else {
		*out |= bit;
	}

	SREG = oldSREG;
}

you should add variables in the class for bit and port for all the pins used e.g. _cs, and _dc.
uint8_t _cs_bit, _cs_out, _dc_bit, _dc_out;

these 4 must be initialized in the begin() function just like they are derived in the first digitalWrite()

uint8_t _cs_bit = digitalPinToBitMask(_cs);
uint8_t port = digitalPinToPort(_cs);
volatile uint8_t *_cs_out;
_cs_out = portOutputRegister(port);

uint8_t _dc_bit = digitalPinToBitMask(_dc);
port = digitalPinToPort(_dc);
volatile uint8_t *_dc_out;
_dc_out = portOutputRegister(port);

then you can replace every

digitalWrite(_dc, LOW); ==> *_dc_out &= ~_dc_out;
digitalWrite(_dc, HIGH); ==> *_dc_out |= _dc_out;

idem for _cs

should make things faster.

your turn to implement and test

i dont understand how to change the code.
could u please upload the libary with the code that makes it faster?
or upload the code from the sketch.
and if this draw the graphicstest example faster should it draw a bmp faster too?

i dont understand how to change the code
To change the code you just need an editor like notepad++. DOn't forget to make a backup copy.
Look at how the library code is written and how often it calls digitalWrite. Then look at theproposal

Sorry I cannot explain better, you can read - http://www.arduino.cc/en/Reference/PortManipulation - for a backgrounder

How much programming experience do you have?

could u please upload the libary with the code that makes it faster?
sorry, my time is limited and I have no display to test so that would take too much of my time.

and if this draw the graphicstest example faster should it draw a bmp faster too?
I think it should but I did not investigate the drawing of BMP's in detail.
The code proposed should increase the speed of all operations with the display.

example

uint8_t Adafruit_ILI9341::spiread(void) {
  uint8_t r = 0;

  if (hwSPI) {
#if defined (__AVR__)
    uint8_t backupSPCR = SPCR;
    SPCR = mySPCR;
    SPDR = 0x00;
    while(!(SPSR & _BV(SPIF)));
    r = SPDR;
    SPCR = backupSPCR;
#elif defined(TEENSYDUINO)
    r = SPI.transfer(0x00);
#elif defined (__arm__)
    SPI.setClockDivider(11); // 8-ish MHz (full! speed!)
    SPI.setBitOrder(MSBFIRST);
    SPI.setDataMode(SPI_MODE0);
    r = SPI.transfer(0x00);
#endif
  } else {

    for (uint8_t i=0; i<8; i++) {
      digitalWrite(_sclk, LOW);  <<<<<<<<<<<<<<<< this line 
      digitalWrite(_sclk, HIGH); <<<<<<<<<<<<<<<< this line 
      r <<= 1;
      if (digitalRead(_miso))  <<<<<<<<<<<<<<<< this line 
	r |= 0x1;
    }
  }
  //Serial.print("read: 0x"); Serial.print(r, HEX);
  
  return r;
}
 uint8_t Adafruit_ILI9341::readdata(void) {
   digitalWrite(_dc, HIGH);  <<<<<<<<<<<<<<<< this line 
   digitalWrite(_cs, LOW);  <<<<<<<<<<<<<<<< this line 
   uint8_t r = spiread();
   digitalWrite(_cs, HIGH);  <<<<<<<<<<<<<<<< this line 
   
   return r;
}
uint8_t Adafruit_ILI9341::readcommand8(uint8_t c, uint8_t index) {
   if (hwSPI) spi_begin();
   digitalWrite(_dc, LOW); // command    <<<<<<<<<<<<<<<< this line 
   digitalWrite(_cs, LOW);  <<<<<<<<<<<<<<<< this line 
   spiwrite(0xD9);  // woo sekret command?
   digitalWrite(_dc, HIGH); // data  <<<<<<<<<<<<<<<< this line 
   spiwrite(0x10 + index);
   digitalWrite(_cs, HIGH);  <<<<<<<<<<<<<<<< this line 

   digitalWrite(_dc, LOW);  <<<<<<<<<<<<<<<< this line 
   digitalWrite(_sclk, LOW);  <<<<<<<<<<<<<<<< this line 
   digitalWrite(_cs, LOW);  <<<<<<<<<<<<<<<< this line 
   spiwrite(c);
 
   digitalWrite(_dc, HIGH);  <<<<<<<<<<<<<<<< this line 
   uint8_t r = spiread();
   digitalWrite(_cs, HIGH);  <<<<<<<<<<<<<<<< this line 
   if (hwSPI) spi_end();
   return r;
}

It is allready done in the write commands like this

*dcport |= dcpinmask; //digitalWrite(_dc, HIGH);
*dcport &= ~dcpinmask; //digitalWrite(_dc, LOW);

*csport &= ~cspinmask; //digitalWrite(_cs, LOW);
*csport |= cspinmask; //digitalWrite(_cs, HIGH);

The above are the display specific class.
More optimizations should be searched for in the Adafruit_GFX library code

Found this link - GitHub - PaulStoffregen/ILI9341_t3: Optimized ILI9341 TFT Library - might be of interest, but might be teensy specific.

discussed here - Highly optimized ILI9341 (320x240 TFT color display) library [Archive] - PJRC (Teensy) Forum -