a tiny gfx library for tft/lcd/oled screen. Platform independent. etc.. C51, STM32, Arduino, Linux, Windows, MacOSX.
中文文档: http://timor.tech/project/tGFX
English: http://timor.tech/project/tGFX/en
https://github.com/LanFly/tGFX/issues
There are no test cases now. But I will write it as soon as possible.
gfx-demo-x86: This is tGFX demo for x86 on MacOSX or Linux using X11.
more examples are under development.
#include "tGFX/565/font.h"
// use 5*8 bitmap font. Font Name: FONT_5X8
#include "tGFX/font/5x8.h"
tGFX_draw_text(canvas, 10, 110, "Hello tGFX!\n...", 16, &FONT_5X8, 0xffff);
choose a color mode to use then include it.
example:
#include "tGFX.h"
#include "tGFX/565/basic.h"
int main()
{
// use 565 color canvas.
tGFX_Canvas *canvas = tGFX_create_canvas(128, 128, tGFX_COLOR_MODE565);
tGFX_draw_pixel(canvas, 63, 63, 0xffff);
return 0;
}
Use macro tGFX_USE_REAL_TIME
to indicate that you want to use Real-Time mode.
CMakeLists.txt
# using real-time drawing mode
add_compile_definitions(tGFX_USE_REAL_TIME)
example:
#include "tGFX.h"
#include "tGFX/565/basic.h"
// TGFX will call this function in real time.
void tGFX_draw_pixel(tGFX_Canvas *canvas, uint16_t x, uint16_t y,
uint16_t color) {
// overflow hidden.
if (x > canvas->width || y > canvas->height) {
return;
}
// you should drawing pixel(color) on position(x, y) here
}
int main()
{
// use 565 color canvas.
tGFX_Canvas ncanvas;
// ref ncanvas
tGFX_Canvas *canvas = &ncanvas;
// use tGFX_init_canvas replace tGFX_create_canvas
tGFX_init_canvas(canvas, 128, 128, tGFX_COLOR_MODE565);
tGFX_draw_line(canvas, 10, 10, 100, 30, 0x35d3);
return 0;
}
reference: examples/gfx-real-time-demo-x86/
We recommend using CMake to build your program. But you can still compile it manually.
There are 2 parts of source code that should be compiled into your program.
tGFX.c
is always needed. It provides the main tGFX_create_canvas
functions.src/tGFX/${color_mode}/*.c
also needed. It provides the set of drawing functions. example tGFX_draw_pixel
.And don't forget to set the include path to /path/to/tGFX/include
.
reference: examples/gfx-demo-x86/CMakeLists.txt
CMake Options:
tGFX_USE_COLOR_MODE description: which color mode to use. Only one color mode can be used at the same time by default. default value: 565
tGFX_USE_TOOLS description: whether to include tools source file. default value: false
tGFX is platform independent. So you can develop and debug drawings code on PC, such as MacOSX, Linux, Windows.
tGFX provides a demo of using X11 to debug drawings code on MacOSX. See examples/gfx-demo-x86/README.md for details.
Any kind of contribution is welcome, such as new features, improvement, bug fix, document, translations, examples.
tGFX is designed to be lightweight, fast, simple and independent. So we hope the code to be clean and friendly to read.
Here are a few things to follow:
./scripts/run-clang-format.sh
before committing your PR.more font under development
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。