SPI Display Module Example¶
This example demonstrates how to use a SPI display module with the KNEO Pi.
The built-in controller used in this LCD is ST7789V3 which is an LCD controller with 240 x 320 pixels.
Important
The module used here is randomly selected and is not intended as a recommendation or endorsement. Please refer to Waveshare 2.0" LCD Module for module details.
The example is adapted from the vendor-provided code available at Waveshare 2.0" LCD Module Demo Example , with the following modifications:
- Hardware PWM is used for backlight brightness control.
- Hardware SPI is used for chip select (CS) pin control.
Hardware Connection¶
Connect the SPI display module to the KNEO Pi as follows:
Module Pin | KNEO Pi Pin | Function |
---|---|---|
VCC | 3.3V / pin-1 |
Power Supply |
GND | GND / pin-14 |
Ground |
DIN | SPI_MOSI / pin-19 |
SPI Data Input |
CLK | SPI_SCK / pin-23 |
SPI Clock |
CS | SPI_CS / pin-24 |
SPI Chip Select |
DC | GPIO_0[19]/ pin-22 |
Data/Command Control |
RST | GPIO_1[20]/ pin-13 |
Reset |
BL | PWM_1 / pin-33 |
Backlight Control |
Install lgpio
library¶
Install required python modules
Install lgpio library
wget https://github.com/joan2937/lg/archive/master.zip
unzip master.zip
cd lg-master
make
make install
#for more details, you can refer to https://github.com/joan2937/lg
Running the Example¶
Clone the modified example from GitHub
git clone https://github.com/kneron/kneopi-examples.git
cd kneopi-examples
cd peripherals/C/spi_display
Build the example
Run the demo test
This should display the test patterns on the screen.Additional Notes
- For more details on available APIs, GUI functions, and font rendering, refer to the official vendor documentation: Waveshare 2.0" LCD Module Wiki
- The example has also been tested with the Waveshare 1.47" LCD Module .
To use it, run :