API
Install and include our kgfx
library to access these APIs.
In platformio.ini
:
Check the latest version of kgfx
here.
In your source or header files:
Index
TFT_eSprite createSprite(width x, height y)
void drawChart(std::vector<float> arr, int color, int y)
void deleteSprite(TFT_eSprite &spr)
void drawText(const char *txt, const tftfont_t &f, int color, int x, int y)
void drawText(TFT_eSprite &spr, const char *txt, const tftfont_t &f, int color, int x, int y)
TFT_eSprite createSprite
createSprite creates the sprite of the size of width
*height
in pixels, for drawing text or numbers on it so that the text or numbers can be regularly updated without causing flicker on the screen.
Example
TFT_eSPI_ext tft
tft returns an instance of the tft library (extended), which was initialized in KGFX
. With this instance, you can use any of the TFT_eSPI functions directly, on top of the helper functions KGFX
provides.
Example
void clear
clear clears the screen by painting it black.
Example
void createChartSprite
createChartSprite enforces strict dimensions and creates a sprite of the size of 240
*80
in pixels and stores that object as a private variable with the UI object so there is no need to manage the chart sprite object.
Example
void deleteChartSprite
deleteChartSprite deletes the chart sprite and frees up memory. Call this when you no longer need to use the chart sprite.
Example
void deleteSprite
deleteSprite deletes the given sprite and frees up memory. Call this when you no longer need to use the sprite.
Example
void drawChart
drawChart plots a graph with the given array. An array of maximum length of 30 will be plotted onto the chart sprite with a default size of 240 by 80 pixels. You must create the chart sprite first.
Example
void drawText
drawText draws text or numbers on the screen. Use this if text will be not updated at regular intervals. Numbers will be have to converted to const char
format.
Example
To convert a float
or int
type variable to a string for printing on screen, use std::to_string(v)
.
Example
void drawText (sprite)
drawText (sprite) requires an additional argument, a sprite object type. Use this if your text or numbers will be updated at regular intervals. Numbers will be have to converted to const char
format.
Use createSprite to create the sprite object.
Example
void init
init initializes the display library. Call this before you use any of the KFGX library.