/* epd.h - E-Paper Display library API */ #ifndef EPD_H_ #define EPD_H_ /* Includes */ #include "stddef.h" #include "stdint.h" #include "stdbool.h" #include "epd_font.h" #include "epd_fonts.h" /* Data Structures */ typedef struct epd_s epd_t; typedef enum epd_dir_e { EPD_DIR_L2R, EPD_DIR_T2B, EPD_DIR_R2L, EPD_DIR_B2T } epd_dir_t; typedef uint8_t epd_dbuf_t; typedef int (*epd_spi_write)(const uint8_t *, size_t, void *); typedef void (*epd_spi_cs)(bool, void *); typedef void (*epd_gpo_dc)(bool, void *); typedef void (*epd_gpo_rst)(bool, void *); typedef bool (*epd_gpi_busy)(void *); typedef void (*epd_sleep_ms)(uint32_t, void *); typedef struct epd_platform_config_s { epd_spi_write spi_write; epd_spi_cs spi_cs; epd_gpo_dc dc; epd_gpo_rst rst; epd_gpi_busy busy; epd_sleep_ms sleep_ms; void *udata; } epd_platform_config_t; typedef int32_t (*epd_write_dbuf)(epd_t *); typedef struct epd_display_config_s { uint32_t w; uint32_t h; epd_write_dbuf write; } epd_display_config_t; typedef uint16_t (*epd_char_cb)(epd_t *epd, uint8_t b); typedef struct epd_font_decode_s { const uint8_t *decode_ptr; /* pointer to the compressed data */ uint16_t target_x; uint16_t target_y; int8_t x; /* local coordinates, (0,0) is upper left */ int8_t y; int8_t glyph_width; int8_t glyph_height; uint8_t decode_bit_pos; /* bitpos inside a byte of the compressed data */ uint8_t is_transparent; uint8_t fg_color; uint8_t bg_color; #ifdef EPD_WITH_FONT_ROTATION uint8_t dir; /* direction */ #endif } epd_font_decode_t; typedef struct epd_font_data_s { epd_fontcfg_t cfg; uint8_t utf8_state; uint16_t encoding; uint8_t height_mode; int8_t ref_ascent; int8_t ref_descent; epd_font_decode_t decode; epd_char_cb char_cb; } epd_font_data_t; struct epd_s { epd_platform_config_t platform; epd_display_config_t display; epd_dbuf_t *dbuf; epd_font_t *font; epd_font_data_t fontdata; uint8_t draw_color; }; /* Function Prototypes */ void epd_init(epd_t *epd, epd_platform_config_t *cfg); void epd_display_init(epd_t *epd, epd_display_config_t *cfg); int8_t epd_dbuf_set(epd_t *epd, epd_dbuf_t *dbuf); int8_t epd_dbuf_clear(epd_t *epd); void epd_draw_line(epd_t *epd, uint16_t x, uint16_t y, uint16_t len, epd_dir_t dir); int32_t epd_update(epd_t *epd); #endif /* EPD_H_ */