I was recently involved in a ILI9341 related project and missed some features which were already implemented in the original Adafruit lib but not yet in our STM32 variant.
Therefore I added following features to the Adafruit_ILI9341_STM library from Roger’s repo:
– push (RGB565) pixel data array to the LCD (already committed in the Roger’s repo)
– possible to pass an SPI class object reference and SPI clock frequency in main sketch without editing any lib file
– fix reading single + implement reading multiple pixels
– some speed improvements (by optimizing DC and CS pin toggling)
The graphicstest has been extended with single+multiple pixel read test.
Actual benchmark (CPU@72MHz, SPI_1@36MHz):

- new ILI9341 benchmark.jpg (80.28 KiB) Viewed 1402 times
ILI9341 Test!
Display Power Mode: 0x9C
MADCTL Mode: 0x48
Pixel Format: 0x5
Image Format: 0x9C
Self Diagnostic: 0xC0
Read single pixel test
------------------------------
Write pixel: 0x1234
Read pixel: 0x1234
Read multiple pixel test
------------------------------
Write pixels: 0x1234, 0x5678, 0x9012, 0x3456
Read 4 pixels: 0x1234, 0x5678, 0x9012, 0x3456
Benchmark Time (microseconds)
Screen fill 341489
Text 43819
Lines 226266
Horiz/Vert Lines 29315
Rectangles (outline) 19360
Rectangles (filled) 709364
Circles (filled) 154906
Circles (outline) 180807
Triangles (outline) 51422
Triangles (filled) 261140
Rounded rects (outline) 67645
Rounded rects (filled) 789560
Done!
Thanks
I have tested the latest library, using copy in the zip and it seems to work OK.
I’m not sure why when I pulled from your repo, it didnt work for me.
One minor thing which caught me out with the new version of the graphics test, is that it does not run unless the serial monitor is open.
I also think there could be conflicts by requiring Arduino Streaming to use the graphics lib, unless we include that lib as part of the core install.
But people may already have it installed, and we’d then need to keep our copy of it, up to date with the master version
I think its easier simply to include Streaming.h in the example folder and reference that version.
If we’re going to update the graphics test, we should remove all the F() macros used in printing the text etc
I will need to compare the speed / Time with the previous version of the lib, just to make sure the all look OK to me.
BTW.
I’ve also tried running it with differen optimisation and it seems to work fine.
Strangely -O2 is slower for Text than -Os but -O3 is faster and -O3 + LTO is even faster than that.
static SPIClass _spi(1);
tft.begin(_spi); //worked
tft.begin(); // no display
[martinayotte – Wed Aug 16, 2017 5:52 pm] –
@Manny, why are you posting 3 times the same post using replies ?
Haha must be losing it, wont even let me delete them because they have been replied too ![]()
But I have been too busy with other things to do it yet
[stevestrong – Thu Aug 17, 2017 5:14 pm] –
Guys, im on holliday currently, will be back in a week or so.
Steve, when you are back, if you haven’t already you can remove this line, is a leftover from when the DMA transfers were done directly in the library, before adding dmaSend:
https://github.com/stevstrong/Arduino_S … STM.cpp#L7
One more thing, wouldn’t using dmaSendAsync here cause problems since the CS line may be toggled before the transfer is over?
https://github.com/stevstrong/Arduino_S … M.cpp#L243
Since we can use DMA callbacks with the SPI, perhaps we could instead have a function toggle the CS pin when when called?
[RogerClark – Thu Aug 17, 2017 10:25 pm] –
As Steves latest code seems to work OK, I was planning to update the repo with his copy of this library and also his updated SPI lib.But I have been too busy with other things to do it yet
l had compile errors with Steve’s SPI lib and SDfat, other libraries might be affected.
I only tested Steve’s code with the ILI9341 lib. It needs to be tested with a wider range of libs e.g. SD
However, because I am not at home, I cannot test it.
If you discover some bugs or have compile/build errors, please report it on github.
[Manny – Thu Aug 17, 2017 11:13 pm] –
l had compile errors with Steve’s SPI lib and SDfat, other libraries might be affected.
Manny, can you please post here what kind of error messages do you get?
[stevestrong – Fri Sep 01, 2017 2:37 pm] –
Manny, can you please post here what kind of error messages do you get?
Better late than never
I:\Users\Manny\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SdFat\SdSpiSTM32F1.cpp: In member function 'void SdSpi::send(const uint8_t*, size_t)':
I:\Users\Manny\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SdFat\SdSpiSTM32F1.cpp:91:20: error: call of overloaded 'write(const uint8_t*&, size_t&)' is ambiguous
SPI.write (buf, n);
^
I:\Users\Manny\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SdFat\SdSpiSTM32F1.cpp:91:20: note: candidates are:
In file included from I:\Users\Manny\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SdFat\SdSpi.h:124:0,
from I:\Users\Manny\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SdFat\SdSpiSTM32F1.cpp:23:
I:\Users\Manny\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src/SPI.h:274:10: note: void SPIClass::write(uint16, uint32) <near match>
void write(uint16 data, uint32 n);
^
I:\Users\Manny\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src/SPI.h:274:10: note: no known conversion for argument 1 from 'const uint8_t* {aka const unsigned char*}' to 'uint16 {aka short unsigned int}'
I:\Users\Manny\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src/SPI.h:281:10: note: void SPIClass::write(void*, uint32) <near match>
void write(void * buffer, uint32 length);
^
I:\Users\Manny\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\SPI\src/SPI.h:281:10: note: no known conversion for argument 1 from 'const uint8_t* {aka const unsigned char*}' to 'void*'
Anyway,I posted two PRs to Greiman’s repo to solve this issue. https://github.com/greiman/SdFat/pulls
[stevestrong – Mon Sep 18, 2017 12:08 pm] –
Manny, I see that you are using non-DMA transfers. Is there any reason why you don’t use DMA transfers?Anyway,I posted two PRs to Greiman’s repo to solve this issue. https://github.com/greiman/SdFat/pulls
Good spot on the DMA…anyway, downloaded Greiman’s repo and its all working with the Adafruit_ILI9341_STM and SPI libs from your repo.


