Hanna
Sourcecode Batteriemanagementsystem
gfx_text.h
gehe zur Dokumentation dieser Datei
1 
43 /*
44  * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
45  */
46 #ifndef GFX_TEXT_H_INCLUDED
47 #define GFX_TEXT_H_INCLUDED
48 
49 
50 #include <stdint.h>
51 
52 
53 #include "compiler.h"
54 #ifdef CONFIG_HAVE_HUGEMEM
55 # include "hugemem.h"
56 #endif
57 
58 
66 #ifdef CONFIG_HAVE_HUGEMEM
67 
68  FONT_LOC_HUGEMEM,
69 #endif
70 };
71 
79  TEXT_ALIGN_CENTER,
80 };
81 
85  TEXT_POS_TOP = (1 << 0),
87  TEXT_POS_CENTER_Y = (1 << 1),
89  TEXT_POS_BOTTOM = (1 << 2),
91  TEXT_POS_LEFT = (1 << 3),
93  TEXT_POS_CENTER_X = (1 << 4),
95  TEXT_POS_RIGHT = (1 << 5),
96 
97  TEXT_POS_TOP_LEFT = TEXT_POS_TOP | TEXT_POS_LEFT,
98  TEXT_POS_TOP_CENTER = TEXT_POS_TOP | TEXT_POS_CENTER_X,
99  TEXT_POS_TOP_RIGHT = TEXT_POS_TOP | TEXT_POS_RIGHT,
100  TEXT_POS_CENTER_LEFT = TEXT_POS_CENTER_Y | TEXT_POS_LEFT,
101  TEXT_POS_CENTER = TEXT_POS_CENTER_Y | TEXT_POS_CENTER_X,
102  TEXT_POS_CENTER_RIGHT = TEXT_POS_CENTER_Y | TEXT_POS_RIGHT,
103  TEXT_POS_BOTTOM_LEFT = TEXT_POS_BOTTOM | TEXT_POS_LEFT,
104  TEXT_POS_BOTTOM_CENTER = TEXT_POS_BOTTOM | TEXT_POS_CENTER_X,
105  TEXT_POS_BOTTOM_RIGHT = TEXT_POS_BOTTOM | TEXT_POS_RIGHT,
106 };
107 
109 struct font {
112  union {
118 #ifdef CONFIG_HAVE_HUGEMEM
119  hugemem_ptr_t hugemem;
120 #endif
121  uint8_t PROGMEM_PTR_T progmem;
122  } data;
123 
125  uint8_t width;
127  uint8_t height;
129  uint8_t first_char;
131  uint8_t last_char;
132 };
133 
136 void gfx_draw_char(const char c, const gfx_coord_t x, const gfx_coord_t y,
137  const struct font *font, const gfx_color_t bg_color,
138  const gfx_color_t text_color);
139 
140 void gfx_draw_string(const char *str, const gfx_coord_t x,
141  const gfx_coord_t y, const struct font *font,
142  const gfx_color_t bg_color, const gfx_color_t text_color);
143 
144 void gfx_draw_string_aligned(const char *str, gfx_coord_t x, gfx_coord_t y,
145  const struct font *font, const gfx_color_t bg_color,
146  const gfx_color_t text_color, enum gfx_text_position text_pos,
147  enum gfx_text_alignment text_align);
148 
149 void gfx_get_string_bounding_box(char const *str, const struct font *font,
156 void gfx_draw_progmem_string(char PROGMEM_PTR_T str, gfx_coord_t x,
157  gfx_coord_t y, const struct font *font,
158  const gfx_color_t bg_color, const gfx_color_t text_color);
159 
160 void gfx_draw_progmem_string_aligned(char PROGMEM_PTR_T str,
161  gfx_coord_t x, gfx_coord_t y, const struct font *font,
162  const gfx_color_t bg_color, const gfx_color_t text_color,
163  enum gfx_text_position text_pos, enum gfx_text_alignment text_align);
164 
165 void gfx_get_progmem_string_bounding_box(char PROGMEM_PTR_T str,
166  const struct font *font, gfx_coord_t *width,
171 #endif /* GFX_TEXT_H_INCLUDED */
uint8_t height
Definition: gfx_text.h:127
Commonly used includes, types and macros.
void gfx_get_string_bounding_box(const char *str, const struct font *font, gfx_coord_t *width, gfx_coord_t *height)
Computes the bounding box of a string.
Definition: gfx_text.c:519
uint8_t last_char
Definition: gfx_text.h:131
Definition: gfx_text.h:109
void gfx_draw_progmem_string_aligned(char PROGMEM_PTR_T str, gfx_coord_t x, gfx_coord_t y, const struct font *font, const gfx_color_t bg_color, const gfx_color_t text_color, enum gfx_text_position text_pos, enum gfx_text_alignment text_align)
Draws an aligned string located in program memory to the display.
Definition: gfx_text.c:414
void gfx_get_progmem_string_bounding_box(char PROGMEM_PTR_T str, const struct font *font, gfx_coord_t *width, gfx_coord_t *height)
Computes the bounding box of a string located in program memory.
Definition: gfx_text.c:565
enum font_data_type type
Definition: gfx_text.h:111
uint8_t first_char
Definition: gfx_text.h:129
void gfx_draw_string_aligned(const char *str, gfx_coord_t x, gfx_coord_t y, const struct font *font, const gfx_color_t bg_color, const gfx_color_t text_color, enum gfx_text_position text_pos, enum gfx_text_alignment text_align)
Draws an aligned string to the display.
Definition: gfx_text.c:295
font_data_type
Valid storage locations for font data.
Definition: gfx_text.h:63
ili9341_coord_t gfx_coord_t
Data type representing a coordinate on the screen.
Definition: gfx_ili9341.h:58
void gfx_draw_progmem_string(char PROGMEM_PTR_T str, gfx_coord_t x, gfx_coord_t y, const struct font *font, const gfx_color_t bg_color, const gfx_color_t text_color)
Draws a string located in program memory to the display.
Definition: gfx_text.c:389
void gfx_draw_char(const char c, const gfx_coord_t x, const gfx_coord_t y, const struct font *font, const gfx_color_t bg_color, const gfx_color_t text_color)
Draws a character to the display.
Definition: gfx_text.c:234
gfx_text_alignment
Definition: gfx_text.h:73
void gfx_draw_string(const char *str, const gfx_coord_t x, const gfx_coord_t y, const struct font *font, const gfx_color_t bg_color, const gfx_color_t text_color)
Draws a string to the display.
Definition: gfx_text.c:272
uint8_t width
Definition: gfx_text.h:125
ili9341_color_t gfx_color_t
Data type for color values native to the display.
Definition: gfx_ili9341.h:57
uint8_t PROGMEM_PTR_T progmem
Definition: gfx_text.h:121
gfx_text_position
Definition: gfx_text.h:83