components/tft/tft.h

changeset 20
3fd5e0fc075f
parent 18
5d4a40fe9967
child 29
45647136ec95
equal deleted inserted replaced
19:49e2960d4642 20:3fd5e0fc075f
1 /** 1 /**
2 * @file tft.h 2 * @file tft.h
3 * @brief High level TFT functions 3 * @brief High level TFT functions
4 * @author LoBo 04/2017 4 * @author LoBo 04/2017
5 * @see https://github.com/loboris 5 * @see https://github.com/loboris
6 * @author M. Broek - removed unused code for this app.
6 */ 7 */
7 8
8 #ifndef _TFT_H_ 9 #ifndef _TFT_H_
9 #define _TFT_H_ 10 #define _TFT_H_
10 11
177 * @param y1 vertical end position 178 * @param y1 vertical end position
178 * @param color line color 179 * @param color line color
179 */ 180 */
180 void TFT_drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, color_t color); 181 void TFT_drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, color_t color);
181 182
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 /** 183 /**
198 * @brief Fill given rectangular screen region with color 184 * @brief Fill given rectangular screen region with color
199 * 185 *
200 * @param x horizontal rect start position 186 * @param x horizontal rect start position
201 * @param y vertical rect start position 187 * @param y vertical rect start position
253 * @param color fill color 239 * @param color fill color
254 */ 240 */
255 void TFT_fillWindow(color_t color); 241 void TFT_fillWindow(color_t color);
256 242
257 /** 243 /**
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 244 * @brief Draw circle on screen
285 * 245 *
286 * @param x circle center x position 246 * @param x circle center x position
287 * @param y circle center x position 247 * @param y circle center x position
288 * @param r circle radius 248 * @param r circle radius
299 * @param color circle fill color 259 * @param color circle fill color
300 */ 260 */
301 void TFT_fillCircle(int16_t x, int16_t y, int radius, color_t color); 261 void TFT_fillCircle(int16_t x, int16_t y, int radius, color_t color);
302 262
303 /** 263 /**
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. 264 * @brief Set the font used for writing the text to display.
372 * 265 *
373 * ------------------------------------------------------------------------------------ 266 * ------------------------------------------------------------------------------------
374 * For 7 segment font only characters 0,1,2,3,4,5,6,7,8,9, . , - , : , / are available. 267 * For 7 segment font only characters 0,1,2,3,4,5,6,7,8,9, . , - , : , / are available.
375 * Character ‘/‘ draws the degree sign. 268 * Character ‘/‘ draws the degree sign.
468 * PORTRAIT, LANDSCAPE, PORTRAIT_FLIP, LANDSCAPE_FLIP 361 * PORTRAIT, LANDSCAPE, PORTRAIT_FLIP, LANDSCAPE_FLIP
469 */ 362 */
470 void TFT_setRotation(uint8_t rot); 363 void TFT_setRotation(uint8_t rot);
471 364
472 /** 365 /**
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 366 * @brief Select gamma curve
481 * @param gm gama curve, values 0~3 367 * @param gm gama curve, values 0~3
482 */ 368 */
483 void TFT_setGammaCurve(uint8_t gm); 369 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 370
493 /** 371 /**
494 * @brief returns the string width in pixels. Useful for positions strings on the screen. 372 * @brief returns the string width in pixels. Useful for positions strings on the screen.
495 * @return The string width. 373 * @return The string width.
496 */ 374 */
502 * @param x X position 380 * @param x X position
503 * @param Y Y position 381 * @param Y Y position
504 * @param str The string 382 * @param str The string
505 */ 383 */
506 void TFT_clearStringRect(int x, int y, char *str); 384 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 385
521 /** 386 /**
522 * @brief Get the touch panel coordinates. 387 * @brief Get the touch panel coordinates.
523 * The coordinates are adjusted to screen orientation if raw=0 388 * The coordinates are adjusted to screen orientation if raw=0
524 * 389 *
528 * @return 0 if touch panel is not touched; x=y=0 393 * @return 0 if touch panel is not touched; x=y=0
529 * 1 if touch panel is touched; x&y are the valid coordinates 394 * 1 if touch panel is touched; x&y are the valid coordinates
530 */ 395 */
531 int TFT_read_touch(int *x, int* y, uint8_t raw); 396 int TFT_read_touch(int *x, int* y, uint8_t raw);
532 397
533
534 /**
535 * @brief Compile font c source file to .fnt file
536 * which can be used in TFT_setFont() function to select external font
537 * Created file have the same name as source file and extension .fnt
538 *
539 * @param fontfile pointer to c source font file name; must have .c extension
540 * @param dbg if set to 1, prints debug information
541 *
542 * @return 0 on success, err no on error
543 */
544 int compile_font_file(char *fontfile, uint8_t dbg);
545
546 /**
547 * @brief Get all font's characters to buffer
548 */
549 void getFontCharacters(uint8_t *buf);
550
551 #endif 398 #endif

mercurial