TFT LCD Display Example¶
Description¶
The TFT LCD Display Example shows how to use the LCD library API functions to draw graphic objects on the LCD.
The table below shows the connections of each pin of the TFT LCD driver ST7789:
LCD Pin | nRF52840 Pin | Name |
---|---|---|
LCD DC | P0_08 | LCD_DC |
LCD CS | P0_06 | LCD_CS |
LCD Backlight | P0_20 | LCD_BL |
LCD Reset | P1_09 | LCD_RST |
SPI SCK | P0_11 | SCK |
SPI MOSI | P0_12 | MOSI |
Before you start coding, the Python Interpreter should be installed on the nRF52840 M.2 module correctly:
Run the code¶
Run the TFT LCD Display Example by performing the following steps:
-
Connect the Module USB port to your PC as shown in the figure below. A disk drive called CIRCUITPY should be automatically detected by the computer:
-
Open the
code.py
file on your CIRCUITPY drive, then copy and paste the following code. Your code will run as soon as the file is done saving.import board import digitalio import displayio import time from lcd import LCD displayio.release_displays() spi = board.SPI() display_bus = displayio.FourWire( spi, command=board.LCD_DC, chip_select=board.LCD_CS, reset=board.LCD_RST ) display = LCD(display_bus, width=240, height=240, rowstart=80, rotation=90, backlight_pin=board.LCD_BL)
-
Run a terminal application like PuTTY or screen:
screen /dev/cu.usbmodem14102 115200
-
Type something in the terminal window. Observe that the LCD will display the same thing as in the terminal:
Reference¶
Create an Issue¶
Interested in contributing to this project? Want to report a bug? Feel free to click here: