Streamline your development process! This library enables rapid prototyping of graphical functions by utilizing the Arduino IDE's serial monitor to communicate via the serial port with any display supported by Adafruit GFX and TFT_eSPI libraries
.
It eliminates the need for time-consuming microcontroller uploads when testing graphical functions, you can focus on refining your designs more efficiently.
Simply use the serial monitor to send graphical commands to your microcontroller, in the example below the commands x;sc0,0;ttHello World!
when sent will clear the display and show Hello World! Make sure the option No Line Endind is selected in the Serial Monitor.
All display supported by Adafruit GFX and TFT_eSPI libraries
- Installation
- Code Setup Adafruit GFX
- Code Setup TFT_eSPI
- Examples
- Serial Commands Reference
- Using Fonts
- Library Configuration
- Library Size
- Serial Buffer Limitation
You can easily install the library in the Arduino IDE using the Library Manager, just search for "fastdisplay" and locate the FastDisplayPrototyping library and click the "Install" button.
ℹ️ You can also use get this setup code with the examples provided with the library in the Arduino IDE through the menu
File > Examples > FastDisplayPrototyping
// Core graphics library
#include <Adafruit_GFX.h>
// -- Hardware-specific library & Definitions Section
// -- Change this section according to your type of display
#include <Adafruit_TFTLCD.h>
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); // Initialize the display
// -- End of the Hardware-specific Section
// Fast Display Prototyping library
#define OUTPUT_CODE_ON_SERIAL // Output graphical functions on the Serial Monitor, comment it to disable
#include <FastDisplayPrototyping.h>
// Initialize the display prototyping library
FastSerialDisplay sDisplay(&tft, "tft");
void setup() {
Serial.begin(9600); // This line mandatory for using the display prototyping library, change the baud rate if needed
tft.begin();
tft.setRotation(0);
// Your specific code here
}
void loop(void) {
sDisplay.readCommandsFromSerial(); // This line mandatory for using the display prototyping library
// Your specific code here
}
ℹ️ You can also use get this setup code with the examples provided with the library in the Arduino IDE through the menu
File > Examples > FastDisplayPrototyping
// Core graphics library
// Don't forget to select the driver of your display in the User_Setup_Select.h file
#include <TFT_eSPI.h>
// Initialize the display
TFT_eSPI tft = TFT_eSPI();
// Fast Display Prototyping library
#define OUTPUT_CODE_ON_SERIAL // Output graphical functions on the Serial Monitor, comment it to disable
#include <FastDisplayPrototyping.h>
// Initialize the display prototyping library
FastSerialDisplay sDisplay(&tft,"tft");
void setup() {
Serial.begin(115200); // This line mandatory for using the display prototyping library, change the baud rate if needed
tft.begin();
tft.setRotation(0);
// Your specific code here
}
void loop(void) {
sDisplay.readCommandsFromSerial(); // This line mandatory for using the display prototyping library
// Your specific code here
}
ℹ️ You can send multiple graphical commands through the Serial Monitor by seperating them with a semicolon
;
Type this in the Serial Monitor | Result on the display |
---|---|
x;sc10,10;ttHello World! | Clear screen & print text on row 10 |
x;#ffe0;cf50,60,10 | Clear screen & Yellow filled circle at position 50,60 radius of 10 |
x;#077f;ri10,10,40,40,10 | Clear screen & Blue rounded rectangle outline at position 10,10, width 40, height 40, corner radius 10 |
ℹ️ You can replace any numeric value with
w
,h
,c
orm
and it will be replaced by the width, the height, half of the height or half of the width of the display respectively. For examplelhc,10,w
ℹ️ For most serial commands, you don't need to specify a color, as they will use the current color set by the#
serial command. This reduces the amount of typing needed
ℹ️ Color format is RGB565, you can use this Color Name Defintions Reference or RGB565 Color Picker (There are many others on the web)
ℹ️ A graphical function supported by Adafruit GFX is indicated withand supported by TFT_eSPI is indicated with
The library utilizes the currently defined font in the code. Support for handling multiple preloaded fonts is planned for the upcoming release of the library.
By default, the graphical commands corresponding to the serial commands sent are displayed in the Serial Monitor, allowing you to easily copy and paste them into your code. If you wish to disable this feature and reduce the library size, you can comment out this definition:
// #define OUTPUT_CODE_ON_SERIAL
To facilitate the process of copying graphical commands into your code, you can initialize the library using the variable that represents the display in your code. For instance, if you have a variable named "display" for the display in your code, you can initialize the library as follows:
// Initialize the display
TFT_eSPI tft = TFT_eSPI();
// Initialize the display prototyping library
serialDisplay sDisplay(&tft);
// Initialize the display
Adafruit_TFTLCD display(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
// Initialize the display prototyping library
serialDisplay sDisplay(&tft,"display");
All the graphical commands will be preceded by the "display" keyword, for example display.fillSmoothRoundRect(80,100,20,20,5,0xfde0,0x0);
The library utilizes a wide range of graphical functions, which can pose a challenge for microcontrollers with limited memory, such as the Arduino Uno or Nano. In such cases, you can use the library within an empty sketch to prototype your designs and then copy the code output from the Serial Monitor into your main sketch. This approach helps you avoid potential memory issues while still benefiting from the library's functionality.
Arduino Uno and Nano, both equipped with the ATmega328P microcontroller, have a default serial buffer size of 64 bytes. When sending data through the Serial Monitor it is crucial to be aware of this limitation, as attempting to send a message larger than 64 bytes can lead to data loss or unexpected behavior.
On the ESP32, the default serial buffer size is typically set to 256 bytes.