|
| #define | RGB(r, g, b) ((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | (((b) & 0xF8) >> 3)) |
| |
| #define | RED RGB(255,0,0) |
| |
| #define | GREEN RGB(0,255,0) |
| |
| #define | BLUE RGB(0,0,255) |
| |
| #define | WHITE 0xF7BE |
| |
| #define | BLACK RGB(0,0,0) |
| |
| #define | HEX(h) (RGB(((h)>>16),((h)>>8),(h))) |
| |
| #define | TRANSPARENT ((uint16_t)0x80C2) |
| |
|
| bool | tft_init () |
| |
| void | tft_clear (uint16_t color) |
| |
| void | tft_draw_line (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) |
| |
| void | tft_draw_pixel (uint16_t x, uint16_t y, uint16_t color) |
| |
| void | tft_draw_rectangle (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) |
| |
| void | tft_fill_rectangle (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) |
| |
| void | tft_draw_bitmap_unscaled (uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *dat) |
| |
| bool | tft_draw_bitmap_file_unscaled (uint16_t x, uint16_t y, const char *filename) |
| |
| void | tft_draw_circle (uint16_t x, uint16_t y, uint16_t r, uint16_t color) |
| |
| uint8_t | tft_num_fonts () |
| |
| uint8_t | tft_font_height (uint8_t fontnum) |
| |
| uint8_t | tft_font_width (uint8_t fontnum) |
| |
| void | tft_print_line (uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *text) |
| |
| void | tft_print_formatted (uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *format,...) |
| |
The TFT Modul provides access to the display
| #define BLUE RGB(0,0,255) |
| #define GREEN RGB(0,255,0) |
| #define HEX |
( |
|
h | ) |
(RGB(((h)>>16),((h)>>8),(h))) |
Creates a 16bit color from a 24bit hex rgb color code
- Returns
| #define RGB |
( |
|
r, |
|
|
|
g, |
|
|
|
b |
|
) |
| ((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | (((b) & 0xF8) >> 3)) |
Creates a 16bit color from 8bit * 3 colors (r,g,b)
- Returns
| #define TRANSPARENT ((uint16_t)0x80C2) |
Transparent color
- Returns
| void tft_clear |
( |
uint16_t |
color | ) |
|
Clears the entire display with the given color. Overpaints everything which was there before.
- Parameters
-
| color | The 16-bit color to clear the display with. |
| bool tft_draw_bitmap_file_unscaled |
( |
uint16_t |
x, |
|
|
uint16_t |
y, |
|
|
const char * |
filename |
|
) |
| |
Draws a bitmap from the filesystem onto the display without scaling/cropping The bitmap must be saved in the windows bitmap format (.bmp) without compression and with 24 (b,g,r) or 32 (a,r,g,b) bits per pixel
- Parameters
-
| x | The x-coordinate of the top-left corner to draw the bitmap at |
| y | The y-coordinate of the top-left corner to draw the bitmap at |
| filename | The absolute path to the .bmp file |
- Returns
- true on success
| void tft_draw_bitmap_unscaled |
( |
uint16_t |
x, |
|
|
uint16_t |
y, |
|
|
uint16_t |
width, |
|
|
uint16_t |
height, |
|
|
const uint16_t * |
dat |
|
) |
| |
Draws a bitmap onto the display without scaling/cropping. The bitmap must be provided as an array of 16-bit colors
- Parameters
-
| x | The x-coordinate of the top-left corner to draw the bitmap at |
| y | The y-coordinate of the top-left corner to draw the bitmap at |
| width | The width of the bitmap in pixels |
| height | The height of the bitmap in pixels |
| dat | A pointer to a uint16_t array containing the colors for each pixel. Starting in the topleft and going from left to right, line by line. |
| void tft_draw_circle |
( |
uint16_t |
x, |
|
|
uint16_t |
y, |
|
|
uint16_t |
r, |
|
|
uint16_t |
color |
|
) |
| |
Draws the outline of a circle onto the display
- Parameters
-
| x | The x-Coordinate of the center point |
| y | The y-Coordinate of the center point |
| r | The Radius in Pixels |
| color | The 16-Bit color to draw the circle with |
| void tft_draw_line |
( |
uint16_t |
x1, |
|
|
uint16_t |
y1, |
|
|
uint16_t |
x2, |
|
|
uint16_t |
y2, |
|
|
uint16_t |
color |
|
) |
| |
Draws a line onto the display. The pixels specified by start/end point are inclusive!
- Parameters
-
| x1 | The x-Coordinate of the start-point |
| y1 | The y-Coordinate of the start-point |
| x2 | The x-Coordinate of the end-point |
| y2 | The y-Coordinate of the end-point |
| color | The 16-bit color to draw the line with |
| void tft_draw_pixel |
( |
uint16_t |
x, |
|
|
uint16_t |
y, |
|
|
uint16_t |
color |
|
) |
| |
Draws a pixel onto the display.
- Parameters
-
| x | The x-Coordinate of the pixel |
| y | The y-Coordinate of the pixel |
| color | The 16-bit color to draw the pixel with |
| void tft_draw_rectangle |
( |
uint16_t |
x1, |
|
|
uint16_t |
y1, |
|
|
uint16_t |
x2, |
|
|
uint16_t |
y2, |
|
|
uint16_t |
color |
|
) |
| |
Draws the outline of a rectangle onto the display. The outline is one pixel wide and goes through the specified start and endpoint.
- Parameters
-
| x1 | The x-Coordinate of the start-point |
| y1 | The y-Coordinate of the start-point |
| x2 | The x-Coordinate of the end-point |
| y2 | The y-Coordinate of the end-point |
| color | The 16-bit color to draw the pixel with |
| void tft_fill_rectangle |
( |
uint16_t |
x1, |
|
|
uint16_t |
y1, |
|
|
uint16_t |
x2, |
|
|
uint16_t |
y2, |
|
|
uint16_t |
color |
|
) |
| |
Draws a filled rectangle onto the display. The start,end points are inclusive
- Parameters
-
| x1 | The x-Coordinate of the start-point |
| y1 | The y-Coordinate of the start-point |
| x2 | The x-Coordinate of the end-point |
| y2 | The y-Coordinate of the end-point |
| color | The 16-bit color to draw the pixel with |
| uint8_t tft_font_height |
( |
uint8_t |
fontnum | ) |
|
Get the height of a font
- Parameters
-
| fontnum | The number of the font, from 0 .. (num_fonts -1) |
- Returns
- The height in pixel
| uint8_t tft_font_width |
( |
uint8_t |
fontnum | ) |
|
Get the width of a font
- Parameters
-
| fontnum | The number of the font, from 0 .. (num_fonts -1) |
- Returns
- The width in pixel
Initializes the display. Call this method before using any tft_* functions
- Returns
- true on success
| uint8_t tft_num_fonts |
( |
| ) |
|
Queries the number of available fonts
- Returns
| void tft_print_formatted |
( |
uint16_t |
x, |
|
|
uint16_t |
y, |
|
|
uint16_t |
color, |
|
|
uint16_t |
bgcolor, |
|
|
uint8_t |
font, |
|
|
const char * |
format, |
|
|
|
... |
|
) |
| |
Prints a formatted text (like printf) onto the display
- Parameters
-
| x | The x-Coordinate of the Top-Left corner where the text should be drawn |
| y | The y-Coordinate of the Top-Left corner where the text should be drawn |
| color | The 16-bit foreground color of the text |
| bgcolor | The 16-bit background color of the text. You may pass TRANSPARENT as Color |
| font | The Fontnum to use for drawing |
| format | The format string (like printf) |
| ... | The arguments to format (like printf) |
| void tft_print_line |
( |
uint16_t |
x, |
|
|
uint16_t |
y, |
|
|
uint16_t |
color, |
|
|
uint16_t |
bgcolor, |
|
|
uint8_t |
font, |
|
|
const char * |
text |
|
) |
| |
Prints a unformatted/preformatted string onto the display
- Parameters
-
| x | The x-Coordinate of the Top-Left corner where the text should be drawn |
| y | The y-Coordinate of the Top-Left corner where the text should be drawn |
| color | The 16-bit foreground color of the text |
| bgcolor | The 16-bit background color of the text. You may pass TRANSPARENT as Color |
| font | The Fontnum to use for drawing |
| text | The text to draw |