Shell with Display (TFT LCD)
Example Project
Creating the 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
shell-test. - Board type ... Select the board type.
- Location ... Select the parent directory where the project directory will be created.
- Stdio support ... If using a serial console for the terminal, select the port (UART or USB) to connect Stdio. If using a USB keyboard for the terminal, uncheck USB.
- 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.
Embedding the Shell
To embed the shell in your program, write the following code:
- Create and initialize a
Terminalinstance (Serial::TerminalorDisplay::Terminal) to use with the shell - Connect the
Terminalinstance to the shell with theShell::AttachTerminal()function - In the main loop, call
Tickable::Tick()orTickable::Sleep()
How you create the Terminal instance depends on what you use for the terminal. Here are some examples:
Using TFT LCD ST7789 and USB Keyboard as the Terminal
This can be used in environments where a TFT LCD ST7789 and USB keyboard are connected to the Pico board. Since you need to initialize the TFT LCD and set up SPI, there is more code to write, but it can run standalone on the Pico board.
The breadboard wiring image is as follows:

Add the following line to the end of CMakeLists.txt. Also, make sure USB connection for Stdio is disabled (pico_enable_stdio_usb(shell-test 0)).
target_link_libraries(shell-test jxglib_USBHost jxglib_Display_ST7789 jxglib_Shell jxglib_ShellCmd_Basic)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../pico-jxglib pico-jxglib)
jxglib_configure_USBHost(shell-test CFG_TUH_HID 3)
Edit the source file as follows:
#include <stdio.h>
#include "pico/stdlib.h"
#include "jxglib/Display/ST7789.h"
#include "jxglib/USBHost/HID.h"
#include "jxglib/Shell.h"
#include "jxglib/Font/shinonome16.h"
using namespace jxglib;
int main()
{
::stdio_init_all();
//-------------------------------------------------------------------------
Display::Terminal terminal;
USBHost::Initialize();
USBHost::Keyboard keyboard;
::spi_init(spi1, 125 * 1000 * 1000);
GPIO14.set_function_SPI1_SCK();
GPIO15.set_function_SPI1_TX();
Display::ST7789 display(spi1, 240, 320, {RST: GPIO10, DC: GPIO11, CS: GPIO12, BL: GPIO13});
terminal.Initialize()
.AttachDisplay(display.Initialize(Display::Dir::Rotate90))
.AttachKeyboard(keyboard.SetCapsLockAsCtrl()).SetFont(Font::shinonome16);
Shell::AttachTerminal(terminal);
terminal.Println("Shell on ST7789 TFT LCD");
//-------------------------------------------------------------------------
for (;;) {
// any jobs
Tickable::Tick();
}
}