Skip to content

English WIKI

Frances9 edited this page Apr 24, 2020 · 7 revisions

GDL API Function List

C++/Arduino Example Tutorial

    #include "DFRobot_GDL.h"

    #define TFT_DC  2
    #define TFT_CS  3
    #define TFT_RST 4

    DFRobot_ST7789_240x240_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);

    void setup() {
         Serial.begin(115200);
         screen.begin();
    }

    void loop(){
        ///Set font size to 4, font range 1-4
        screen.setTextSize(2);
        //Set screen color 
        screen.fillScreen(COLOR_RGB565_BLACK);
        screen.setFont(&FreeMono12pt7b);//Set font to FreeMono12pt7b
        screen.setCursor(/*x=*/10,/*y=*/120);
        //Set text color 
        screen.setTextColor(COLOR_RGB565_LGRAY);
        //Set to text auto-wrap mode, true=Auto-wrap, false=No auto-wrap
        screen.setTextWrap(true);
        screen.print("HelloWorld!");
        delay(500);
    }
  • Note: In inofile, we have different constructors for various ICs and screens with different resolution: different MCUs define different pins. These functions can be directly called. All other parameters determine the connection of display.

References

begin

  • C Prototype:
void DFRobot_GDL::begin()
  • Description: Initialize screen and specify transmission rate
  • Parameter: none
  • Return Value: none

drawPixel

  • C++/Arduino Prototype:
void DFRobot_GDL::drawPixel(int16_t x, int16_t y, uint16_t color)
  • Description: draw a pixel at(x, y)
  • Parameter:
    • x: x-coordinate of the pixel
    • y: y-coordinate of the pixel
    • color: pixel color, RGB565 format
  • Return Value: none

fillScreen

  • C++/Arduino Prototype:
void DFRobot_GDL::fillScreen(uint16_t color)
  • Description: this is screen clear function:color is in RGB565 format
  • Parameter:
    • color: color to fill the screen, RGB565 format
  • Return Value: none

drawFastVLine

  • C++/Arduino Prototype:
void DFRobot_GDL::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
  • Description: function to draw vertical line fast;taking the (x, y) as a starting point, draw a vertical line with heighth
  • Parameter:
    • x: x-coordinate of the starting point of the vertical line
    • y: y-coordinate of the starting point of the vertical line
    • h: the height of the vertical line
    • color: the color of the vertical line, RGB565 format
  • Return Value: none

drawFastHLine

  • C++/Arduino Prototype:
void DFRobot_GDL::drawFastHLine(int16_t x, int16_t y, int16_t h, uint16_t color)
  • Description: function to draw horizontal line fast: taking the (x, y) as a starting point, draw a horizontal line with length h
  • Parameter:
    • x: x-coordinte of the starting point of the horizontal line
    • y: y-coordinate of the starting point of the horizontal line
    • h: horizontal line length
    • color: the horizontal line color, RGB565 format
  • Return Value: none

drawRect

  • C++/Arduino Prototype:
void DFRobot_GDL::drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
  • Description: draw a hollow rectangle at (x, y) with width w and height h
  • Parameter:
    • x: x-coordinate of the starting point of the rectangle
    • y: y-coordinate of the starting point of the rectangle
    • w: rectangle width
    • h: rectangle height
    • color: rectangle color, RGB565 format
  • Return Value: none

fillRect

  • C++/Arduino Prototype:
void DFRobot_GDL::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
  • Description: draw a filled rectangle at (x, y) with widthw and height h
  • Parameter:
    • x: x-coordinate of the starting point of the rectangle
    • y: y-coordinate of the starting point of the rectangle
    • w: rectangle width
    • h: rectangle height
    • color: rectangle color, RGB565 format
  • Return Value: none

drawCircle

  • C++/Arduino Prototype:
void DFRobot_GDL::drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
  • Description: draw a circle outline at(x0, y0) with radius r; The diameter2*r+1; color to draw with.
  • Parameter:
    • x0,y0: center point
    • r: Radius of circle: Radius = r
    • color: define the color
  • Return Value: none

drawCircleHelper

  • C++/Arduino Prototype:
void GDFRobot_GDL::drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,uint16_t color)
  • Description: drawCircleHelper draw a quarter-circle at(x0, y0) with radius r, used to do circles and roundrects. cornername mask bit for making quarter-circles, multiple combinations.
  • Parameter:
    • x0,y0: circle center point
    • r: Radius of circle: Radius = r
    • cornername:Mask bit#1 or bit #2 to indicate which quarters of the circle we are doing.
    • color: circle color, RGB565 format
  • Return Value: none

fillCircle

  • C++/Arduino Prototype:
void DFRobot_GDL::fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
  • Description: draw a filled circle at(x0, y0) with radius r. The diameter2*r+1, color to draw with.
  • Parameter:
    • x0,y0: circle center point
    • r: Radius of circle: Radius = r
    • color: circle color, RGB565 format
  • Return Value: none

fillCircleHelper

  • C++/Arduino Prototype:
void DFRobot_GDL::fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,int16_t delta, uint16_t color)
  • Description: fillCircleHelper draw a filled quarter-circle at (x0, y0) with radius r, used to do circles or roundRects. cornername mask bit for making quarter-circles, multiple combinations.
  • Parameter:
    • x0,y0: circle center point
    • r: Radius of circle :Radius = r
    • cornername: Mask bit #1 or bit #2 to indicate which quarters of the circle we are doing.
    • color: circle color, RGB565 format
  • Return Value: none

drawTriangle

  • C++/Arduino Prototype:
void DFRobot_GDL::drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,int16_t x2, int16_t y2, uint16_t color)
  • Description: draw a hollow triangle, 16-bit. x0/y0,x1/y1,x2/y2 are the three vertexes of the triangle.
  • Parameter:
    • x0: X0 vertex x-coordinate
    • y0: y0 vertex y-coordinate
    • x1: X1 vertex x-coordinate
    • y1: y1 vertex y-coordinate
    • x2: X2 vertex x-coordinate
    • y2: y2 vertex y-coordinate
    • color: triangle color, RGB565 format
  • Return Value: none

fillTriangle

  • C++/Arduino Prototype:
void DFRobot_GDL::fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,int16_t x2, int16_t y2, uint16_t color)
  • Description: draw a filled triangle, 16 bit. x0/y0,x1/y1,x2/y2 are the three vertexes of the triangle.
  • Parameter:
    • x0: X0 vertex x-coordinate
    • y0: y0 vertex y-coordinate
    • x1: X1 vertex x-coordinate
    • y1: y1 vertex y-coordinate
    • x2: X2 vertex x-coordinate
    • y2: y2 vertex y-ccordinate
    • color: triangle color, RGB565
  • Reture Value: none

drawRoundRect

  • C++/Arduino Prototype:
void DFRobot_GDL::drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,int16_t radius, uint16_t color)
  • Description: draw a hollow round Rectangle at x/y(top-left)with width w and height h. Some parts of the frame can be displayed outside of the boundary. Corner round radius: r. Requirements: w>=2*(r+1) and h>=2*(r+1). If w or h is smaller than 2*(r+1), define the function r.
  • Parameter:
    • x: top left corner x coordinate
    • y: top left corner y coordinate
    • w: round rectangle width
    • h: round rectangle heigth
    • r: Radius of corner rounding
    • color: round rectangle color, RGB565 format.
  • Return Value: none

fillRoundRect

  • C++/Arduino Prototype:
void DFRobot_GDL::fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,int16_t radius, uint16_t color)
  • Description: draw a filled round rectangle at x/y (top left) with width w and height h. Some parts of the frame can be dislayed outside of the boundary. Corner round radius: r. Requirements: w>=2*(r+1) and h>=2*(r+1). If w or h is smaller than 2*(r+1), define the function r.
  • Parameter:
    • x: top left corner x-coordinate
    • y: top left corner y-coordinate
    • w: round rectangle width
    • h: round rectangle height
    • r: Radius of corner rounding
    • color: round rectangle color, RGB565.
  • Return Value: none

drawBitmap

  • C++/Arduino Prototype:
void DFRobot_GDL::drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],int16_t w, int16_t h, uint16_t color)

void DFRobot_GDL::drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],int16_t w, int16_t h, uint16_t color, uint16_t bg)

void DFRobot_GDL::drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,int16_t w, int16_t h, uint16_t color)

void DFRobot_GDL::drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,int16_t w, int16_t h, uint16_t color, uint16_t bg)
  • Description: drawBitmap overload multiple functions. Draw a monochrome bitmap at the specified x, y position. Some parts of the bitmap may not be displayed within the boundary.bitmap: bitmap array or pointer to the start of the bitmap. w and h are the height and width of the bitmap; color 16-bit 5-6-5 to draw pixels with, and bg 16-bit 5-6-5 color to draw background with.
  • Parameter:
    • x: X position
    • y: Y position
    • bitmap: bitmap array or pointer to the start of the bitmap
    • w: the width of the bitmap
    • h: the height of the bitmap
    • color: draw 16-bit 5-6-5 monochrome picture color
    • bg: draw a 16-bit background color of 5-6-5
  • Return value: none

drawXBitmap

  • C++/Arduino prototype:
void DFRobot_GDL::drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[],int16_t w, int16_t h, uint16_t color)
  • Description: drawXBitmap draw PROGMEM-resident XBitMap Files (*.xbm), exported from GIMP. Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in the editor. C Array can be directly used with this function. There is no RAM-resident version of this function; if generating bitmaps in RAM, use the format defined by drawBitmap() and call that instead. Draw a monochrome bitmap at the specified x, y position (top left corner of the bitmap). Some parts of the bitmap may not be displayed within the display boundary. bitmap: bitmap array. w, h are the height and width of the bitmap; color 16-bit 5-6-5 to draw monochrome image with.
  • Parameter:
    • x: X position
    • y: Y position
    • bitmap: bitmap array
    • w: the width of the bitmap
    • h: the height of the bitmap
    • color: 16-bit 5-6-5 to draw monochrome image with
  • Return value: none

drawGrayscaleBitmap

  • C++/Arduino Prototype:
void DFRobot_GDL::drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[],int16_t w, int16_t h)

void DFRobot_GDL::drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap,int16_t w, int16_t h)

void DFRobot_GDL::drawGrayscaleBitmap(int16_t x, int16_t y,const uint8_t bitmap[], const uint8_t mask[],int16_t w, int16_t h)

void DFRobot_GDL::drawGrayscaleBitmap(int16_t x, int16_t y,uint8_t *bitmap, uint8_t *mask, int16_t w, int16_t h)
  • Description: drawGrayscaleBitmap overload multiple functions. It aims to draw a progmemeresident 8-bit image (grayscale) at the specified position (x, y). Especially for 8-bit display devices, such as IS31FL3731; no color reduction/expansion is performed. Draw an 8-bit bitmap at the specified x, y position (top left corner of the bitmap). Some parts of the bitmap may not be displayed within the display boundary. bitmap: bitmap array or a pointer to the start of the bitmap; mask: byte array with mask bitmap. w and h are the height and width of the bitmap.
  • Parameter:
    • x: X position
    • y: Y position
    • bitmap: grayscale bitmap array or pointer to the start of grayscale bitmap
    • mask: byte array with mask bitmap
    • w: the width of the bitmap
    • h: the height of the bitmap
  • Return Value: none

drawRGBBitmap

  • C++/Arduino Prototype:
void DFRobot_GDL::drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[],int16_t w, int16_t h)

