|
#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
Definition at line 54 of file tft.h.
#define BLUE RGB(0,0,255) |
Definition at line 52 of file tft.h.
#define GREEN RGB(0,255,0) |
Definition at line 51 of file tft.h.
#define HEX |
( |
|
h | ) |
(RGB(((h)>>16),((h)>>8),(h))) |
Creates a 16bit color from a 24bit hex rgb color code
- Returns
Definition at line 60 of file tft.h.
Definition at line 50 of file tft.h.
#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
Definition at line 48 of file tft.h.
#define TRANSPARENT ((uint16_t)0x80C2) |
Transparent color
- Returns
Definition at line 66 of file tft.h.
Definition at line 53 of file tft.h.
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. |
Definition at line 45 of file tft.c.
void ll_tft_clear(uint16_t color)
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
Definition at line 123 of file tft.c.
135 unsigned char info[54];
143 uint32_t
width = *(uint32_t*)&info[18];
144 uint32_t
height = *(uint32_t*)&info[22];
145 uint16_t depth = *(uint16_t*)&info[28];
150 uint32_t row_padded = (width * depth + 3) & (~3);
152 unsigned char data [row_padded];
154 for (
int i = 0; i <
height; i++) {
157 for (
int j = 0; j < width * depth; j += depth) {
158 unsigned char a, r, g, b;
165 }
else if (depth == 3) {
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
FILE_HANDLE * filesystem_file_open(const char *filename)
void filesystem_file_close(FILE_HANDLE *handle)
void tft_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
FILE_STATUS filesystem_file_read(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
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. |
Definition at line 72 of file tft.c.
void ll_tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *dat)
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 |
Definition at line 77 of file tft.c.
void ll_tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color)
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 |
Definition at line 50 of file tft.c.
void ll_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 |
|
) |
| |
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 |
Definition at line 56 of file tft.c.
void ll_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 |
|
) |
| |
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 |
Definition at line 61 of file tft.c.
void ll_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 |
|
) |
| |
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 |
Definition at line 67 of file tft.c.
void ll_tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
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
Definition at line 87 of file tft.c.
uint8_t ll_tft_font_height(uint8_t fontnum)
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
Definition at line 92 of file tft.c.
uint8_t ll_tft_font_width(uint8_t fontnum)
Initializes the display. Call this method before using any tft_* functions
- Returns
- true on success
Definition at line 39 of file tft.c.
uint8_t tft_num_fonts |
( |
| ) |
|
Queries the number of available fonts
- Returns
Definition at line 82 of file tft.c.
uint8_t ll_tft_num_fonts()
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) |
Definition at line 111 of file tft.c.
113 static char buffer[128];
117 va_start(args, format);
118 vsprintf(buffer, format, args);
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_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 |
Definition at line 98 of file tft.c.
104 for (
int i = 0; i < strlen(text); i++) {
uint8_t ll_tft_font_width(uint8_t fontnum)
uint8_t ll_tft_num_fonts()
void ll_tft_draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, char c)