-
Notifications
You must be signed in to change notification settings - Fork 2
/
u8g2_font_render.h
83 lines (60 loc) · 1.89 KB
/
u8g2_font_render.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* u8g2_font_render.h
*
* Created on: Nov 27, 2020
* Author: quard
*/
#ifndef INC_U8G2_FONT_RENDER_H_
#define INC_U8G2_FONT_RENDER_H_
#include "stm32f1xx_hal.h"
#include <stdlib.h>
#include <string.h>
#define U8G2_FONT_HEADER_SIZE 23
#define U8G2FontRender_OK 0x01
#define U8G2FontRender_ERR 0x02
#define pgm_read(adr) (*(const uint8_t *)(adr))
typedef void (*fnDrawPixel)(uint8_t x, uint8_t y);
typedef struct {
uint8_t number_of_glyphs : 8;
uint8_t bounding_box_mode : 8;
uint8_t zero_bit_width : 8;
uint8_t one_bit_width : 8;
uint8_t glyph_width : 8;
uint8_t glyph_height : 8;
uint8_t glyph_x_offset : 8;
uint8_t glyph_y_offset : 8;
uint8_t glyph_pitch : 8;
int8_t bounding_box_width : 8;
int8_t bounding_box_height : 8;
int8_t bounding_box_x_offset : 8;
int8_t bounding_box_y_offset : 8;
int8_t ascent_A : 8;
int8_t descent_g : 8;
int8_t ascent_parentheses : 8;
int8_t descent_parentheses : 8;
uint16_t offset_A : 16;
uint16_t offset_a : 16;
uint16_t offset_0x100 : 16;
} U8G2FontHeader_t;
typedef struct {
uint8_t character : 8;
uint8_t next_glypth : 8;
uint8_t width;
uint8_t height;
int8_t x_offset;
int8_t y_offset;
int8_t pitch;
uint8_t bit_pos;
const uint8_t *data;
} U8G2FontGlyph_t;
typedef struct {
U8G2FontHeader_t header;
const uint8_t *data;
fnDrawPixel drawFgPixel;
fnDrawPixel drawBgPixel;
} U8G2FontRender_t;
U8G2FontRender_t U8G2FontRender(const uint8_t *data, fnDrawPixel drawFgPixel, fnDrawPixel drawBgPixel);
U8G2FontHeader_t U8G2FontRender_ParseHeader(U8G2FontRender_t *font);
void U8G2FontRender_PrintChar(U8G2FontRender_t *font, uint8_t *x, uint8_t y, char chr);
void U8G2FontRender_Print(U8G2FontRender_t *font, uint8_t x, uint8_t y, char *str);
#endif /* INC_U8G2_FONT_RENDER_H_ */