void DFRobot_GDL::drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap,int16_t w, int16_t h)

void DFRobot_GDL::drawRGBBitmap(int16_t x, int16_t y,const uint16_t bitmap[], const uint8_t mask[],int16_t w, int16_t h)

void DFRobot_GDL::drawRGBBitmap(int16_t x, int16_t y,uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h)
  • Description: drawRGBBitmap overload multiple functions. Draw a RAM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position (top left corner of the bitmap); For 16-bit display devices; no color reduction performed. Some parts of the bitmap may not be displayed within the display boundary. bitmap: or a pointer to the start of the bitmap;mask: byte array with mask bitmap. w and h are the height and width of the bitmap.
  • Parameter:
    • x: X position
    • y: Y position
    • bitmap: bitmap array or pointer to the start of the bitmap.
    • mask: byte array with mask bitmap
    • w: the width of the bitmap
    • h: the height of the bitmap
  • Return Value: none

drawChar

  • C++/Arduino Prototype:
void DFRobot_GDL::drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,uint16_t bg, uint8_t size)

void DFRobot_GDL::drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,uint16_t bg, uint8_t size_x,uint8_t size_y)
  • Description: drawChar draw a single character, overloaded. Draw the character at the specified x, y position (top left corner of the character). size: set the font magnification level. size_z and size_y: customize the enlargement level of the font's length and width.
  • Parameter:
    • x: X position
    • y: Y position
    • c: the 8-bit font-indexed character (likely ascii)
    • color: 16-bit 5-6-5 Color to draw chraracter with
    • bg: 16-bit 5-6-5 Color to fill background with
    • size: font magnification level (1-6), 1 is the" original "size.
    • size_z: font magnification level in x-axis (1-6), 1 is the" original "size.
    • size_y: the font magnification level in y-axis (1-6), 1 is the" original "size.
  • Return Value: none

getTextBounds

  • C++/Arduino Prototype:
void DFRobot_GDL::getTextBounds(const char *string, int16_t x, int16_t y,int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)

void DFRobot_GDL::getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)

void DFRobot_GDL::getTextBounds(const String &str, int16_t x, int16_t y,int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)
  • Description:getTextBounds help to determine size of a string with current font/size. Pass string and a cursor position, returns UL corner and W,H. Overloaded.
  • Parameter:
    • string: the ascii string to measure
    • s: the flash ascii string to measure
    • str: measure ascii string(as arduino string () class).
    • x: current cursor X.
    • y: current cursor y.
    • x1: boundary X coordinate, set by function
    • y1: boundary y coordinate, set by function
    • w: boundary width, set by function
    • h: boundary height, set by function
  • Return Value: none

getRotation

  • C Prototype:
uint8_t getRotation(void)
  • Description: getRotation get rotation setting for the display. Used to determine the current display direction, 0~3 corresponds to 4 basic rotations.
  • Parameter: none
  • Return value: 0-3; corresponds to 4 basic rotations.
Parameter Description
0 No rotation, horizontal
1 Rotate 90 degrees clockwise
2 Rotate 180 degrees clockwise
3 Rotate 270 degrees clockwise

getCursorX

  • C Prototype:
int16_t getCursorX(void)
  • Description: getCursorX get text cursor X location.
  • Parameter: none
  • Return value: X coordinate in pixels.

getCursorY

  • C Prototype:
int16_t getCursorY(void)
  • Description: getCursorY get text cursor Y location
  • Parameter: none
  • Return Value: Y coordinate in pixels

setTextSize

  • C++/Arduino Prototype:
void DFRobot_GDL::setTextSize(uint8_t s)

void DFRobot_GDL::setTextSize(uint8_t sx, uint8_t sy)
  • Description: setTextSize Set text 'magnification' size. The length and width are set by the function. sx and sy are designed to customize the enlargement level of the font's length and width.
  • Parameter:
    • s: desired text size. 1 is the default 6x8, 2 is 12x16, 3 is 18x24, and so on
    • sx: desired text width magnification level in X-axis. 1 is default
    • sy: desired text width magnification level in Y-axis. 1 is default
  • Return Value: none

