Sainsmart ST7735 LCD display

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
gcarver
Posts: 34
Joined: Sun Oct 26, 2014 4:07 am
Location: New Market, Maryland
Contact:

Sainsmart ST7735 LCD display

Post by gcarver » Sun Oct 26, 2014 5:00 am

I'm attempting to write a driver for this display but it does not work at the moment. I was hoping I could get some help on what the SPI settings for this hardware should be.
My code is here:
https://github.com/GuyCarver/MicroPytho ... /ST7735.py

The datasheet for the hardware is here:
http://www.sainsmart.com/zen/documents/ ... R_V0.2.pdf

I've looked at some code for RPi implementation and the baud rate is set to 20mhz.
I also looked at ssd1306.py for cross reference. This sets the baud rate to around 16mhz and the phase to 0. This phase is not legitimate and actually gets set to 2.
However I cannot read the timing charts to know what to set the SPI values to.

I'm going to keep plugging away and even try software SPI to see if I can find where I'm going wrong.

Thanks in advance for any help.
End of line...

nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Re: Sainsmart ST7735 LCD display

Post by nelfata » Sun Oct 26, 2014 12:14 pm

Hi,
I just modified the stock LCD driver in MP (but the C code) and I thought to share with you some notes to get you going:
- make sure you have the pins connected appropriately
- make sure the SPI bus is not shared with other devices (if it is you need to make sure the CS lines are connected and in use)
- check if you are configuring the CS line as a digital output
- double check your SPI configuration
- use a slow SPI clock speed setting to start with (try 1MHz or even 500KHz), sometimes your wires might be too long and higher speeds would generate noisy data lines
- check the signals on a scope (make sure the clock speed is what you expect)
- the phase is being set correctly but the print is showing 2 instead of 1 on the MP console (I will file a bug against it)
- a good way of testing the proper configuration is to write a series of registers and read them afterwards (not all displays allow you to read), make sure you write a block and you read the same block and verify, if you have the clock/phase badly configured this method will allow you to detect that

I hope this helps.

User avatar
gcarver
Posts: 34
Joined: Sun Oct 26, 2014 4:07 am
Location: New Market, Maryland
Contact:

Re: Sainsmart ST7735 LCD display

Post by gcarver » Wed Oct 29, 2014 4:15 am

Thanks for the help. It was invaluable. I now have everything working!
I was not controlling CS as I thought the SPI module was doing that. However the documentation states that the NSS pin is not used and I'm pretty sure that is synonymous with CS.
The phase also needed to be 1 and I finally figured that out from the timing charts.

I've updated GitHub and currently have lines, circles and boxes implemented. Will be adding text soon.
I'd like to implement in C but I'm on windows and don't have a cross compiler successfully installed.
End of line...

nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Re: Sainsmart ST7735 LCD display

Post by nelfata » Mon Nov 03, 2014 3:34 pm

My pleasure, I am glad it worked for you.

User avatar
gcarver
Posts: 34
Joined: Sun Oct 26, 2014 4:07 am
Location: New Market, Maryland
Contact:

Re: Sainsmart ST7735 LCD display

Post by gcarver » Mon Nov 10, 2014 4:54 pm

I've finished implementing the ST7735 driver in c and it is much, much faster than the python version.
I still have to implement the TFT tests and there is no documentation other than source code at the moment.
In case anyone is interested my branch is at https://github.com/GuyCarver/micropython-1/tree/TFT
It is implemented as pyb.TFT. I used pyb.LCD pretty much as a template.
It supports multiple fonts (not provided in this branch) but by default uses the same font as pyb.LCD.
I am still supporting the python version of the driver because that does not require a new uPython image. Th python implementation cannot use the pyb.LCD font however.
End of line...

josie87
Posts: 24
Joined: Tue Jun 30, 2015 2:46 pm

Re: Sainsmart ST7735 LCD display

Post by josie87 » Tue Aug 25, 2015 7:30 pm

Hi,

after I fryed my displaymodule, I thought I 'd go for a shiny colored one. My choice fell on a ST7735. I tryed to hook it up using your lib, but all I get is a black screen.

To verify the screen itself,I ran the arduino examples with my uno and nano, both work fine. Of course I also used the same cables.

I would guess that I wired smth. wrong:

d/c -> x2
rst -> x1
cs -> x5
clk -> x6
din -> x8
bl -> 3.3V

I attached a picture with the pinout.

Hope anyone can help me
Attachments
st7735.png
picture of my st7735 board
st7735.png (233.41 KiB) Viewed 8070 times

josie87
Posts: 24
Joined: Tue Jun 30, 2015 2:46 pm

Re: Sainsmart ST7735 LCD display

Post by josie87 » Sat Aug 29, 2015 4:34 pm


Post Reply