I am building a project based on a STM32F1 running at 72Mhz and a ILI9486 connected to SPI1, clock divider is 1 .
It is working quite well at the moment, my only concern is the slow draw times.
I am drawing images via 2 loops and drawPixel, library is https://github.com/stevstrong/Adafruit_ … ree/master based on the Adafruit GFX.
the times are:
timeSpendReadingFlash=191 millis
timeSpendRendering=1915 millis
this is for rendering:
1x 320×240
1x 320×45
1x 320×26
1x 320×21
1x 38×21
a total of 107038 pixels
Is there any way to speed this up ? a UI based on this solution is really sluggish.
What I tried:
Overclock the STM32 to 128mhz result: some small speed improvements but nothing special.
timeSpendRendering=2015
timeSpendSettingWindow=1652
timeSpendSettingColor=256
it seems that most of the time is spent setAddrWindow.
By the looks of it it seems that setAddrWindow sets a window of memory of 1 pixel at the time. Increasing the window to more pixels should in theory decrease the draw times.
Try to write several pixels in the same block.
You could prepare first in memory the block to be written down to display.
Try to write several pixels in the same block.
You could prepare first in memory the block to be written down to display.
screenDraw=89
void SPIClass::writeBuffer(uint16_t *data, uint32_t length){
spi_reg_map * regs = _currentSetting->spi_d->regs;
for(uint32_t i; i<length i++){
// Serial3.print("index=");Serial3.println(tmp-length);
regs->DR = data[i]; // write the data to be transmitted into the SPI_DR register (this clears the TXE flag)
while ( (regs->SR & SPI_SR_TXE)==0 ) ; // wait till Tx empty
}
while ( (regs->SR & SPI_SR_BSY) != 0); // wait until BSY=0 before returning
}
isn’t this what SPIClass::write(const void *data, uint32 length) is suppose to do ?
isn’t this what SPIClass::write(const void *data, uint32 length) is suppose to do ?
uint16_t tmpData[48] = {GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE};
uint16_t *p = tmpData;
SPI.write(p, 48);
SPI.write(tmpData, 48);I just wanted “extra measures” to make sure I did not mess something up.
It might be spi.c in the core as the SPI.c implementation seems fine will try to debug when I have free time.
Thanks for the help.
Quick question, OFFTOPIC: I am confronting myself with screen tearing (refresh of the screen hits when I am drawing the frame)…any idea how to avoid this ?
The common display modules do not offer any screen refresh signals, so I don’t think you can do it without disassembling the module and hook the signals from the driver chip pins.