setFont

  • C++/Arduino Prototype:
void DFRobot_GDL::setFont(const GFXfont *f = NULL)
  • Description: setFont set the font display when printing (), which can be customized or default. size: set the font magnification level; the length and width are set by the function. sx and sy are designed to customize the enlargement level of the font's length and width.

  • Parameter:

    • f: pointer to the font structure, pointing to GFXfont or gdl_Font_t.
  • Return Value: none

setRotation

  • C++/Arduino Prototype:
void DFRobot_GDL::setRotation(uint8_t r)
  • Description: Set the rotation direction, r is valid for 0,1,2,3.
  • Parameter:
    • r: the rotation direction of the font.
Parameter Description
0 No rotation, horizontal
1 Rotate 90 degrees clockwise
2 Rotate 180 degrees clockwise
3 Rotate 270 degrees clockwise
  • Return Value: none

setCursor

  • C Prototype:
void setCursor(int16_t x, int16_t y)
  • Description: setCursor set the cursor position.

  • Parameter:

    • x: X coordinate (in pixel)
    • y: Y coordinate (in pixel)
  • Return Value: none

setTextColor

  • C Prototype:
void setTextColor(uint16_t c)

void setTextColor(uint16_t c, uint16_t bg)
  • Explanation: setTextColor set the text font color and transparent background or set the text font color and customize the background color. For a "transparent" background, the background and foreground are set to same color instead of using a separate flag.

  • Parameter:

    • c: 16-bit 5-6-5 color to draw text with
    • bg: 16-bit 5-6-5 color to draw background/fill with
  • Return Value: none

setTextWrap

  • C Prototype:
void setTextWrap(uint16_t c)
  • Description: setTextColor set whether text that is too long for the screen width should automatically wrap around to the next line (else clip right).

  • Parameter:

    • c: true for wrapping, and false for clipping.
  • Return Value: none

width

  • C Prototype:
int16_t width(void)
  • Description: width get the display width, taking into account the current rotation.
  • Parameter: none
  • Return Value: Width (in pixel).

hight

  • C Prototype:
int16_t hight(void)
  • Description: hight get the display length, taking into account the current rotation.
  • Parameter: none
  • Return Value: Length (in pixel).

cp437

  • C Prototype:
