discoverpixy
Macros | Functions
TFT

Macros

#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)
 

Functions

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,...)
 

Detailed Description

The TFT Modul provides access to the display

Macro Definition Documentation

#define BLACK   RGB(0,0,0)
#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 RED   RGB(255,0,0)
#define RGB (   r,
  g,
 
)    ((((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
#define WHITE   0xF7BE

Function Documentation

void tft_clear ( uint16_t  color)

Clears the entire display with the given color. Overpaints everything which was there before.

Parameters
colorThe 16-bit color to clear the display with.

Here is the call graph for this function:

Here is the caller graph for this function:

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
xThe x-coordinate of the top-left corner to draw the bitmap at
yThe y-coordinate of the top-left corner to draw the bitmap at
filenameThe absolute path to the .bmp file
Returns
true on success

Here is the call graph for this function:

Here is the caller graph for this function:

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
xThe x-coordinate of the top-left corner to draw the bitmap at
yThe y-coordinate of the top-left corner to draw the bitmap at
widthThe width of the bitmap in pixels
heightThe height of the bitmap in pixels
datA 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.

Here is the call graph for this function:

Here is the caller graph for this function:

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
xThe x-Coordinate of the center point
yThe y-Coordinate of the center point
rThe Radius in Pixels
colorThe 16-Bit color to draw the circle with

Here is the call graph for this function:

Here is the caller graph for this function:

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
x1The x-Coordinate of the start-point
y1The y-Coordinate of the start-point
x2The x-Coordinate of the end-point
y2The y-Coordinate of the end-point
colorThe 16-bit color to draw the line with

Here is the call graph for this function:

Here is the caller graph for this function:

void tft_draw_pixel ( uint16_t  x,
uint16_t  y,
uint16_t  color 
)

Draws a pixel onto the display.

Parameters
xThe x-Coordinate of the pixel
yThe y-Coordinate of the pixel
colorThe 16-bit color to draw the pixel with

Here is the call graph for this function:

Here is the caller graph for this function:

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
x1The x-Coordinate of the start-point
y1The y-Coordinate of the start-point
x2The x-Coordinate of the end-point
y2The y-Coordinate of the end-point
colorThe 16-bit color to draw the pixel with

Here is the call graph for this function:

Here is the caller graph for this function:

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
x1The x-Coordinate of the start-point
y1The y-Coordinate of the start-point
x2The x-Coordinate of the end-point
y2The y-Coordinate of the end-point
colorThe 16-bit color to draw the pixel with

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t tft_font_height ( uint8_t  fontnum)

Get the height of a font

Parameters
fontnumThe number of the font, from 0 .. (num_fonts -1)
Returns
The height in pixel

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t tft_font_width ( uint8_t  fontnum)

Get the width of a font

Parameters
fontnumThe number of the font, from 0 .. (num_fonts -1)
Returns
The width in pixel

Here is the call graph for this function:

Here is the caller graph for this function:

bool tft_init ( )

Initializes the display. Call this method before using any tft_* functions

Returns
true on success

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t tft_num_fonts ( )

Queries the number of available fonts

Returns

Here is the call graph for this function:

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
xThe x-Coordinate of the Top-Left corner where the text should be drawn
yThe y-Coordinate of the Top-Left corner where the text should be drawn
colorThe 16-bit foreground color of the text
bgcolorThe 16-bit background color of the text. You may pass TRANSPARENT as Color
fontThe Fontnum to use for drawing
formatThe format string (like printf)
...The arguments to format (like printf)

Here is the call graph for this function:

Here is the caller graph for this function:

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
xThe x-Coordinate of the Top-Left corner where the text should be drawn
yThe y-Coordinate of the Top-Left corner where the text should be drawn
colorThe 16-bit foreground color of the text
bgcolorThe 16-bit background color of the text. You may pass TRANSPARENT as Color
fontThe Fontnum to use for drawing
textThe text to draw

Here is the call graph for this function:

Here is the caller graph for this function: