29 lines
987 B
Markdown
29 lines
987 B
Markdown
# Simple graphics library
|
|
|
|
Will draw Adafruit GFX compatible fonts, lines, squares, and it will also fill a square. It can draw or clear any of these. That's it, graphics as God intended.
|
|
|
|
Made for ST7920 with my own driver library, but it should be pretty universal, it just needs draw and clear functions taking x,y coords of a pixel + some user context.
|
|
|
|
The API is pretty self-explanatory, but just in case
|
|
|
|
```c
|
|
#include <esp-gfx/gfx.h>
|
|
#include <esp-gfx/fonts/NokiaBig.h>
|
|
|
|
const gfx_canvas_t canvas = {
|
|
.ctx = &dev,
|
|
.draw_pixel_callback = st7567_draw_pixel,
|
|
.clear_pixel_callback = st7567_clear_pixel,
|
|
.clear_disp_callback = st7567_clear,
|
|
.clear_fb_callback = st7567_clear_buffer,
|
|
.flush_callback = st7567_update_screen
|
|
};
|
|
|
|
const GFXfont *font = &NokiaBig;
|
|
st7567_clear(canvas.ctx);
|
|
gfx_fill_box(&canvas, 40, 40, 8, 8, false);
|
|
gfx_draw_string(&canvas, font, 0, 16, "Hello", false);
|
|
st7567_update_screen(canvas.ctx);
|
|
```
|
|
|
|
Some included default fonts. Cozette, Spleen, Terminus |