Example Code for Arduino - gettureFont
This is a UI control demo—a numeric keypad. First, click the text box to display the cursor, then click the numbers to show the corresponding digits in the text box. The "x" in the bottom right corner of the keypad is used to delete content in the text box.
Precautions Before Use
- The GDI interface must be used with a main controller that has a GDI interface.
- It is recommended to use Arduino 1.8.10 or a later version.
- Poor contact of the SD card slot may cause initialization failure; reinserting the SD card may resolve the issue.
Hardware Preparation
- 1 × Firebeetle 2 ESP32-E Development Board (SKU: DFR0654)
- 1 ×3.5" 480×320 IPS Capacitive Touchscreen (SKU: DFR1092)
- 1 × 18-pin FPC Cable
- Several Dupont Wires
Software Preparation
- Download Arduino IDE: Click to download Arduino IDE
- Download Arduino Library: Click to download DFRobot_GDL Library File
- Click the link to view: How to Install the Library?
Hardware Connection
GDI Cable Connection Method

2.54 Pin Header Connection Method

| Display Pin | Controller Pin |
|---|---|
| VCC | 3V3 |
| GND | GND |
| CLK | SCK |
| SI | MO |
| SO | MI |
| SCR_CS | D6 |
| RST | D3 |
| DC | D2 |
| BL | D13 |
| SCL | SCL |
| SDA | SDA |
| INT | D11 |
| SD_CS | Do not use / Leave unconnected |
| TP_R | D10 |
- All demonstration demos for this product are stored in the
DFRobot_GDL->example->basicfolder.- Before burning the demo, enable the corresponding instantiation function (
DFRobot_ST7365P_320x480_HW_SPI).
Sample Code
Program Description: This is a UI control demo—a numeric keypad. First, click the text box to display the cursor, then click the numbers to show the corresponding digits in the text box. The "x" in the bottom right corner of the keypad is used to delete content in the text box.
#include "DFRobot_UI.h"
#include "Arduino.h"
#include "DFRobot_GDL.h"
#include "DFRobot_Touch.h"
/*ESP32 and ESP8266*/
#if defined(ESP32)
#define TFT_DC D2
#define TFT_CS D6
#define TFT_RST D3
#define TFT_BL D13
#define TOUCH_RST D10
#define TOUCH_INT D11
#endif
DFRobot_Touch_GT911_IPS touch(0X5D,TOUCH_RST,TOUCH_INT);
DFRobot_ST7365P_320x480_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST,/*bl=*/TFT_BL);
DFRobot_UI ui(&screen, &touch);
void setup()
{
Serial.begin(9600);
ui.begin();
// Set the UI theme, there are two themes to choose from: CLASSIC and MODERN.
ui.setTheme(DFRobot_UI::CLASSIC);
//Create a numeric keypad
DFRobot_UI::sObject_t &kp = ui.creatKeyPad();
ui.draw(&kp);
}
void loop()
{
// refresh
ui.refresh();
}
Was this article helpful?
