Pico-ResTouch-LCD-2.8

From Waveshare Wiki
Jump to: navigation, search
Pico-ResTouch-LCD-2.8
Pico-ResTouch-LCD-2.8

2.8inch Touch Display Module for Raspberry Pi Pico
262K Colors, 320 × 240, SPI
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

2.8inch resistive touch display module for Raspberry Pi Pico, 262K colors, 320 × 240 pixels, onboard resistive touch controller XPT2046, Micro SD card slot, SPI interface.

Specification

Parameter
Working Voltage 5V Resolution 320 × 240 Pixels
Communication Interface SPI Display Dimension 57.60 × 43.20 mm
Display Panel IPS Pixel Size 0.18 × 0.18 mm
Control Chip ST7789 Dimension 70.20 × 50.20 mm

Hardware connection

Please take care of the direction when you connect Pico, an USB port is printed to indicate. You can also check the pins of Pico and the LCD board when connecting.
You can connect the display according to the table.

LCD Pico Description
VCC VSYS Power input
GND GND GND
SDIO_CLK GP5 SCK pin of SDIO interface, clock input for slave device
LCD_DC GP8 Data/Command control pin (High: data; Low: command)
LCD_CS GP9 Chip select pin of LCD (Low active)
LCD_CLK GP10 SPI CLK pin, clock input for slave device
MOSI GP11 SPI MOSI pin, data input for slave device
MISO GP12 SPI MISO pin, data output for slave device
LCD_BL GP13 LCD backlight control
LCD_RST GP15 LCD reset pin (Low active)
TP_CS GP16 Touch controller chip select (Low active)
TP_IRQ GP17 Touch controller interrupt pin (Low active)
SDIO_CMD GP18 SDIO CMD pin
D0 GP19 SDIO D0 pin
D1 GP20 SDIO D1 pin
D2 GP21 SDIO D2 pin
SD_CS/D3 GP22 SDIO CS/D3 pin

Features

  • 320 × 240 resolution, IPS screen, 262K RGB, clear and colorful displaying effect.
  • Dedicated touch controller, bringing more smooth touching effect than AD-controlled solutions.
  • MicroSD card slot for storing images and direct displaying them easily.
  • Programmable backlight control, power saving.
  • Comes with online development resources and manual (Raspberry Pi Pico C/C++ and MicroPython examples).

Pin

The built-in controller used by this LCD is ST7789VW, which is an LCD controller with 240 x RGB x 320 pixels, while the pixels of this LCD itself are 240 (H) RGB x 320 (V), and the internal RAM of the LCD has been fully used. The LCD supports 16-bit or 18-bit input color formats per pixel, namely RGB565 and RGB666. The test demo uses RGB565 color format, which is a commonly used RGB format. LCD uses a four-wire SPI communication interface, which can greatly save GPIO ports, At the same time, the communication speed will be faster. The maximum SPI write speed tested is 60MHz.
Pico-ResTouch-LCD-2.8-details-inter.jpg
0.96inch lcd module spi.png
Note: The difference with the traditional SPI protocol is that the data cable sent from the slave to the host is hidden because it only needs to be displayed. For details, please refer to Datasheet Page 55 (8.4 Serial Interface).

  • RESX (LCD_RST) indicates reset, usually set to 1 and is pulled low when the module is powered on.
  • CSX (LCD_CS) indicates the slave chip selection and the chip is enabled when CS is low.
  • D/CX (LCD_DC) indicates the chip data/command control pin. When DC=0, it is writing commands. When DC=1, it is writing data.
  • SDA (MOSI) is the transmitted data, that is, RGB data.
  • SCL (CLK) is the SPI clock.
  • For SPI communication, the data has transmission order, that is the combination of clock phase (CPHA) and clock polarity (CPOL).
  • The level of CPHA determines whether the serial synchronization clock data is collected on the first clock transition edge or the second clock transition edge. When CPHA = 0, data acquisition is performed on the first transition edge.
  • The level of CPOL determines the idle state level of the serial synchronous clock. CPOL = 0, which is a low level.
  • As can be seen from the figure, at the first falling edge of SCLK, data starts to be transmitted, 8bit data is transmitted in one clock cycle, using SPI0, bit-wise transmission, high-order first, and low-order last.

