Terminal with TFT-LCD
Building and Flashing the Program
Create a new Pico SDK project named terminal-with-tftlcd.
Create Pico SDK Project
- In VSCode, run
>Raspberry Pi Pico: New Pico Projectin the command palette. -
In the dialog below, select
C/C++.
-
Create a project with the following settings:
- Name ... Enter the project name.
- Board type ... Select your board type.
- Location ... Select the parent directory where the project directory will be created.
- Stdio support ... Leave
Console over USBunchecked when you use LABOPlatform or other USB features because they conflict with each other. You can enable it by editing theCMakeLists.txtfile later. - Code generation options ... Check
Generate C++ code.

Open Existing Pico SDK Project
Open the project folder in VSCode using one of the following methods:
- In a command prompt, change the current directory to the project folder and execute
code .. -
In a Explorer, choose the project folder, push
Alt+Dto focus the address bar, and executecode ..
If the folder is already prepared as a Pico SDK project, just proceed with editing and building the project.
If not, you will see the following message at the bottom right corner of VSCode.

Click Yes and you will see the following window.

Click Import and the project will be prepared as a Pico SDK project.
When the Do you want to import this project as Raspberry Pi Pico project? message disappears before you click Yes, you can reveal it by clicking the icon
at the bottom right corner of VSCode.
Clone the pico-jxglib repository from GitHub so the direcory structure looks like this:
Clone the Repository
Change the current directory to the parent directory where you want to clone the pico-jxglib repository and run the following commands:
$ git clone https://github.com/ypsitau/pico-jxglib.git
$ cd pico-jxglib
$ git submodule update --init --recursive
pico-jxglib is updated almost daily. If you've already cloned it, run the following command in the pico-jxglib directory to get the latest version:
A directory from a Git repository can safely be moved to another location even after cloning.
Add the following lines to the end of CMakeLists.txt:
| CMakeLists.txt | |
|---|---|
Edit terminal-with-tftlcd.cpp as follows:
| terminal-with-tftlcd.cpp | |
|---|---|
Build and flash the program to the board.
Build and Flash
The simplest way to build and flash the program is to use the UF2 file generated by the build process. Pico board, a USB cable, and a computer are all you need to get started. Here are the steps to build and flash the program:
-
Pressing
F7on VSCode will build the project. If this is the first time you build the project, you will see the dialog shown below. SelectPico Using compilers: ...and the build process will start.
-
After building, you can find the generated UF2 file in the
builddirectory. - Connect your Pico to the computer using a USB cable while holding the BOOTSEL button, and it will appear as a mass storage device. Copy the generated UF2 file to this device to flash it. No need to mind the destination directory, just copy it to the root directory of the device.
If you have a debug probe like this, you can also flash the program using OpenOCD and GDB. This is the recommended method for development, as it allows you to debug the program while running it on the board!
Creating a Project
From the VSCode command palette, run >Raspberry Pi Pico: New Pico Project and create a project with the following settings. For details on creating a Pico SDK project, building, and writing to the board, see "Getting Started with Pico SDK".
- Name ... Enter the project name. In this example, enter
termtest. - Board type ... Select the board type.
- Location ... Select the parent directory where the project directory will be created.
- Stdio support ... Select the port (UART or USB) to connect Stdio.
- Code generation options ... Check
Generate C++ code
Assume the project directory and pico-jxglib are arranged as follows:
From here, edit CMakeLists.txt and the source file based on this project to create your program.
Terminal on TFT LCD ST7789
Let's implement Terminal functionality using the TFT LCD ST7789. For other devices, see "pico-jxglib and TFT LCD".
The breadboard wiring image is as follows. Tact switches are placed for operations like rollback.

Add the following lines to the end of CMakeLists.txt:
| CMakeLists.txt | |
|---|---|
Edit the source file as follows:
The first part of the program initializes SPI and the TFT LCD.
terminal.AttachDisplay(display);
terminal.SetFont(Font::shinonome16).SetSpacingRatio(1., 1.2).ClearScreen();
Attach the display device (TFT LCD, OLED, etc.) to the Terminal instance with AttachDisplay(). Use SetFont() to set the font, and SetSpacingRatio() to set character and line spacing. Now you're ready to output text to the Terminal.
terminal.Suppress();
terminal.Print(Text_Botchan);
terminal.Suppress(false);
for (int i = 1; i < 7; i++) {
for (int j = 1; j < 13; j++) terminal.Printf("%3d", i * j);
terminal.Println();
}
Use Print(), Println(), and Printf() to output strings to the Terminal instance. The Suppress() function temporarily suppresses actual drawing. Suppress(false) returns to normal drawing.
Call RollUp() and RollDown() to scroll up and down.
if (!GPIO20.get()) terminal.Dump.BytesPerRow(8).Ascii()(reinterpret_cast<const void*>(0x10000000), 64);
The Dump() function outputs a memory dump.
The CreateReader() function creates a Stream instance to read the contents of the line buffer. Here, WriteTo() is called on that Stream to output data to stdout.