Displays mit ST7735 TreiberIC
1,77" Display 160x128 RGB SPI
Dieses Display stammt von azdelivery.de: https://www.azdelivery.de/products/1-77-zoll-spi-tft-display


Front- und Rückansicht des Displays. In der Draufsicht liegt Pin1 ganz links.
Technische Daten
✅ Leuchtstarkes, entspiegeltes TFT-Display mit großer 1,77 Zoll Bilddiagonale
✅ Große Auflösung von 128x160 Pixeln zur klaren Darstellung von Texten, Grafiken und Bildern
✅ Hohe Hardwarekompatibilität mit Arduino, Raspberry Pi & Co. dank Standard SPI-Datenschnittstelle und frei verfügbarer Bibliotheken für den ST7735 Bildcontroller
✅ Maße (LxBxH) – Board: 34 x 54 x 3,5* mm (ca. 12mm inkl. Pins); Display: 34 x 43 x 2,4 mm; Anzeigefläche: 28 x 35 mm
Testumgebung
Raspberry Pi Pico
Der Test es Displays und der Treibermodule erfolgt auf einem Raspberry Pi Pico. Es wird die Hardware-SPI-Schnittstelle 0 verwendet.
>>> print(SPI(0))
SPI(0, baudrate=992063, polarity=0, phase=0, bits=8, sck=18, mosi=19, miso=16)
Es können die DefaultPins verwendet werden. Daraus ergibt sich folgende Verdrahtung:
1,77" Display | Pico | |
---|---|---|
Pin | Bezeichnung | GPIO |
1 | GND | GND |
2 | Vcc | 3V3 |
3 | SCK | 18 |
4 | SDA | 19 |
5 | RES | 22 |
6 | RS | 20 |
7 | CS | 17 |
8 | LEDA | 21 |
Display Initialisieren
Da MISO nicht benutzt wird braucht ihm auch kein GPIO zugewiesen werden:
from machine import SPI, Pin
spi = SPI(0, miso=None)
Das führt aber nicht dazu, dass GPIO16 nicht initialisiert wird!
>>> print(spi)
SPI(0, baudrate=992063, polarity=0, phase=0, bits=8, sck=18, mosi=19, miso=16)
GPIO16 wird nicht als IN oder OUT initialisiert, sonder als alternative Funktion und als Eingang wie "pull=PULL_DOWN" zeigt.
>>> print(Pin(16))
Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=SPI)
Deshalb wird GPIO16 vorerst nicht benutzt. Später werde ich testen, ob man ihn für andere Zwecke verwenden kann.
Die ST7735 Module
Es gibt im Internet diverse ST7735-Module:
https://github.com/hosaka/micropython-st7735
Unter dieser URL: https://github.com/GuyCarver/MicroPython/blob/master/lib/ST7735.py kann das Modul heruntergeladen werden.
Ich habe es unter st7735_1.py gespeichert und in das lib-Verzeichnis des Pico kopiert.
Aus dem Quellcode der komplett in Micropython geschrieben ist ergibt sich folgendes:
Die Displaygröße ist fest im Modul eingetragen:
_SCREENSIZE = (128, 160)
Bei einer anderen Displaygröße muss diese im Quellcode geändert werden.
Initialisierung
Es gibt die Klasse tft mit der eine Instanz für das Display erstellt werden kann:
disp = st7735.tft(spi, DC_Pin, RES_Pin)
def size(self)
def on( self, aTF = True )
def invertcolor( self, aBool )
def rgb( self, aTF = True ) :
'''True = rgb else bgr'''
def rotation( self, aRot ) :
'''0 - 3. Starts vertical with top toward pins and rotates 90 deg
clockwise each step.'''
def pixel( self, aPos, aColor )
def text( self, aPos, aString, aColor, aFont, aSize = 1 ) :
'''Draw a text at the given position. If the string reaches the end of the
display it is wrapped to aPos[0] on the next line. aSize may be an integer
which will size the font uniformly on w,h or a or any type that may be
indexed with [0] or [1].'''
def char( self, aPos, aChar, aColor, aFont, aSizes ) :
'''Draw a character at the given position using the given font and color.
aSizes is a tuple with x, y as integer scales indicating the
# of pixels to draw for each pixel in the character.'''
def line( self, aStart, aEnd, aColor ) :
'''Draws a line from aStart to aEnd in the given color. Vertical or horizontal
lines are forwarded to vline and hline.'''
def vline( self, aStart, aLen, aColor ) :
'''Draw a vertical line from aStart for aLen. aLen may be negative.'''
def hline( self, aStart, aLen, aColor ) :
'''Draw a horizontal line from aStart for aLen. aLen may be negative.'''
def rect( self, aStart, aSize, aColor ) :
'''Draw a hollow rectangle. aStart is the smallest coordinate corner
and aSize is a tuple indicating width, height.'''
def fillrect( self, aStart, aSize, aColor ) :
'''Draw a filled rectangle. aStart is the smallest coordinate corner
and aSize is a tuple indicating width, height.'''
def circle( self, aPos, aRadius, aColor ) :
'''Draw a hollow circle with the given radius and color with aPos as center.'''
def fillcircle( self, aPos, aRadius, aColor ) :
'''Draw a filled circle with given radius and color with aPos as center'''
def fill( self, aColor = BLACK ) :
'''Fill screen with the given color.'''
Links:
https://github.com/hosaka/micropython-st7735
https://github.com/AnthonyKNorman/MicroPython_ST7735
https://github.com/GuyCarver/MicroPython
https://github.com/AnthonyKNorman/MicroPython_SSD1306
https://www.electronicshub.org/esp32-nokia-5110-lcd/
https://github.com/boochow/MicroPython-ST7735
https://github.com/peterhinch/micropython-nano-gui
https://github.com/boochow/MicroPython-ST7735
https://github.com/boochow/MicroPython-ST7735/blob/master/ST7735.py
https://github.com/GuyCarver/MicroPython
https://github.com/GuyCarver/MicroPython/tree/master/lib
https://github.com/GuyCarver/MicroPython/blob/master/lib/ST7735.py