add flush/clear funcs
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
|
|
||||||
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) {
|
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) {
|
||||||
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;
|
||||||
if (c < f->first || c > f->last) return;
|
if (c < f->first || c > f->last) return;
|
||||||
const GFXglyph *g = &f->glyph[c - f->first];
|
const GFXglyph *g = &f->glyph[c - f->first];
|
||||||
const uint8_t *bm = f->bitmap + g->bitmapOffset;
|
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 */
|
/* 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 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 dx = end_x - start_x;
|
||||||
const uint8_t dy = end_y - start_y;
|
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 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 x = pos_x; x < pos_x + size_x; x++)
|
||||||
for (uint8_t y = pos_y; y < pos_y + size_y; y++)
|
for (uint8_t y = pos_y; y < pos_y + size_y; y++)
|
||||||
draw_cb(canvas->ctx, x, 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 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;
|
const uint8_t row_bytes = (bmp.width + 7) / 8;
|
||||||
|
|
||||||
for (uint8_t y = 0; y < bmp.height; y++) {
|
for (uint8_t y = 0; y < bmp.height; y++) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <esp_err.h>
|
||||||
|
|
||||||
// compatibility for adafruit fonts
|
// compatibility for adafruit fonts
|
||||||
#ifndef PROGMEM
|
#ifndef PROGMEM
|
||||||
@@ -39,11 +39,11 @@ typedef struct {
|
|||||||
* @param clear_fb_callback function that wipes the framebuffer memory of the display, optional
|
* @param clear_fb_callback function that wipes the framebuffer memory of the display, optional
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void (*draw_pixel_callback)(void *ctx, uint8_t x, uint8_t y);
|
esp_err_t (*draw_pixel_callback)(void *ctx, uint8_t x, uint8_t y);
|
||||||
void (*clear_pixel_callback)(void *ctx, uint8_t x, uint8_t y);
|
esp_err_t (*clear_pixel_callback)(void *ctx, uint8_t x, uint8_t y);
|
||||||
void (*flush_callback)(void *ctx);
|
esp_err_t (*flush_callback)(const void *ctx);
|
||||||
void (*clear_disp_callback)(void *ctx);
|
esp_err_t (*clear_disp_callback)(void *ctx);
|
||||||
void (*clear_fb_callback)(void *ctx);
|
esp_err_t (*clear_fb_callback)(void *ctx);
|
||||||
void *ctx;
|
void *ctx;
|
||||||
} gfx_canvas_t;
|
} gfx_canvas_t;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ dependencies:
|
|||||||
idf: '>=5.2'
|
idf: '>=5.2'
|
||||||
description: Simple gfx library for ESP-IDF
|
description: Simple gfx library for ESP-IDF
|
||||||
url: https://git.drath.cc/drath/esp-gfx.git
|
url: https://git.drath.cc/drath/esp-gfx.git
|
||||||
version: "1.2.0"
|
version: "1.3.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user