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
Vorbemerkung
Die Ersten beiden st7735-Module sind für das PyBoard geschrieben und verwenden dessen pyb-Modul. Weiterhin wird die SPI-Schnittstelle des PyBoard durch Zeichen identifiziert und die zugehörigen Pins sind intern bekannt. Die Klasse ttf initialisiert auch die SPI-Schnittstelle.
Weiterhin gibt es wohl 3 verschiedene Versionen des 128x160 Displays. Es gibt im Quellcode Initialisierungsfunktionen für rote, grüne und blaue Platinen.
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/GuyCarver/MicroPython
Es gibt hier noch mehr Module für Micropython. Es lohnt sich diese mal anzusehen.
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.
Dieses Modul verwendet verschiedene Fonts, die in .py Dateien gespeichert sind:
Aus dem Quellcode der komplett in Micropython geschrieben ist ergibt sich folgendes:
Dieses st7735-Module ist für das PyBoard geschrieben und verwenden dessen pyb-Modul. Weiterhin wird die SPI-Schnittstelle des PyBoard durch Zeichen identifiziert und die zugehörigen Pins sind intern bekannt. Die Klasse ttf initialisiert auch die SPI-Schnittstelle.
Weiterhin gibt es wohl 3 verschiedene Versionen des 128x160 Displays. Es gibt im Quellcode Initialisierungsfunktionen für rote, grüne und blaue Platinen.
Die Displaygröße ist fest im Modul eingetragen:
_SCREENSIZE = (128, 160)
Bei einer anderen Displaygröße muss diese im Quellcode geändert werden.
Initialisierung
Die Initialisierung habe ich nicht verstanden und konnte ich mangels PyBoard nicht testen.
Demofile: https://github.com/GuyCarver/MicroPython/blob/master/tft.py
Methoden
Dieses Modul bietet folgende Methoden:
- size()
- gibt die Displaygrössez urück
- on(aTF = True)
- Schaltet das Display ein/aus. on() schaltet ein. on(aTF=False) schaltet aus.
- invertcolor(aBool)
- aBool = TrueiInvertiert die Farbe. aBool = False invertiert nicht.
- rgb(aTF = True)
- True = rgb False = bgr
- rotation( self, aRot )
- 0 - 3. Starts vertical with top toward pins and rotates 90 deg clockwise each step.'''
- pixel( self, aPos, aColor )
- Setzt ein Pixel der Farbe aColor an aPos. aPos ist ein Tuple mit den x,y Koordinaten.
- text( self, aPos, aString, aColor, aFont, aSize = 1 )
- '''Draw a text at the given position. If the string reaches the end of thedisplay 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].'''
- 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.'''
- 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.'''
- vline( self, aStart, aLen, aColor )
- '''Draw a vertical line from aStart for aLen. aLen may be negative.'''
- hline( self, aStart, aLen, aColor )
- '''Draw a horizontal line from aStart for aLen. aLen may be negative.'''
- rect( self, aStart, aSize, aColor )
- '''Draw a hollow rectangle. aStart is the smallest coordinate corner and aSize is a tuple indicating width, height.'''
- fillrect( self, aStart, aSize, aColor )
- '''Draw a filled rectangle. aStart is the smallest coordinate corner and aSize is a tuple indicating width, height.'''
- circle( self, aPos, aRadius, aColor )
- '''Draw a hollow circle with the given radius and color with aPos as center.'''
- fillcircle( self, aPos, aRadius, aColor )
- '''Draw a filled circle with given radius and color with aPos as center'''
- fill( self, aColor = BLACK )
- '''Fill screen with the given color.'''
https://github.com/hosaka/micropython-st7735
Dieses Modul basiert auf dem von GuyCarver s.o. ist aber nicht an das PyBoard gebunden.
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