Dimension

Pico ResTouch LCD 2.8 Guide.jpg

Connection

LCD Pico Function
VCC VSYS Power Input
GND GND Ground
SDIO_CLK GP5 SDIO interface SCK pin, clock input from device
LCD_DC GP8 Data/command control pin (high for data, low for command)
LCD_CS GP9 LCD chip select pin (low active)
LCD_CLK GP10 SPI communication CLK pin, clock input from device
MOSI GP11 SPI communication MOSI pin, data input from device
MISO GP12 SPI communication MISO pin, data output from device
LCD_BL GP13 Backlight control
LCD_RST GP15 LCD reset pin (low active)
TP_CS GP16 Touch chip selection pin(low active)
TP_IRQ GP17 Touch interrupt pin(low active)
SDIO_CMD GP18 SDIO interface CMD pin
D0 GP19 SDIO interface D0 pin
D1 GP20 SDIO interface D1 pin
D2 GP21 SDIO interface D2 pin
SD_CS/D3 GP22 SDIO interface CS/D3 pin

Pico-ResTouch-LCD-2.8-details-3.jpg
Pay attention to the connection direction of the Pico, the USB of the Pico should be in the same direction as the MicroSD card.

Setup Environment

1. Please install Pico SDK in Arduino IDE, click Tools -> Board -> Boards Manager in the menu bar and search for Raspberry Pi Pico, find the corresponding library, and click Install to install it, as shown in the figure below:
Pico 10dof imu spec40.jpg
2. Please refer to The C/C++ SDK and 9.2. Building on MS Windows in GET-START document for the compilation environment of VScode(Cmake).
Pico ResTouch LCD02.jpg
3. Please refer to the official micropython document to set up the environment, and select the Raspberry Pi Pico device in Thonny through Tools->Options->Interpreter. As shown below:
Pico-GPS-002.jpg

Download Demo codes

  1. Click to download the sample demo.
  2. Please open the VScode (Cmake) project with VScode software.
  3. Unzip the sample demo and click ".ino" to open the Arduino demo. Please upload the Micropython sample demo to the Pico document system. As shown below:

Thonny03.jpg

Run the Demo

Arduino

1. Open Arduino IDE or ".ino" sample program. Click "Tools->Board->Raspberry Pi Pico" in the menu bar. As shown below.
Pico-GPS-003.jpg
2. Install the TFT_eSPI library, click Tools->Manage Library in the menu bar, search for TFT_eSPI and click Install.
Pico ResTouch LCD 3.5 Guide09.png
3. To configure the driver file, open the Arduino library file directory, usually in C:\Users\xxxx\Documents\Arduino\libraries\TFT_eSPI\.

  • For ResTouch-LCD-3.5, replace the two files in the TFT_eSPI library, (User_Setups\Setup60_RP2040_ILI9341.h) and (User_Setup_Select.h), with the files in the Arduino\ResTouch-LCD-3.5 folder.
  • For ResTouch-LCD-2.8, replace the three files in the TFT_eSPI library, (User_Setups\Setup23_TTGO_TM.h), (User_Setup_Select.h) and (TFT_eSPI.h), with the files in the Arduino\ResTouch-LCD-2.8 folder.

Pico ResTouch LCD 3.5 Guide112.jpg

4. The "ino" file is in TFT_eSPI -> examples. Select the example program under File-Examples->TFT_eSPI->480*320 in the menu bar, and then click Upload under Edit to download the code to Pico.

VScode(Cmake)

  • Open the c project with VScode, and then compile and download.

Micropython

  • Open Thonny IDE, and save the file under "python/2inch8/" to the Pico file system, as shown in the figure. And the same for ResTouch-LCD-3.5.

Pico ResTouch LCD 3.5 Guide10.jpg

Codes Analysis

The example will display strings, figures, images, and finally the touch pad function. The C demo is for Pico-ResTouch-LCD-2.8 and Pico-ResTouch-LCD-3.5. In the main function, we place the three main functions in order and place TP_DrawBoard(); in an infinite loop to achieve the above function.

GUI_Show();
LCD_Show_bmp(Bmp_ScanDir , Lcd_ScanDir);	
TP_DrawBoard();

