3

I've been trying to get this ST7789 library working with the 240x240 1.3" display on the rpi0w

Python lib

https://github.com/solinnovay/Python_ST7789

So far I've set all the screen pins to the bcm spi1 pins on the pi and updated them in my script to match. I've also tried setting the spi device / port to 1 and in various combinations of 1,0 0,1 1,1 and so on.

Photos of connections: https://m.imgur.com/gallery/xPBa166 There is no chip select on this breakout board. I have connected gnd vcc sda (mosi) scl res dc and bl/led setup on spi1

Please see his clock_EN.py in examples for parameters example.

So far I have not been able to display anything on the screen when connected to spi1. But connected to spi0 everything works as expected.

I've contacted the author but haven't received a reply.

Is it as simple as changing the script parameters and connecting the screen to the spi1 pins or is the spi device hard coded into his library?

My goal is to have 1 screen running on spi0 and another on spi1.

Thanks in advance.

3
  • I once looked at the WaveShare SPI driver thing and found that they hard coded for SPI0 only (They did NOT develope the touch LCD for two mon situation). Another touch TFT LCD for ILI9341 based kernel also has a fixed channel SPI0 - you CANNOT build a kernel using SPI1. Many users want to use two mons at the same time. Me too. But my quick and dirty conclusion is that it is mission impossible.
    – tlfong01
    Oct 22, 2019 at 9:17
  • Hi tlfong01 I think you might be referencing a different display altogether. This is the display in question displaymodule.com/products/… Oct 22, 2019 at 9:36
  • My apologies for my careless mistake of the wrong conclusion on your ST7789 LCD. Yes, as you said, ST7789 LCD is completely different from what I have been studying. Your LCD's driver is a python program, NO need to build any newbie scary driver/kernel. There is some hope (20%, I think) of setting up dual mon or triple mon. So I quickly skimmed the docs and draft a brainstorming answer.
    – tlfong01
    Oct 22, 2019 at 14:07

3 Answers 3

1

clock_EN.py has the line:

disp = TFT.ST7789(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=SPI_SPEED_HZ),
       mode=SPI_MODE, rst=RST, dc=DC, led=LED)

The intention appears to be that the bus is defined by SPI_PORT and the chip select by SPI_DEVICE.

So set SPI_PORT and SPI_DEVICE and connect the device as follows

                                     DEVICE 0    DEVICE 1    DEVICE 2
                   MISO  MOSI  SCLK  CE0         CE1         CE2
PORT 0 | Main SPI    9    10    11    8           7           -
PORT 1 | Aux SPI    19    20    21   18          17          16

Of course if the display doesn't have a chip select line you will have to use different buses and can ignore the chip selects.

5
  • Thanks for your reply Joan. This is the display displaymodule.com/products/… it has no chip select but I don't see that being an issue if I'm using spi0 and spi1. I did try connecting a single display to the spi1 bcm pins and tried various combinations of port / device 1/0. Is there something I'm missing? Oct 22, 2019 at 9:25
  • Could you add a photo of the connections when connected to SPI bus 1 (the auxiliary SPI device)?
    – joan
    Oct 22, 2019 at 9:46
  • Thanks Joan, here are the images imgur.com/a/xPBa166 I used the base pin numbers specified in the clock Python script but tried changing the port and device numbers unfortunately with no luck. Oct 22, 2019 at 20:01
  • were you able to open the images I uploaded? thanks Oct 24, 2019 at 7:53
  • You should add clarifying information (e.g. photos) to your question. I can only see MOSI and SCLK connected.
    – joan
    Oct 24, 2019 at 8:03
0

Question

How to talk to an ST7789 LCD connected to SPI #1?


Answer

Update 2019oct23hkt0928

For those with little experience of rewiring delicate ribbon cables, perhaps the follow 12 pin breakout version (Ref 8)is worth trying:

12 pin lcd


I think we need to do two things:

(1) Change ST7789 LCD's CS connection from Ground to CS1 (Note 1),

(2) Change Python_ST7789/examples/clock_EN.py's statement form SPI_PORT = 0 to SPI_PORT = 1

Note 1 - I used to cheat the SPI device by connecting its CS pin NOT to CS0 or CS1. Instead, I connect to other Rpi GPIO pins (as CS0, CS1, CS2, ... CSn pins), or even to MCP23017 I/O expander's GPIO pins. So if my trick here works, I can use a MCP23017 and have 16 time multiplexed LCDs! :)


st7789 1


st7789 1


Update 2019nov10hkt1559

wiring 2


st7789 wiring


References

(1) Display Module DM-TFT13-377 1.3" 240 X 240 IPS TFT Display Module-SPI -$10

(2) AliExpress IPS 1.3 inch 3.3V 12 PIN SPI TFT LCD ST7789 240 * 240 US$3

(4) Display Module 1.3 SPI TFT LCD User Guide

(5) ST7789VW Datasheet - Sitronix

(6) Python ST7789 GitHub - solinnovay

(7) ST7789 GitHub Example Program (Python_ST7789/examples/clock_EN.py)

(8) AliExpress IPS 1.3" 240x240 12 pin SPI TFT LCD ST7789 - US$2


Appendices

Appendix - How to change clock_EN.py for SPI CS #1

Raspberry Pi pin configuration:

RST = 27 DC  = 25

LED = 24

SPI_PORT = 0 >>>>>> change to SPI_PORT = 1

SPI_DEVICE = 0

SPI_MODE = 0b11 SPI_SPEED_HZ = 40000000


End of answer

5
  • 1
    Thanks for your answer. Although this display module supports chip select, it is not included in the breakout board. I'm not confident breaking out the ribbon cable by hand. Please let me know if I'm misunderstanding something. Thanks for mentioning about the multiplexer too, I might look in to it in future. Oct 22, 2019 at 17:39
  • @nosuchintel, (1) Ah yes, you need some skills to extract the CS wire from the breakout. Perhaps I will show my steps, in case other newbies would like to take the risk. (2) The CS multiplexing thing is a bit complicated. Perhaps I can search my old answers in other forums and explain in a bit more details. This is a general trick for ALL SPI devices. I usually use it for multiple sensors. (1) Yes, you understand what I said perfectly. Actually I hesitate to give this answer and risky hardware get around to newbies. But since you already dug deep into the python driver part, .. Cheers!
    – tlfong01
    Oct 23, 2019 at 0:44
  • @nosuchintel, Or you might like to consider the 12 pin breakout version. See the update to my answer.
    – tlfong01
    Oct 23, 2019 at 1:38
  • 1
    Thanks for your reply. I don't think i should need the CS pin though. If I am using physically separate SPI pins? In my case using the screen on spi0 is fine, but switching to the spi1 bcm pins and changing the port/device paramaters, I get nothing. Oct 23, 2019 at 6:20
  • There seems to be some confusion. Let me summarize: (1) Using the LCD with 7 pin connector, everything goes well without any CS pin connection. (2) On changing python program's SPI_PORT = 0 to SPI_PRT = 1, does not work, that is what I expected. (3) Now for 7 pin model, disconnect 12 pin connector's CS pin to ground and connect it to Rpi CS1, then LCD should work with SPI Bus 1. (4) If using 12 pin LCD, just connect CS pin to CS1 would work for Bus 1, (5) Connect to CS0, would work for CS0. I am only 80% sure. Perhaps I should get the 12 pin model to check out. Cheers.
    – tlfong01
    Oct 23, 2019 at 6:38
0

In my case, I had to change the interface speed from the default 4 MHz to 65kHz and then it worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.