diff --git a/esp-gfx/gfx.c b/esp-gfx/gfx.c index 92b5559..6d93bc4 100644 --- a/esp-gfx/gfx.c +++ b/esp-gfx/gfx.c @@ -2,8 +2,8 @@ #include -void gfx_draw_char(const gfx_canvas_t *canvas, const GFXfont *f, const bool inverted, const int16_t x, const int16_t y, const char c, const uint8_t scale) { - void (*draw_cb)(void* ctx, uint8_t x, uint8_t y) = inverted ? canvas->clear_pixel_callback : canvas->draw_pixel_callback; +static void gfx_draw_char(const gfx_canvas_t *canvas, const GFXfont *f, const bool inverted, const int16_t x, const int16_t y, const char c, const uint8_t scale) { + esp_err_t (*draw_cb)(void* ctx, uint8_t x, uint8_t y) = inverted ? canvas->clear_pixel_callback : canvas->draw_pixel_callback; if (c < f->first || c > f->last) return; const GFXglyph *g = &f->glyph[c - f->first]; const uint8_t *bm = f->bitmap + g->bitmapOffset; @@ -52,7 +52,7 @@ int16_t gfx_draw_string_centered(const gfx_canvas_t *canvas, const GFXfont *f, c /* only draws top->bottom and left->right */ void gfx_draw_line(const gfx_canvas_t *canvas, const uint8_t start_x, const uint8_t start_y, const uint8_t end_x, const uint8_t end_y, const bool inverted) { - void (*draw_cb)(void* ctx, uint8_t x, uint8_t y) = inverted ? canvas->clear_pixel_callback : canvas->draw_pixel_callback; + esp_err_t (*draw_cb)(void* ctx, uint8_t x, uint8_t y) = inverted ? canvas->clear_pixel_callback : canvas->draw_pixel_callback; const uint8_t dx = end_x - start_x; const uint8_t dy = end_y - start_y; @@ -92,14 +92,14 @@ void gfx_draw_box(const gfx_canvas_t *canvas, const uint8_t pos_x, const uint8_t } void gfx_fill_box(const gfx_canvas_t *canvas, const uint8_t pos_x, const uint8_t pos_y, const uint8_t size_x, const uint8_t size_y, const bool inverted) { - void (*draw_cb)(void* ctx, uint8_t x, uint8_t y) = inverted ? canvas->clear_pixel_callback : canvas->draw_pixel_callback; + esp_err_t (*draw_cb)(void* ctx, uint8_t x, uint8_t y) = inverted ? canvas->clear_pixel_callback : canvas->draw_pixel_callback; for (uint8_t x = pos_x; x < pos_x + size_x; x++) for (uint8_t y = pos_y; y < pos_y + size_y; y++) draw_cb(canvas->ctx, x, y); } void gfx_draw_bitmap(const gfx_canvas_t *canvas, const uint8_t pos_x, const uint8_t pos_y, const gfx_bitmap_t bmp, const bool inverted) { - void (*draw_cb)(void* ctx, uint8_t x, uint8_t y) = inverted ? canvas->clear_pixel_callback : canvas->draw_pixel_callback; + esp_err_t (*draw_cb)(void* ctx, uint8_t x, uint8_t y) = inverted ? canvas->clear_pixel_callback : canvas->draw_pixel_callback; const uint8_t row_bytes = (bmp.width + 7) / 8; for (uint8_t y = 0; y < bmp.height; y++) { diff --git a/esp-gfx/gfx.h b/esp-gfx/gfx.h index 09b022c..92f74a8 100644 --- a/esp-gfx/gfx.h +++ b/esp-gfx/gfx.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include // compatibility for adafruit fonts #ifndef PROGMEM @@ -39,11 +39,11 @@ typedef struct { * @param clear_fb_callback function that wipes the framebuffer memory of the display, optional */ typedef struct { - void (*draw_pixel_callback)(void *ctx, uint8_t x, uint8_t y); - void (*clear_pixel_callback)(void *ctx, uint8_t x, uint8_t y); - void (*flush_callback)(void *ctx); - void (*clear_disp_callback)(void *ctx); - void (*clear_fb_callback)(void *ctx); + esp_err_t (*draw_pixel_callback)(void *ctx, uint8_t x, uint8_t y); + esp_err_t (*clear_pixel_callback)(void *ctx, uint8_t x, uint8_t y); + esp_err_t (*flush_callback)(const void *ctx); + esp_err_t (*clear_disp_callback)(void *ctx); + esp_err_t (*clear_fb_callback)(void *ctx); void *ctx; } gfx_canvas_t; diff --git a/idf_component.yml b/idf_component.yml index 3b1c4ab..211ee81 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -2,4 +2,4 @@ dependencies: idf: '>=5.2' description: Simple gfx library for ESP-IDF url: https://git.drath.cc/drath/esp-gfx.git -version: "1.2.0" +version: "1.3.0"