Note: Before you test the LCD_ShowBMP example for displaying pictures, you need to copy the picture from the PIC folder to the root directory of a micro SD card, and insert the SD card into the slot in the backside of the LCD. Then run the examples.

  • The micro SD card should be in FAT format, and the resolution of pictures used should be the same as the LCD, for a 2.8-inch LCD, it is 320 × 240, and 480 × 320 for a 3.5-inch LCD if the picture is in 24bit BMP format.


The LCD controller is ST7789, we need to initialize the controller through the SPI communication protocol, which is done in LCD_Driver.c file.
And being called in lcd_test.c file:

 System_Init();//System initialization, configure the baud rate of the serial port and SPI interface...<br/>
  LCD_SCAN_DIR Lcd_ScanDir = SCAN_DIR_DFT; //Set the scan mode <br/>
  LCD_Init( Lcd_ScanDir, 200);//Initialize LCD panel, confirm the scan mode and the brightness<br/>

GUI functions are all saved in LCD_GUI.c file, you can call them to draw the display. The function and the parameters of each function are explained in the source code, and can be called directly when needed.

  • Draw point
void GUI_DrawPoint(POINT Xpoint, POINT Ypoint, COLOR Color,
                   DOT_PIXEL Dot_Pixel, DOT_STYLE DOT_STYLE)
  • Draw the line (dotted or solid):
void GUI_DrawLine(POINT Xstart, POINT Ystart, POINT Xend, POINT Yend,
                  COLOR Color, LINE_STYLE Line_Style, DOT_PIXEL Dot_Pixel)
  • Draw a rectangle (empty or filled)
void GUI_DrawRectangle(POINT Xstart, POINT Ystart, POINT Xend, POINT Yend,
                       COLOR Color, DRAW_FILL Filled, DOT_PIXEL Dot_Pixel)
  • Draw a circle (empty or filled)
void GUI_DrawCircle(POINT X_Center, POINT Y_Center, LENGTH Radius,
                    COLOR Color, DRAW_FILL  Draw_Fill , DOT_PIXEL Dot_Pixel)
  • Display character
void GUI_DisChar(POINT Xpoint, POINT Ypoint, const char Acsii_Char,
                 sFONT* Font, COLOR Color_Background, COLOR Color_Foreground)
  • Display string
void GUI_DisString_EN(POINT Xstart, POINT Ystart, const char * pString,
                      sFONT* Font, COLOR Color_Background, COLOR Color_Foreground )
  • Display number
void GUI_DisNum(POINT Xpoint, POINT Ypoint, int32_t Nummber,
                sFONT* Font, COLOR Color_Background, COLOR Color_Foreground )
  • Display time
void GUI_Showtime(POINT Xstart, POINT Ystart, POINT Xend, POINT Yend,
                  DEV_TIME *pTime, COLOR Color)


In the example, this demo shows that the BMP picture first reads the picture data in the BMP format on the SD card through the SPI protocol and displays it.
In lcd_test.c file, we use two functions for display pictures:

SD_Init();//Initialize SD card
LCD_Show_bmp(bmp_scan_dir,lcd_scan_dir);//Display BMP picture

These functions are written in LCD_Bmp.c, actually read the picture data in the BMP format with a specific file name from the SD card and then call the display function written by ourselves to "express" the data as an image again.

In LCD_Touch.c file:

  TP_Init( Lcd_ScanDir );//Initialize the touch panel and the parameter is the scan mode
  TP_GetAdFac();//Calibrate the display
  TP_Dialog();//Clear
  TP_DrawBoard();//Enable the drawing board

There will be five colors on the right side of the screen, the default color is black, touch them to select the pen color; click the AD button, and follow the on-screen prompts to click the red + sign to calibrate the screen; click the CLEAR button in upper right corner to clear the drawing board
The touch experiment uses four sets of calibration values by default, which can meet the brush operations in four directions. There are five color choices on the right, and the default brush size is 9 pixels.
The functions for touching are saved in the LCD_Touch.c file.

There are five font libraries available.

   Width 5, Height 8     font8
   Width 7, Height 12    font12
   Width 11, Height 16   font16
   Width 14, Height 20   font20
   Width 17, Height 24   font24


  • If you need characters in different sizes and fonts, you can generate the font library you want with the font extraction software provided in the #Resource.
  • In fact, you can use the Image2Lcd software to convert a picture to arrays and display them by the functions in the example.
  • Datasheet of chips is provided, you can read them for more information.

