Sat, 20 Oct 2018 13:23:15 +0200
Initial checkin brewboard
0 | 1 | /** |
2 | * @file tft.h | |
3 | * @brief High level TFT functions | |
4 | * @author LoBo 04/2017 | |
5 | * @see https://github.com/loboris | |
6 | */ | |
7 | ||
8 | #ifndef _TFT_H_ | |
9 | #define _TFT_H_ | |
10 | ||
11 | #include <stdlib.h> | |
12 | #include "tftspi.h" | |
13 | ||
14 | typedef struct { | |
15 | uint16_t x1; | |
16 | uint16_t y1; | |
17 | uint16_t x2; | |
18 | uint16_t y2; | |
19 | } dispWin_t; | |
20 | ||
21 | typedef struct { | |
22 | uint8_t *font; | |
23 | uint8_t x_size; | |
24 | uint8_t y_size; | |
25 | uint8_t offset; | |
26 | uint16_t numchars; | |
27 | uint16_t size; | |
28 | uint8_t max_x_size; | |
29 | uint8_t bitmap; | |
30 | color_t color; | |
31 | } Font; | |
32 | ||
33 | ||
34 | //========================================================================================== | |
35 | // ==== Global variables =================================================================== | |
36 | //========================================================================================== | |
37 | extern uint8_t orientation; ///< current screen orientation | |
38 | extern uint16_t font_rotate; ///< current font font_rotate angle (0~395) | |
39 | extern uint8_t font_transparent; ///< if not 0 draw fonts transparent | |
40 | extern uint8_t font_forceFixed; ///< if not zero force drawing proportional fonts with fixed width | |
41 | extern uint8_t font_buffered_char; | |
42 | extern uint8_t font_line_space; ///< additional spacing between text lines; added to font height | |
43 | extern uint8_t text_wrap; ///< if not 0 wrap long text to the new line, else clip | |
44 | extern color_t _fg; ///< current foreground color for fonts | |
45 | extern color_t _bg; ///< current background for non transparent fonts | |
46 | extern dispWin_t dispWin; ///< display clip window | |
47 | extern float _angleOffset; ///< angle offset for arc, polygon and line by angle functions | |
48 | extern uint8_t image_debug; ///< print debug messages during image decode if set to 1 | |
49 | ||
50 | extern Font cfont; ///< Current font structure | |
51 | ||
52 | extern int TFT_X; ///< X position of the next character after TFT_print() function | |
53 | extern int TFT_Y; ///< Y position of the next character after TFT_print() function | |
54 | ||
55 | // ========================================================================================= | |
56 | ||
57 | ||
58 | // Buffer is created during jpeg decode for sending data | |
59 | // Total size of the buffer is 2 * (JPG_IMAGE_LINE_BUF_SIZE * 3) | |
60 | // The size must be multiple of 256 bytes !! | |
61 | #define JPG_IMAGE_LINE_BUF_SIZE 512 | |
62 | ||
63 | // --- Constants for ellipse function --- | |
64 | #define TFT_ELLIPSE_UPPER_RIGHT 0x01 | |
65 | #define TFT_ELLIPSE_UPPER_LEFT 0x02 | |
66 | #define TFT_ELLIPSE_LOWER_LEFT 0x04 | |
67 | #define TFT_ELLIPSE_LOWER_RIGHT 0x08 | |
68 | ||
69 | // Constants for Arc function | |
70 | // number representing the maximum angle (e.g. if 100, then if you pass in start=0 and end=50, you get a half circle) | |
71 | // this can be changed with setArcParams function at runtime | |
72 | #define DEFAULT_ARC_ANGLE_MAX 360 | |
73 | // rotational offset in degrees defining position of value 0 (-90 will put it at the top of circle) | |
74 | // this can be changed with setAngleOffset function at runtime | |
75 | #define DEFAULT_ANGLE_OFFSET -90 | |
76 | ||
77 | #define PI 3.14159265359 | |
78 | ||
79 | #define MIN_POLIGON_SIDES 3 | |
80 | #define MAX_POLIGON_SIDES 60 | |
81 | ||
82 | // === Color names constants === | |
83 | extern const color_t TFT_BLACK; | |
84 | extern const color_t TFT_NAVY; | |
85 | extern const color_t TFT_DARKGREEN; | |
86 | extern const color_t TFT_DARKCYAN; | |
87 | extern const color_t TFT_MAROON; | |
88 | extern const color_t TFT_PURPLE; | |
89 | extern const color_t TFT_OLIVE; | |
90 | extern const color_t TFT_LIGHTGREY; | |
91 | extern const color_t TFT_DARKGREY; | |
92 | extern const color_t TFT_BLUE; | |
93 | extern const color_t TFT_GREEN; | |
94 | extern const color_t TFT_CYAN; | |
95 | extern const color_t TFT_RED; | |
96 | extern const color_t TFT_MAGENTA; | |
97 | extern const color_t TFT_YELLOW; | |
98 | extern const color_t TFT_WHITE; | |
99 | extern const color_t TFT_ORANGE; | |
100 | extern const color_t TFT_GREENYELLOW; | |
101 | extern const color_t TFT_PINK; | |
102 | ||
103 | // === Color invert constants === | |
104 | #define INVERT_ON 1 | |
105 | #define INVERT_OFF 0 | |
106 | ||
107 | // === Special coordinates constants === | |
108 | #define CENTER -9003 | |
109 | #define RIGHT -9004 | |
110 | #define BOTTOM -9004 | |
111 | ||
112 | #define LASTX 7000 | |
113 | #define LASTY 8000 | |
114 | ||
115 | // === Embedded fonts constants === | |
116 | #define DEFAULT_FONT 0 ///< 12 points 95 characters DejaVu font. | |
117 | #define DEJAVU18_FONT 1 ///< 18 points 95 characters DejaVuSans font. | |
118 | #define DEJAVU24_FONT 2 ///< 24 points 95 characters DejaVu font. | |
119 | #define UBUNTU16_FONT 3 ///< 16 points 95 characters Ubuntu font. | |
120 | #define COMIC24_FONT 4 ///< 24 points 95 characters Comic font. | |
121 | #define MINYA24_FONT 5 ///< 24 points 95 characters Minya font. | |
122 | #define TOONEY32_FONT 6 ///< 32 points 95 characters Tooney font. | |
123 | #define SMALL_FONT 7 ///< 8x12 pixels 95 characters fixed font. | |
124 | #define DEF_SMALL_FONT 8 ///< 9 points 95 characters font. | |
125 | #define FONT_7SEG 9 ///< Variable size 14 characters 7 segment font. | |
126 | #define USER_FONT 10 ///< font will be read from file | |
127 | ||
128 | ||
129 | ||
130 | // ===== PUBLIC FUNCTIONS ========================================================================= | |
131 | ||
132 | ||
133 | /** | |
134 | * @brief Draw pixel at given x,y coordinates | |
135 | * @param x horizontal position | |
136 | * @param y vertical position | |
137 | * @param color pixel color | |
138 | * @param sel if not 0 activate CS before and deactivat after sending pixel data to display | |
139 | * when sending multiple pixels it is faster to activate the CS first, | |
140 | * send all pixels an deactivate CS after all pixela was sent | |
141 | */ | |
142 | void TFT_drawPixel(int16_t x, int16_t y, color_t color, uint8_t sel); | |
143 | ||
144 | /** | |
145 | * @brief Read pixel color value from display GRAM at given x,y coordinates | |
146 | * @param[in] x horizontal position | |
147 | * @param[in] y vertical position | |
148 | */ | |
149 | color_t TFT_readPixel(int16_t x, int16_t y); | |
150 | ||
151 | /** | |
152 | * @brief Draw vertical line at given x,y coordinates | |
153 | * | |
154 | * @param x horizontal start position | |
155 | * @param y vertical start position | |
156 | * @param h line height in pixels | |
157 | * @param color line color | |
158 | */ | |
159 | void TFT_drawFastVLine(int16_t x, int16_t y, int16_t h, color_t color); | |
160 | ||
161 | /** | |
162 | * @brief Draw horizontal line at given x,y coordinates | |
163 | * | |
164 | * @param x horizontal start position | |
165 | * @param y vertical start position | |
166 | * @param w line width in pixels | |
167 | * @param color line color | |
168 | */ | |
169 | void TFT_drawFastHLine(int16_t x, int16_t y, int16_t w, color_t color); | |
170 | ||
171 | /** | |
172 | * @brief Draw line on screen | |
173 | * | |
174 | * @param x0 horizontal start position | |
175 | * @param y0 vertical start position | |
176 | * @param x1 horizontal end position | |
177 | * @param y1 vertical end position | |
178 | * @param color line color | |
179 | */ | |
180 | void TFT_drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, color_t color); | |
181 | ||
182 | ||
183 | /** | |
184 | * @brief Draw line on screen from (x,y) point at given angle | |
185 | * Line drawing angle starts at lower right quadrant of the screen and is offseted by | |
186 | * '_angleOffset' global variable (default: -90 degrees) | |
187 | * | |
188 | * @param x horizontal start position | |
189 | * @param y vertical start position | |
190 | * @param start start offset from (x,y) | |
191 | * @param len length of the line | |
192 | * @param angle line angle in degrees | |
193 | * @param color line color | |
194 | */ | |
195 | void TFT_drawLineByAngle(uint16_t x, uint16_t y, uint16_t start, uint16_t len, uint16_t angle, color_t color); | |
196 | ||
197 | /** | |
198 | * @brief Fill given rectangular screen region with color | |
199 | * | |
200 | * @param x horizontal rect start position | |
201 | * @param y vertical rect start position | |
202 | * @param w rectangle width | |
203 | * @param h rectangle height | |
204 | * @param color fill color | |
205 | */ | |
206 | void TFT_fillRect(int16_t x, int16_t y, int16_t w, int16_t h, color_t color); | |
207 | ||
208 | /** | |
209 | * @brief Draw rectangle on screen | |
210 | * | |
211 | * @param x horizontal rect start position | |
212 | * @param y vertical rect start position | |
213 | * @param w rectangle width | |
214 | * @param h rectangle height | |
215 | * @param color rect line color | |
216 | */ | |
217 | void TFT_drawRect(uint16_t x1,uint16_t y1,uint16_t w,uint16_t h, color_t color); | |
218 | ||
219 | /** | |
220 | * @brief Draw rectangle with rounded corners on screen | |
221 | * | |
222 | * @param x horizontal rect start position | |
223 | * @param y vertical rect start position | |
224 | * @param w rectangle width | |
225 | * @param h rectangle height | |
226 | * @param r corner radius | |
227 | * @param color rectangle color | |
228 | */ | |
229 | void TFT_drawRoundRect(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t r, color_t color); | |
230 | ||
231 | /** | |
232 | * @brief Fill given rectangular screen region with rounded corners with color | |
233 | * | |
234 | * @param x horizontal rect start position | |
235 | * @param y vertical rect start position | |
236 | * @param w rectangle width | |
237 | * @param h rectangle height | |
238 | * @param r corner radius | |
239 | * @param color fill color | |
240 | */ | |
241 | void TFT_fillRoundRect(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t r, color_t color); | |
242 | ||
243 | /** | |
244 | * @brief Fill the whole screen with color | |
245 | * | |
246 | * @param color fill color | |
247 | */ | |
248 | void TFT_fillScreen(color_t color); | |
249 | ||
250 | /** | |
251 | * @brief Fill the current clip window with color | |
252 | * | |
253 | * @param color fill color | |
254 | */ | |
255 | void TFT_fillWindow(color_t color); | |
256 | ||
257 | /** | |
258 | * @brief Draw triangle on screen | |
259 | * | |
260 | * @param x0 first triangle point x position | |
261 | * @param y0 first triangle point y position | |
262 | * @param x0 second triangle point x position | |
263 | * @param y0 second triangle point y position | |
264 | * @param x0 third triangle point x position | |
265 | * @param y0 third triangle point y position | |
266 | * @param color triangle color | |
267 | */ | |
268 | void TFT_drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color); | |
269 | ||
270 | /** | |
271 | * @brief Fill triangular screen region with color | |
272 | * | |
273 | * @param x0 first triangle point x position | |
274 | * @param y0 first triangle point y position | |
275 | * @param x0 second triangle point x position | |
276 | * @param y0 second triangle point y position | |
277 | * @param x0 third triangle point x position | |
278 | * @param y0 third triangle point y position | |
279 | * @param color fill color | |
280 | */ | |
281 | void TFT_fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, color_t color); | |
282 | ||
283 | /** | |
284 | * @brief Draw circle on screen | |
285 | * | |
286 | * @param x circle center x position | |
287 | * @param y circle center x position | |
288 | * @param r circle radius | |
289 | * @param color circle color | |
290 | */ | |
291 | void TFT_drawCircle(int16_t x, int16_t y, int radius, color_t color); | |
292 | ||
293 | /** | |
294 | * @brief Fill circle on screen with color | |
295 | * | |
296 | * @param x circle center x position | |
297 | * @param y circle center x position | |
298 | * @param r circle radius | |
299 | * @param color circle fill color | |
300 | */ | |
301 | void TFT_fillCircle(int16_t x, int16_t y, int radius, color_t color); | |
302 | ||
303 | /** | |
304 | * @brief Draw ellipse on screen | |
305 | * | |
306 | * @param x0 ellipse center x position | |
307 | * @param y0 ellipse center x position | |
308 | * @param rx ellipse horizontal radius | |
309 | * @param ry ellipse vertical radius | |
310 | * @param option drawing options, multiple options can be combined | |
311 | * | |
312 | * 1 (TFT_ELLIPSE_UPPER_RIGHT) draw upper right corner | |
313 | * 2 (TFT_ELLIPSE_UPPER_LEFT) draw upper left corner | |
314 | * 4 (TFT_ELLIPSE_LOWER_LEFT) draw lower left corner | |
315 | * 8 (TFT_ELLIPSE_LOWER_RIGHT) draw lower right corner | |
316 | * to draw the whole ellipse use option value 15 (1 | 2 | 4 | 8) | |
317 | * @param color: circle color | |
318 | */ | |
319 | void TFT_drawEllipse(uint16_t x0, uint16_t y0, uint16_t rx, uint16_t ry, color_t color, uint8_t option); | |
320 | ||
321 | /** | |
322 | * @brief Fill elliptical region on screen | |
323 | * | |
324 | * @param x0 ellipse center x position | |
325 | * @param y0 ellipse center x position | |
326 | * @param rx ellipse horizontal radius | |
327 | * @param ry ellipse vertical radius | |
328 | * @param option drawing options, multiple options can be combined | |
329 | * | |
330 | * 1 (TFT_ELLIPSE_UPPER_RIGHT) fill upper right corner | |
331 | * 2 (TFT_ELLIPSE_UPPER_LEFT) fill upper left corner | |
332 | * 4 (TFT_ELLIPSE_LOWER_LEFT) fill lower left corner | |
333 | * 8 (TFT_ELLIPSE_LOWER_RIGHT) fill lower right corner | |
334 | * to fill the whole ellipse use option value 15 (1 | 2 | 4 | 8) | |
335 | * @param color fill color | |
336 | */ | |
337 | void TFT_fillEllipse(uint16_t x0, uint16_t y0, uint16_t rx, uint16_t ry, color_t color, uint8_t option); | |
338 | ||
339 | ||
340 | /** | |
341 | * @brief Draw circle arc on screen | |
342 | * Arc drawing angle starts at lower right quadrant of the screen and is offseted by | |
343 | * '_angleOffset' global variable (default: -90 degrees) | |
344 | * | |
345 | * @param cx arc center X position | |
346 | * @param cy arc center Y position | |
347 | * @param th thickness of the drawn arc | |
348 | * @param ry arc vertical radius | |
349 | * @param start arc start angle in degrees | |
350 | * @param end arc end angle in degrees | |
351 | * @param color arc outline color | |
352 | * @param fillcolor arc fill color | |
353 | */ | |
354 | void TFT_drawArc(uint16_t cx, uint16_t cy, uint16_t r, uint16_t th, float start, float end, color_t color, color_t fillcolor); | |
355 | ||
356 | /** | |
357 | * @brief Draw polygon on screen | |
358 | * | |
359 | * @param cx polygon center X position | |
360 | * @param cy arc center Y position | |
361 | * @param sides number of polygon sides; MAX_POLIGON_SIDES ~ MAX_POLIGON_SIDES (3 ~ 60) | |
362 | * @param diameter diameter of the circle inside which the polygon is drawn | |
363 | * @param color polygon outline color | |
364 | * @param fill polygon fill color; if same as color, polygon is not filled | |
365 | * @param deg polygon rotation angle; 0 ~ 360 | |
366 | * @param th thickness of the polygon outline | |
367 | */ | |
368 | void TFT_drawPolygon(int cx, int cy, int sides, int diameter, color_t color, color_t fill, int deg, uint8_t th); | |
369 | ||
370 | /** | |
371 | * @brief Set the font used for writing the text to display. | |
372 | * | |
373 | * ------------------------------------------------------------------------------------ | |
374 | * For 7 segment font only characters 0,1,2,3,4,5,6,7,8,9, . , - , : , / are available. | |
375 | * Character ‘/‘ draws the degree sign. | |
376 | * ------------------------------------------------------------------------------------ | |
377 | * | |
378 | * @param font font number; use defined font names | |
379 | * @param font_file pointer to font file name; NULL for embeded fonts | |
380 | */ | |
381 | void TFT_setFont(uint8_t font, const char *font_file); | |
382 | ||
383 | /** | |
384 | * @brief Returns current font height & width in pixels. | |
385 | * | |
386 | * @param[in] width pointer to returned font width | |
387 | * @param[in] height pointer to returned font height | |
388 | */ | |
389 | int TFT_getfontsize(int *width, int* height); | |
390 | ||
391 | /** | |
392 | * @brief Returns current font height in pixels. | |
393 | * @return The font height in pixels. | |
394 | */ | |
395 | int TFT_getfontheight(); | |
396 | ||
397 | /** | |
398 | * @brief Write text to display. | |
399 | * | |
400 | * Rotation of the displayed text depends on 'font_rotate' variable (0~360) | |
401 | * if 'font_transparent' variable is set to 1, no background pixels will be printed | |
402 | * | |
403 | * If the text does not fit the screen width it will be clipped (if text_wrap=0), | |
404 | * or continued on next line (if text_wrap=1) | |
405 | * | |
406 | * Two special characters are allowed in strings: | |
407 | * | |
408 | * ‘\r’ CR (0x0D), clears the display to EOL | |
409 | * ‘\n’ LF (ox0A), continues to the new line, x=0 | |
410 | * | |
411 | * @param st pointer to null terminated string to be printed | |
412 | * @param x horizontal position of the upper left point in pixels. Special values can be entered: | |
413 | * | |
414 | * CENTER, centers the text | |
415 | * RIGHT, right justifies the text | |
416 | * LASTX, continues from last X position; offset can be used: LASTX+n | |
417 | * | |
418 | * @param y vertical position of the upper left point in pixels. Special values can be entered: | |
419 | * | |
420 | * CENTER, centers the text | |
421 | * BOTTOM, bottom justifies the text | |
422 | * LASTY, continues from last Y position; offset can be used: LASTY+n | |
423 | * | |
424 | */ | |
425 | void TFT_print(char *st, int x, int y); | |
426 | ||
427 | /** | |
428 | * @brief Set atributes for 7 segment vector font | |
429 | * @note 7 segment font must be the current font to this function to have effect | |
430 | * | |
431 | * @param l 6~40; distance between bars in pixels | |
432 | * @param w 1~12, max l/2; bar width in pixels | |
433 | * @param outline draw font outline if set to 1 | |
434 | * @param color font outline color, only used if outline=1 | |
435 | */ | |
436 | void set_7seg_font_atrib(uint8_t l, uint8_t w, int outline, color_t color); | |
437 | ||
438 | /** | |
439 | * @brief Sets the clipping area coordinates. | |
440 | * All writing to screen is clipped to that area. | |
441 | * Starting x & y in all functions will be adjusted to the clipping area. | |
442 | * | |
443 | * @param x1,y1 upper left point of the clipping area | |
444 | * @param x2,y2 bottom right point of the clipping area | |
445 | */ | |
446 | void TFT_setclipwin(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); | |
447 | ||
448 | /** | |
449 | * @brief Resets the clipping area to full screen (0,0),(_wodth,_height) | |
450 | */ | |
451 | void TFT_resetclipwin(); | |
452 | ||
453 | /** | |
454 | * @brief Save current clipping area to temporary variable | |
455 | */ | |
456 | void TFT_saveClipWin(); | |
457 | ||
458 | /** | |
459 | * @brief Restore current clipping area from temporary variable | |
460 | */ | |
461 | void TFT_restoreClipWin(); | |
462 | ||
463 | /** | |
464 | * @brief Set the screen rotation | |
465 | * Also resets the clip window and clears the screen with current background color | |
466 | * | |
467 | * @param rot 0~3; screen rotation; use defined rotation constants: | |
468 | * PORTRAIT, LANDSCAPE, PORTRAIT_FLIP, LANDSCAPE_FLIP | |
469 | */ | |
470 | void TFT_setRotation(uint8_t rot); | |
471 | ||
472 | /** | |
473 | * @brief Set inverted/normal colors | |
474 | * | |
475 | * @param mode 0 or 1; use defined constants: INVERT_ON or INVERT_OFF | |
476 | */ | |
477 | void TFT_invertDisplay(const uint8_t mode); | |
478 | ||
479 | /** | |
480 | * @brief Select gamma curve | |
481 | * @param gm gama curve, values 0~3 | |
482 | */ | |
483 | void TFT_setGammaCurve(uint8_t gm); | |
484 | ||
485 | /** | |
486 | * @brief Compare two color structures | |
487 | * @return 0 if equal, 1 if not equal | |
488 | * | |
489 | * @param c1, c2 colors to be compared | |
490 | */ | |
491 | int TFT_compare_colors(color_t c1, color_t c2); | |
492 | ||
493 | /** | |
494 | * @brief returns the string width in pixels. Useful for positions strings on the screen. | |
495 | * @return The string width. | |
496 | */ | |
497 | int TFT_getStringWidth(char* str); | |
498 | ||
499 | ||
500 | /** | |
501 | * @brief Fills the rectangle occupied by string with current background color | |
502 | * @param x X position | |
503 | * @param Y Y position | |
504 | * @param str The string | |
505 | */ | |
506 | void TFT_clearStringRect(int x, int y, char *str); | |
507 | ||
508 | /** | |
509 | * @brief Converts the components of a color, as specified by the HSB model, | |
510 | * to an equivalent set of values for the default RGB model. | |
511 | * | |
512 | * The color structure that is returned by HSBtoRGB encodes the value of a color as R, G & B component | |
513 | * | |
514 | * @param _hue any number, the floor of this number is subtracted from it to create a fraction between 0 and 1. | |
515 | * This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model. | |
516 | * @param _sat 0 ~ 1.0 | |
517 | * @param _brightness 0 ~ 1.0 | |
518 | */ | |
519 | color_t HSBtoRGB(float _hue, float _sat, float _brightness); | |
520 | ||
521 | /** | |
522 | * @brief Decodes and displays JPG image | |
523 | * Limits: | |
524 | * Baseline only. Progressive and Lossless JPEG format are not supported. | |
525 | * Image size: Up to 65520 x 65520 pixels | |
526 | * Color space: YCbCr three components only. Gray scale image is not supported. | |
527 | * Sampling factor: 4:4:4, 4:2:2 or 4:2:0. | |
528 | * | |
529 | * @param x image left position; constants CENTER & RIGHT can be used; negative value is accepted | |
530 | * @param y image top position; constants CENTER & BOTTOM can be used; negative value is accepted | |
531 | * @param scale image scale factor: 0~3; if scale>0, image is scaled by factor 1/(2^scale) (1/2, 1/4 or 1/8) | |
532 | * @param fname pointer to the name of the file from which the image will be read | |
533 | * if set to NULL, image will be read from memory buffer pointed to by 'buf' | |
534 | * @param buf pointer to the memory buffer from which the image will be read; used if fname=NULL | |
535 | * @param size size of the memory buffer from which the image will be read; used if fname=NULL & buf!=NULL | |
536 | */ | |
537 | void TFT_jpg_image(int x, int y, uint8_t scale, char *fname, uint8_t *buf, int size); | |
538 | ||
539 | /** | |
540 | * @brief Decodes and displays BMP image | |
541 | * Only uncompressed RGB 24-bit with no color space information BMP images can be displayed | |
542 | * | |
543 | * @param x image left position; constants CENTER & RIGHT can be used; negative value is accepted | |
544 | * @param y image top position; constants CENTER & BOTTOM can be used; negative value is accepted | |
545 | * @param scale image scale factor: 0~7; if scale>0, image is scaled by factor 1/(scale+1) | |
546 | * @param fname pointer to the name of the file from which the image will be read | |
547 | * if set to NULL, image will be read from memory buffer pointed to by 'imgbuf' | |
548 | * @param imgbuf pointer to the memory buffer from which the image will be read; used if fname=NULL | |
549 | * @param size size of the memory buffer from which the image will be read; used if fname=NULL & imgbuf!=NULL | |
550 | */ | |
551 | int TFT_bmp_image(int x, int y, uint8_t scale, char *fname, uint8_t *imgbuf, int size); | |
552 | ||
553 | /** | |
554 | * @brief Get the touch panel coordinates. | |
555 | * The coordinates are adjusted to screen orientation if raw=0 | |
556 | * | |
557 | * @param[in] x pointer to X coordinate | |
558 | * @param[in] y pointer to Y coordinate | |
559 | * @param raw if 0 returns calibrated screen coordinates; if 1 returns raw touch controller coordinates | |
560 | * @return 0 if touch panel is not touched; x=y=0 | |
561 | * 1 if touch panel is touched; x&y are the valid coordinates | |
562 | */ | |
563 | int TFT_read_touch(int *x, int* y, uint8_t raw); | |
564 | ||
565 | ||
566 | /** | |
567 | * @brief Compile font c source file to .fnt file | |
568 | * which can be used in TFT_setFont() function to select external font | |
569 | * Created file have the same name as source file and extension .fnt | |
570 | * | |
571 | * @param fontfile pointer to c source font file name; must have .c extension | |
572 | * @param dbg if set to 1, prints debug information | |
573 | * | |
574 | * @return 0 on success, err no on error | |
575 | */ | |
576 | int compile_font_file(char *fontfile, uint8_t dbg); | |
577 | ||
578 | /** | |
579 | * @brief Get all font's characters to buffer | |
580 | */ | |
581 | void getFontCharacters(uint8_t *buf); | |
582 | ||
583 | #endif |