void cp437(boolean x=true)
  • Description: setTextColor enable (or disable) the code page 437-compatible character set. There was an error in glcdfont.c for the longest time – one character (#176, the 'light shade' block) was missing – this threw off the index of every character that followed it. But a ton of code has been written with the erroneous character indices. By default, the library uses the original 'wrong' behavior and old sketches will still work. Pass 'true' to this function to use correct CP437 character values in your code.

  • Parameter:

    • c:true = enable (new behavior), false = disable (old behavior).
  • Return Value: none

UI

C ++ / Aduino example tutorial

#include "DFRobot_UI.h"
#include "Arduino.h"
#include "DFRobot_GDL.h"
#include "DFRobot_Touch.h"

/* M0 */
#if defined ARDUINO_SAM_ZERO
#define TFT_DC 7
#define TFT_CS 5
#define TFT_RST 6
#define TOUCH_CS A3
/* ESP32 and ESP8266 */
#elif defined (ESP32) || defined (ESP8266)
#define TFT_DC D3
#define TFT_CS D4
#define TFT_RST D5
#define TOUCH_CS D6
/* AVR series motherboard */
#else
#define TFT_DC 2
#define TFT_CS 3
#define TFT_RST 4
#define TOUCH_CS 5
#endif

// Touch constructor, construct the touched object
DFRobot_Touch_XPT2046 touch (/* cs = */ TOUCH_CS);
// Screen constructor, contruct the screen object
DFRobot_ILI9341_240x320_HW_SPI screen (/* dc = */ TFT_DC, /* cs = */ TFT_CS, /* rst = */ TFT_RST);

/**
 * @brief UI constructor
 * @param gdl screen object
 * @param touch touch object
 */
DFRobot_UI ui (& screen, & touch);

uint8_t value1 = 0;
uint8_t value2 = 0;
uint8_t value3 = 0;
// Callback function of progress bar1
void barCallback1 (DFRobot_UI :: sBar_t & obj) {
    // Automatically make the progress bar value plus 1 every time;
   delay (50);
    obj.setValue (value1);
if (value1 <100) value1 ++;
}
// Callback function of progress bar2
void barCallback2 (DFRobot_UI :: sBar_t & obj) {
    // Automatically make the progress bar value plus 1 every time;
    delay (50);
    obj.setValue (value2);
if (value2 <100) value2 ++;
The
}
// The callback function of the progress bar3
void barCallback3 (DFRobot_UI :: sBar_t & obj) {
    // Automatically make the progress bar value plus 1 every time;
    delay (50);
    obj.setValue (value3);
if (value3 <100) value3 ++;
}
void setup ()
{
  
  Serial.begin (9600);
  // Initialize UI 
  ui.begin ();
  ui.setTheme (DFRobot_UI :: MODERN);

  // Display the string on the screen
  ui.drawString (/* x = */ 33, /* y = */ screen.height () / 5 * 4, "Page of loading", COLOR_RGB565_WHITE, ui.bgColor, /* fontsize = */ 2, /* Invert = */ 0);
  // Create a progress bar control
  DFRobot_UI :: sBar_t & bar1 = ui.creatBar ();
  /** User-defined progress bar parameters */
  bar1.setStyle (DFRobot_UI :: COLUMN);
  bar1.fgColor = COLOR_RGB565_GREEN;
  bar1.setCallback (barCallback1);
  ui.draw (& bar1, /* x = */ 33, /* y = */ screen.height () / 5 * 3);
  
  DFRobot_UI :: sBar_t & bar2 = ui.creatBar ();
  /** User-defined progress bar parameters */
  bar2.setStyle (DFRobot_UI :: CIRCULAR);
  bar2.setCallback (barCallback2);
  ui.draw (& bar2, /* x = */ 120, /* y = */ screen.height () / 5 * 2);

  DFRobot_UI :: sBar_t & bar3 = ui.creatBar ();
  /** User-defined progress bar parameters */
  bar3.fgColor = COLOR_RGB565_BLUE;
  bar3.setStyle (DFRobot_UI :: BAR);
  bar3.setCallback (barCallback3);
  ui.draw (& bar3, /* x = */ (screen.width ()-bar3.width) / 2, /* y = */ screen.height () / 5 * 1);
}


void loop ()
{
  // Refresh all controls
  ui.refresh ();
}
  • Description:
    • DFRobot_UI ui(&screen, &touch)UI constructor can pass in screen and touch objects.
    • DFRobot_UI ui(&screen, NULL)UI constructor can only pass in screen objects, other objects are empty.

begin

  • C++ Prototype:
void DFRobot_UI::begin()
  • Explanation: The begin initialization function initializes the parameters used by the UI.
  • Parameter: none
  • Return Value: none

setTheme

  • C++ Prototype:
void DFRobot_UI::setTheme(eTheme_t the)
  • Description: setTheme set the UI theme function and initialize the parameters used by the UI. the is eTheme_t type data and contains two themes.
  • Parameter:
    • the: CLASSIC is a classic theme, MODERN is a popular theme.
  • Return Value: none

setGestureArea

  • C++ Prototype:
void DFRobot_UI::setGestureArea(uint16_t x,uint16_t y,uint16_t width,uint16_t height)
  • Description: setGestureArea set the touch gesture recognition area.
  • Parameter:
    • x: the x coordinate of the start position of the recognition area.
    • x: the y coordinate of the start position of the recognition area.
    • width: the width of the recognition area.
    • height: the height of the recognition area.
  • Return Value: none

draw

  • C++ Prototype:
void DFRobot_UI::draw(sObject_t *obj,uint16_t posx = 0,uint16_t posy = 0,uint16_t width = 0,uint16_t height = 0)
  • Description: draw control.
  • Parameter:
    • obj: control object
    • posx: the x coordinate of the control
    • posy: the y coordinate of the control
    • width: the width of the control
    • height: the height of the control
  • Return Value: none

drawString

  • C++ Prototype:
void DFRobot_UI::drawString(int16_t x, int16_t y, char  *c, uint16_t color, uint16_t bg, uint8_t size, boolean mode)
  • Description: draw string. Start drawing the string c at ( x, y).
  • Parameter:
    • x: the x coordinate of the string to be drawn on the screen
    • y: the x coordinate of the string to be drawn on the screen
    • c: pointer to character array
    • color: font color
    • bg: font background color
    • size: font size
    • mode: font display mode. 0: normal display; 1: color inversion
  • Return Value: none

refresh

  • C++ Prototype:
void DFRobot_UI::refresh()
  • Description: refresh refresh the screen.
  • Parameter: none
  • Return Value: none

endInput

  • C++ Prototype:
void DFRobot_UI::endInput()
  • Description: endInput make the text box stop inputting.
  • Parameter: none
  • Return Value: none

getGestureArea

  • C Prototype:
eGestures_t getGestures()
  • Explanation: getGestureArea gets gestures.
  • Parameter: none
  • Return Value: eGestures_t type data represents different gestures.
Return parameter Description
DUPGLIDE Swipe up
DDOWNGLIDE Swipe down
DLEFTGLIDE swipe left
DRIGHTGLIDE swipe right
DLONGPRESSDE Long press on the screen
DSINGLECLICK Click on the screen
DDOUBLECLICK Double click the screen
NONE No gesture

creatKeyPad

  • C Prototype:
sKeyPad_t &creatKeyPad()
  • Explanation: creatKeyPad creates a numeric keyboard on the screen.
  • Parameter: none
  • Return Value: the address of the numeric keyboard object.

creatButton

  • C Prototype:
sButton_t &creatButton()
  • Description: creatButton creates a button control on the screen.
  • Parameter: none
  • Return Value: the address of the button object.

creatText

  • C Prototype:
sTextBox_t &creatText()
  • Description: creatText create a text box control on the screen.
  • Parameter: none
  • Return Value: the address of the text box object.

creatSlider

  • C Prototype:
sSlider_t &creatSlider()
  • Description: creatSlider creates a slider control on the screen.
  • Parameter: none
  • Return Value: the address of the slider object.

creatSwitch

  • C Prototype:
sSwitch_t &creatSwitch()
  • Description: creatSwitch create a switch control on the screen.
  • Parameter: none
  • Return Value: the address of the switch object.

creatTableview

  • C Prototype:
sTableview_t &creatTableview()
  • Description: creatTableview create a tableview control on the screen.
  • Parameter: none
  • Return Value: the address of the tableview object.

creatBar

  • C Prototype:
sBar_t &creatBar()
  • Description: creatBar create a progress bar on the screen.
  • Parameter: none
  • Return Value: the address of the progress bar object.

Touch

Touch constructor

  • DFRobot_Touch_GT911
    • Description: constructor for touch chip GT911
    • Usage:
// Touch constructor, construct the touch object
DFRobot_Touch_GT911 touch(/*cs=*/TOUCH_CS);
  • DFRobot_Touch_XPT20466
    • Explanation: Constructor for touch chip XPT2046
    • Usage:
// Touch constructor, construct the touch object
DFRobot_Touch_XPT2046 touch(/*cs=*/TOUCH_CS);