Resource

Documents

Demo codes

Development Software

Pico Quick Start

Firmware Download

  • MicroPython Firmware Download

MicroPython Firmware Download.gif

  • C_Blink Firmware Download

C Blink Download.gif

Text Tutorial

Introduction

MicroPython Series

C/C++ Series

For C/C++, it is recommended to use Pico VS Code for development. This is a Microsoft Visual Studio Code extension designed to make it easier for you to create, develop, and debug projects for the Raspberry Pi Pico series development board. Whether you are a beginner or an experienced professional, this tool can help you confidently and easily develop Pico. Below we will introduce how to install and use the extension.

  • Official website tutorial: https://www.raspberrypi.com/news/pico-vscode-extension/.
  • This tutorial is applicable to Raspberry Pi Pico, Pico2, and our company's RP2040 and RP2350 series development boards.
  • The development environment defaults to Windows as an example. For other environments, please refer to the official website tutorial for installation.

Arduino IDE Series

Install Arduino IDE

  1. Download the Arduino IDE installation package from Arduino website.
    RoArm-M1 Tutorial II01.jpg
  2. Just click on "JUST DOWNLOAD".
    Arduino IDE Pico.png
  3. Click to install after downloading.
    RoArm-M1 Tutorial II02.gif
  4. Note: You will be prompted to install the driver during the installation process, we can click Install.

Install Arduino-Pico Core on Arduino IDE

  1. Open Arduino IDE, click the File on the left corner and choose "Preferences".
    RoArm-M1 Tutorial04.jpg
  2. Add the following link in "Additional boards manager URLs", then click OK.
    https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

    RoArm-M1 Tutorial II05.jpg
    Note: If you already have the ESP32 board URL, you can separate the URLs with commas like this:

    https://dl.espressif.com/dl/package_esp32_index.json,https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
    
  3. Click on Tools -> Board -> Board Manager -> Search for pico, it shows installed since my computer has already installed it.
    Pico Get Start 05.png
    Pico Get Start 06.png

Upload Demo At the First Time

  1. Press and hold the BOOTSET button on the Pico board, connect the Pico to the USB port of the computer via the Micro USB cable, and release the button when the computer recognizes a removable hard drive (RPI-RP2).
    Pico Get Start.gif
  2. Download the demo from #Resource, open the D1-LED.ino under arduino\PWM\D1-LED path.
  3. Click Tools -> Port, remember the existing COM, do not need to click this COM (different computers show different COM, remember the existing COM on your computer).
    UGV1 doenload02EN.png
  4. Connect the driver board to the computer with a USB cable, then click Tools -> Ports, select uf2 Board for the first connection, and after the upload is complete, connecting again will result in an additional COM port.
    UGV1 doenload03EN.png
  5. Click Tools -> Board -> Raspberry Pi Pico/RP2040 -> Raspberry Pi Pico.
    Pico Get Start02.png
  6. After setting, click the right arrow to upload.
    Pico Get Start03.png
    • If you encounter problems during the period, you need to reinstall or replace the Arduino IDE version, uninstall the Arduino IDE clean, after uninstalling the software you need to manually delete all the contents of the folder C:\Users\[name]\AppData\Local\Arduino15 (you need to show the hidden files in order to see it) and then reinstall.


Open Source Demo

FAQ



 Answer:

No, it is because the memory of the Pico W is limited by its firmware, and there is no more space for Pico-ResTouch-LCD-2.8 usage.

{{{5}}}


 Answer:

As the Arduino example of the Pico-ResTouch-LCD-2.8 uses the TFT_eSPI library, we just modify some key files and other files remain unchanged, so if you need to access "ino" file, you can use the TFT_eSPI example at .\TFT_eSPI\examples.

{{{5}}}


 Answer:

It is because the mpy firmware consumes too much memory, and there is no memory available for displaying image files or rotating the display direction. If you need to display images or rotate the display direction using Micropython, you will need to write your mpy firmware and remove unnecessary libraries to reduce the firmware's memory. Alternatively, you can use C examples where you can write firmware yourself and directly display bitmaps.

{{{5}}}


Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)