60 lines
2.5 KiB
C
60 lines
2.5 KiB
C
#pragma once
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
// compatibility for adafruit fonts
|
|
#ifndef PROGMEM
|
|
#define PROGMEM
|
|
#endif
|
|
|
|
typedef struct {
|
|
uint16_t bitmapOffset;
|
|
uint8_t width, height;
|
|
uint8_t xAdvance;
|
|
int8_t xOffset, yOffset;
|
|
} GFXglyph;
|
|
|
|
typedef struct {
|
|
const uint8_t *bitmap;
|
|
const GFXglyph *glyph;
|
|
uint8_t first, last;
|
|
uint8_t yAdvance;
|
|
} GFXfont;
|
|
|
|
typedef struct {
|
|
uint8_t* data;
|
|
uint8_t width;
|
|
uint8_t height;
|
|
} gfx_bitmap_t;
|
|
|
|
/**
|
|
* @brief Canvas struct for the gfx library
|
|
* Functions take the context and x,y coordinates of a pixel
|
|
*
|
|
* @param ctx any context that the draw/clear functions might need, ie display device
|
|
* @param draw_pixel_callback function that gets called to draw a pixel
|
|
* @param clear_pixel_callback function that gets called to clear a pixel
|
|
* @param flush_callback function that gets called to flush the buffer to the display, optional
|
|
* @param clear_disp_callback function to send the clear command to the display, optional
|
|
* @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);
|
|
void *ctx;
|
|
} gfx_canvas_t;
|
|
|
|
int16_t gfx_string_width(const GFXfont *f, const char *s);
|
|
int16_t gfx_draw_string_scaled(const gfx_canvas_t *canvas, const GFXfont* f, int16_t x, int16_t y, const char *s, bool inverted, uint8_t scale);
|
|
int16_t gfx_draw_string(const gfx_canvas_t *canvas, const GFXfont* f, int16_t x, int16_t y, const char *s, bool inverted);
|
|
int16_t gfx_draw_string_centered(const gfx_canvas_t *canvas, const GFXfont *f, int16_t centerpoint, int16_t y, const char *s, bool inverted);
|
|
void gfx_draw_line(const gfx_canvas_t *canvas, uint8_t start_x, uint8_t start_y, uint8_t end_x, uint8_t end_y, bool inverted);
|
|
void gfx_draw_box(const gfx_canvas_t *canvas, uint8_t pos_x, uint8_t pos_y, uint8_t size_x, uint8_t size_y, bool inverted);
|
|
void gfx_fill_box(const gfx_canvas_t *canvas, uint8_t pos_x, uint8_t pos_y, uint8_t size_x, uint8_t size_y, bool inverted);
|
|
void gfx_draw_bitmap(const gfx_canvas_t *canvas, uint8_t pos_x, uint8_t pos_y, gfx_bitmap_t bmp, bool inverted);
|
|
void gfx_flush(const gfx_canvas_t *canvas);
|
|
void gfx_clear_disp(const gfx_canvas_t *canvas);
|
|
void gfx_clear_fb(const gfx_canvas_t *canvas); |