FunGuy
Posts: 6
Joined: Sat Jan 06, 2018 10:11 am

Move ili9341 TFT display to SPI1

Sun Jan 07, 2018 11:51 pm

I was hoping somebody could help me. I am quite a new user to RPI and experimenting a lot. I have a sensor which communicates using SPI to the Pi 3 Model B+ and it works great. I also have TFT screen running an ili9341 driver display also using SPI. Here is my problem: The sensor can only operate on SPI mode 3 and consumes a lot of bandwidth. The TFT screen operates in SPI mode 0 and consume reasonable amount of bandwidth on the bus. I decided to use 2 SPI buses, namely /dev/spi0 and /dev/spi1. I have read on some blogs that the primary SPI (/dev/spi0) support all modes of SPI. I have confirmed this as both devices operate correctly on SPI0. I have also read that the aux SPI (/dev/spi1) does not support all modes of SPI. I have confirmed this that the sensor operating on SPI0 does not work on SPI1 unless I change the mode (but then I receive garbage data which was expected). So the sensor which consumes a lot of bandwidth is stuck on the primary SPI bus. I see there a lot of pre-made images for the TFT displays, but they all use SPI0 to drive the screen. I have tried to hack the code (with very little success) to move the TFT to aux SPI (/dev/spi1). Is there an easy way to do it?

Thanks in advance for any assistance.

HermannSW
Posts: 676
Joined: Fri Jul 22, 2016 9:09 pm

Re: Move ili9341 TFT display to SPI1

Wed Jan 10, 2018 2:31 pm

Yes, please follow the link in this posting:
viewtopic.php?t=193722#p1217930
Image
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

FunGuy
Posts: 6
Joined: Sat Jan 06, 2018 10:11 am

Re: Move ili9341 TFT display to SPI1

Thu Jan 25, 2018 11:51 am

Thank you! This really did the trick! You saved me a lot of effort

FunGuy
Posts: 6
Joined: Sat Jan 06, 2018 10:11 am

Re: Move ili9341 TFT display to SPI1

Sun Feb 25, 2018 11:27 am

I have another question. I can send the image giraffe.565 to the tft using your recommendation of

sudo tail --bytes 153600 /home/pi/giraffe.565 > / dev/fb1

It works beautifully! I am also learning Qt (tying to expand my horizons a bit), and I do the following:

QFile file("/home/pi/giraffe.565");
file.open(QIODevice::ReadOnly);
QByteArray qb = file.readAll();
qb.remove(0,54);
printf("qb size %d\n",qb.size());
QFile tft("/dev/fb1");
tft.open(QIODevice::WriteOnly);
tft.write((char*)qb.data());

This works, but the image is displayed with a slight offset (I can see mixture of blocks). It seems it is having trouble synching the new lines to the tft screen. So my question is what is the difference between? What am I doing wrong?

Thanks in advance!

HermannSW
Posts: 676
Joined: Fri Jul 22, 2016 9:09 pm

Re: Move ili9341 TFT display to SPI1

Mon Feb 26, 2018 8:44 am

File size is 153666, so you need to "qb.remove(0,66)" and not only 54 bytes:.
http://doc.qt.io/qt-5/qbytearray.html#remove
pi@raspberrypi05:~ $ ls -l giraffe.565
-rw-r--r-- 1 pi pi 153666 Nov 6 2015 giraffe.565
pi@raspberrypi05:~ $
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

FunGuy
Posts: 6
Joined: Sat Jan 06, 2018 10:11 am

Re: Move ili9341 TFT display to SPI1

Mon Feb 26, 2018 11:04 am

On my RPI3 it says
-rw-r--r-- 1 pi pi 153654 Jan 29 2018 giraffe.565

I thought it was 320 x 240 x 2 (bytes) = 153600 bytes
565 header file is 54 bytes.

I have downloaded several different 16 bit images and they all report the same size on my RPI3. Do you any other ideas? I have been at it a few nights and my ideas are running out?

FunGuy
Posts: 6
Joined: Sat Jan 06, 2018 10:11 am

Re: Move ili9341 TFT display to SPI1

Mon Feb 26, 2018 11:08 am

I think I got it, arghhh! When writing in Qt passing the QByteArray needs a size as second parameter. It is not working properly yet, but is 98% correct!

Amended command
tft.write((char*)qb.data(),153600);

HermannSW
Posts: 676
Joined: Fri Jul 22, 2016 9:09 pm

Re: Move ili9341 TFT display to SPI1

Mon Feb 26, 2018 10:11 pm

Nice that you found the solution.

In case you need more samples, I found the giraffe and others here:
https://github.com/marekburiak/ILI9341_ ... map/images

"ILI9341_due" is the fastest ILI9341 library for the (84MHz, 12$) Arduino Due:
https://github.com/marekburiak/ILI9341_due
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

FunGuy
Posts: 6
Joined: Sat Jan 06, 2018 10:11 am

Re: Move ili9341 TFT display to SPI1

Wed Mar 07, 2018 12:12 am

Awesome, thank you for all the info. I got it working perfectly eventually. I needed to cast the size of the length of the byte array to unsigned int64. It works beautifully!

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 8 guests