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?
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
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).
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.
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?
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
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()
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
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.
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