From 20e8302c1f77cbd064937e5e5001c29386692f4c Mon Sep 17 00:00:00 2001 From: jaska Date: Sun, 12 Apr 2020 23:03:41 +0100 Subject: [PATCH 1/3] :books: update usage example for 1.14" TFT users The usage example may only work for 2.2", 2.4", 2.8", 3.2" TFT ( which I could not verify ). With 1.14" TFT and raspberry pi 4, the wiring are different, chipset is different. At the first try-out, as a novice user, I was doubting my soldering skills. Why does not it work? Blank screen! It turns out that wrong chipset driver was used. After updating its chipset driver, it is still blank! I was doubting my connections and my soldering skills again! It turns out that the CS_PIN, DC_PIN are not the same as bigger TFTs. After all those adjustments, it worked. --- README.rst | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/README.rst b/README.rst index bb3fa41..11dfd27 100644 --- a/README.rst +++ b/README.rst @@ -60,6 +60,9 @@ To install in a virtual environment in your current project: Usage Example ============= +2.2", 2.4", 2.8", 3.2" TFT +--------------------------- + .. code-block:: python import time @@ -95,6 +98,57 @@ Usage Example # Pause 2 seconds. time.sleep(2) + +1.14" TFT with Raspbery Pi 4 +----------------------------- + +With 1.14" `wiring `_, here is the working code: + +.. code-block:: python + + import time + import busio + import digitalio + from board import SCK, MOSI, MISO, CE0, D24, D25 + + from adafruit_rgb_display import color565 + from adafruit_rgb_display.st7789 import ST7789 + + + # Configuration for CS and DC pins: + CS_PIN = CE0 + DC_PIN = D25 + RESET_PIN = D24 + BAUDRATE = 24000000 + + # Setup SPI bus using hardware SPI: + spi = busio.SPI(clock=SCK, MOSI=MOSI, MISO=MISO) + + # Create the ILI9341 display: + display = ST7789( + spi, + rotation=90, + width=135, + height=240, + baudrate=BAUDRATE, + cs=digitalio.DigitalInOut(CS_PIN), + dc=digitalio.DigitalInOut(DC_PIN), + rst=digitalio.DigitalInOut(RESET_PIN)) + + # Main loop: same as above + while True: + # Clear the display + display.fill(0) + # Draw a red pixel in the center. + display.pixel(120, 160, color565(255, 0, 0)) + # Pause 2 seconds. + time.sleep(2) + # Clear the screen blue. + display.fill(color565(0, 0, 255)) + # Pause 2 seconds. + time.sleep(2) + + Contributing ============ From 54bcb2a71c713258cf509a13755036380d188196 Mon Sep 17 00:00:00 2001 From: jaska Date: Sun, 12 Apr 2020 23:08:20 +0100 Subject: [PATCH 2/3] :bug: add x and y offsets. with this fix, the blue rectangle will situate at the corner near Vin pin. --- README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 11dfd27..e7079fa 100644 --- a/README.rst +++ b/README.rst @@ -124,12 +124,14 @@ With 1.14" `wiring Date: Mon, 13 Apr 2020 19:32:44 +0100 Subject: [PATCH 3/3] :books: correct reference link address review feedback. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index e7079fa..ca7caa1 100644 --- a/README.rst +++ b/README.rst @@ -102,7 +102,7 @@ Usage Example 1.14" TFT with Raspbery Pi 4 ----------------------------- -With 1.14" `wiring `_, here is the working code: +With 1.14" `wiring `_, here is the working code: .. code-block:: python