TFT LCD CLI Commands
Using the UART/USB CLI to work with TFT LCDs in the LPC1343 Code Base
In addition to being able to program TFT LCDs in native mode in C, the LPC1343 Code Base also includes support for driving an LCD using a command-line interface (CLI). The commands support by the latest version of the LPC1343 Code Base (v0.92 as of the last page update) are detailed below, along with details on configuring your board to take advantage of the CLI mode.
Using Precompiled Firmware for TFT LCD in CLI Mode
If you are using CLI mode to control the TFT LCD, you may not want to waste your time learning how to modify and build the firmware. Every version of the LPC1343 Code Base includes a handful of precompiled binary images in the '/tools/testfirmware' folder that can be used to quickly program the boards via the USB Bootloader. A handful of images are included here for supported LCDs to help you get started. You can download the entire LPC1343 Code Base, or download the latest binary files directly from the source code repository on github.
Building the LPC1343 Code Base with CLI Mode
In order to build your own firmware with support for CLI mode and TFT LCDs, you have two options. The first (and most error-prone) is the manually modify various projectconfig.h settings to include the CLI (CFG_INTERFACE) and the TFT LCD (CFG_TFTLCD), also selecting whether to use UART or USB are used (CFG_PRINTF_UART or CFG_PRINTF_USBCDC), the line termination, error messages, etc.
There easiest and recommended way, however, is to simply select the appropriate global board configuration setting at the top of the config file, which will configure the rest of the file to match this board (also including a FAT32 file system for the micro-SD connector, etc.):
Because several boards use this code library with sometimes slightly
different pin configuration, you will need to specify which board you
are using by enabling one of the following definitions. The code base
will then try to configure itself accordingly for that board.
// #define CFG_BRD_LPC1343_REFDESIGN
// #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
// #define CFG_BRD_LPC1343_802154USBSTICK
As of v0.92 of the LPC1343 Code Base, there are now two different TFTLCDSTANDALONE board definitions. The first (CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB) is designed to be used via USB and driven by human input using software like terraterm or realterm. This mode will echo back any characters sent to the display, includes more verbose error messages, and by default terminates strings with default Windows-style "\r\n".
The second setting (CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART) is designed for situations where the LCD is controlled by another MCU or HW device (such as an Arduino), and has minimal output, terminates all lines with Linux-style '\n', and does not echo out any unnecessary data like incoming characters, command prompts, etc.
You're free, of course, to customise either of these board packags to meet your needs by changing individual values in projectconfig.h, but these two global settings will give you a good starting point and both will enable the command-line interface as well as the TFT LCD to be able to send external commands directly to the LCD. To program the LCD in native mode (in C) see Using the TFT LCD API.
Be sure to clean the solution ("make clean") and then rebuild it ("make all") after making these changes.
TFT-Related CLI Commands
The LPC1343 Code Base includes an easily extensible command-line interface (CLI) that can also be used to drive an LCD from a PC or external HW using USB or UART. Each individual command is encapsulated in a seperate source code file stored in the "/project/commands/*" folder. A full list of commands can be seen in the CLI by entering the "?" command, but the following TFT LCD-related commands are included as of v0.92 f the code base. Details on specific commands can be seen on the CLI by entering "<cmdname> ?":
|Command ||Parameters ||Description |
|b ||b <x> <y> <w> <h> <brdrclr> <fillclr> <fontclr> [<txt>] ||Button |
|B ||B <x> <y> <file> ||Bitmap (SD card) |
|c ||c <x> <y> <radius> <color> [<filled[0|1]> <bcolor>] ||Circle |
|C ||-- ||Calibrate Touch screen |
|F ||F [<color>] ||Fill screen |
|g ||g <x> <y> ||Get Pixel |
|l ||l <x1> <y1> <x2> <y2> <color> [<empty> <solid>] ||Line |
|L ||L <0|1> ||Backlight |
|o ||o [<0|1>] ||LCD Orientation |
|p ||p <x> <y> <color> ||Draw Pixel |
|P ||P <x> <y> <w> <h> <%> <bclr> <bfillclr> <pbrdclr> <pfillclr> ||Progress Bar |
|r ||r <x1> <y1> <x2> <y2> <color> [<filled[0|1]> <bcolor>] ||Rectangle |
|R ||R <x1> <y1> <x2> <y2> <color> <radius> <corners> ||Rounded Rectangle |
|s ||s <font#> <msg> ||Measure Text Width |
|t ||t <x> <y> <color> <font#> <msg> ||Draw Text |
|v ||v <x0> <y0> <x1> <y1> <x2> <y2> <color> [<filled[0|1]>] ||Triangle |
|W ||W [<ms>] ||Wait for touch event |
|x ||x [<0..254>] ||Touch threshold |
|Command ||Parameters ||Description |
|? ||-- ||Help Menu |
|V ||-- ||System Info (lcd size, etc.) |
|e ||e <addr> ||Read EEPROM |
|w ||w <addr> <val> ||Write EEPROM |
|U ||U [<val>] ||Get/Set UART Baud Rate |
|Z ||-- ||Reset |