Graphics driver
[Graphical display system]

Collaboration diagram for Graphics driver:

Data Structures

struct  font
 Storage structure for font metadata. More...
struct  gfx_bitmap
 Storage structure for bitmap pixel data and metadata. More...

Modules

 Generic Implementation of Graphics Primitives

Enumerations

enum  font_data_type { FONT_LOC_PROGMEM, FONT_LOC_HUGEMEM }

Functions

static uint_fast8_t gfx_font_get_height (struct font *font)
 Get scaled height of a font.
static uint_fast8_t gfx_font_get_width (struct font *font)
 Get scaled width of a font.

Bitmap functions and structures



enum  gfx_bitmap_type { BITMAP_SOLID, BITMAP_RAM, BITMAP_PROGMEM }
void gfx_draw_bitmap (const struct gfx_bitmap *bmp, gfx_coord_t x, gfx_coord_t y)
 Draw a bitmap.
void gfx_draw_bitmap_tiled (const struct gfx_bitmap *bmp, gfx_coord_t x1, gfx_coord_t y1, gfx_coord_t x2, gfx_coord_t y2, gfx_coord_t tile_origin_x, gfx_coord_t tile_origin_y)
 Draw a bitmap to the screen tiled to cover the output area.
void gfx_put_bitmap (const struct gfx_bitmap *bmp, gfx_coord_t map_x, gfx_coord_t map_y, gfx_coord_t x, gfx_coord_t y, gfx_coord_t width, gfx_coord_t height)
 Write a rectangular block of pixels from a bitmap to the screen.

Driver-specific Definitions



typedef uint16_t gfx_color_t
 Data type for color values native to the display.
typedef int16_t gfx_coord_t
 Data type representing a coordinate on the screen.
#define GFX_COLOR(r, g, b)
 Generate a display-native color value from constant RGB components.
#define GFX_COLOR_INVALID   GFX_COLOR(1,2,3)
 Value returned by gfx_get_pixel() for pixels outside clipping region.
#define GFX_COLOR_TRANSPARENT   GFX_COLOR(254,0,0)
 Value used as input to font functions to give a transparent background region.

Screen geometry and clipping variables

For internal use only.

These global variables should not be accessed directly. They cannot be marked as private/static since they are shared within multiple C files of the graphics drivers.

Use gfx_set_clipping to change clipping region.



gfx_coord_t gfx_min_x
 Minimum X of current clipping region.
gfx_coord_t gfx_min_y
 Maximum Y of current clipping region.
gfx_coord_t gfx_max_x
 Minimum X of current clipping region.
gfx_coord_t gfx_max_y
 Maximum Y of current clipping region.
gfx_coord_t gfx_width
 Current width of screen.
gfx_coord_t gfx_height
 Current height of screen.

Display driver management functions



void gfx_init (void)
 Initialize the low-level graphics device driver.
void gfx_sync (void)
 Synchronize access to the display.

Display Geometry



void gfx_set_orientation (uint8_t flags)
 Change display orientation.
gfx_coord_t gfx_get_width (void)
 Return the current width of the screen.
gfx_coord_t gfx_get_height (void)
 Return the current height of the screen.

Display Clipping

The display driver uses software and hardware clipping. In the graphics drivers software clipping is referred to as clipping and hardware clipping as limits.

Software clipping is used to ensure that nothing outside the set region is draw to the screen by any of the drawing functions. Eliminating unwanted drawing to the display will give a higher performance on displays which has a low bandwidth from the CPU. Software is enabled by the CONFIG_GFX_USE_CLIPPING configuration symbol. Clipping region is set with the gfx_set_clipping function.

Hardware clipping is used in the supported display drivers to efficiently draw primitives on a subset of the display. Example: when drawing a filled rectangle the limits is set to the size of the rectangle, and the driver sends the correct number of pixels to fill the entire rectangle. Without hardware clipping/limits the driver will have to to move the graphics ram (GRAM) position/pointer manually. Hardware clipping/limits is not used like software clipping to eliminate drawing outside a given region. Hardware clipping is set with the gfx_set_top_left_limit, gfx_set_bottom_right_limit and gfx_set_limits functions. In display drivers that do not use hardware clipping these functions will not have any effect.



void gfx_set_clipping (gfx_coord_t min_x, gfx_coord_t min_y, gfx_coord_t max_x, gfx_coord_t max_y)
 Set the clipping region.
void gfx_set_top_left_limit (gfx_coord_t x, gfx_coord_t y)
 Set the top-left limit for the display.
void gfx_set_bottom_right_limit (gfx_coord_t x, gfx_coord_t y)
 Set the bottom-right limit for the display.
void gfx_set_limits (gfx_coord_t x1, gfx_coord_t y1, gfx_coord_t x2, gfx_coord_t y2)
 Set the limits for the display.

Low-level pixel drawing operations



gfx_color_t gfx_color (uint8_t r, uint8_t g, uint8_t b)
 Generate native color value from R/G/B values.
void gfx_draw_pixel (gfx_coord_t x, gfx_coord_t y, gfx_color_t color)
 Draw a single pixel on the screen.
void gfx_draw_line_pixel (gfx_coord_t x, gfx_coord_t y, gfx_color_t color)
 Draw a single pixel on the screen (for lines, apparently).
gfx_color_t gfx_get_pixel (gfx_coord_t x, gfx_coord_t y)
 Get the color of a pixel on the display.
void gfx_duplicate_pixel (gfx_color_t color, uint32_t count)
 Draw multiple pixels all having the same color.
void gfx_copy_pixels_to_screen (const gfx_color_t *pixels, uint32_t count)
 Copy a block of pixels from data memory to screen.
void gfx_copy_progmem_pixels_to_screen (const gfx_color_t __progmem_arg *pixels, uint32_t count)
 Copy a block of pixels from program memory to screen.
void gfx_copy_hugemem_pixels_to_screen (const hugemem_ptr_t pixels, uint32_t count)
 Copy a block of pixels from hugemem to screen.
void gfx_copy_pixels_from_screen (gfx_color_t *pixels, uint32_t count)
 Copy a block of pixels from screen to data memory.

Graphics Drawing Primitives



void gfx_draw_char (char c, gfx_coord_t x, gfx_coord_t y, struct font *font, gfx_color_t color, gfx_color_t background_color)
 Draws a character to the display.
void gfx_draw_string (char *str, gfx_coord_t x, gfx_coord_t y, struct font *font, gfx_color_t color, gfx_color_t background_color)
 Draws a string to the display.
void gfx_draw_progmem_string (const char __progmem_arg *str, gfx_coord_t x, gfx_coord_t y, struct font *font, gfx_color_t color, gfx_color_t background_color)
void gfx_get_string_bounding_box (char const *str, struct font *font, gfx_coord_t *width, gfx_coord_t *height)
 Computes the bounding box of a string.
void gfx_get_progmem_string_bounding_box (const char __progmem_arg *str, struct font *font, gfx_coord_t *width, gfx_coord_t *height)
 Computes the bounding box of a string stored in progmem.
#define gfx_draw_horizontal_line(x, y, length, color)   gfx_generic_draw_horizontal_line(x, y, length, color)
 Draw a horizontal line, one pixel wide.
#define gfx_draw_vertical_line(x, y, length, color)   gfx_generic_draw_vertical_line(x, y, length, color)
 Draw a vertical line, one pixel wide.
#define gfx_draw_line(x1, y1, x2, y2, color)   gfx_generic_draw_line(x1, y1, x2, y2, color)
 Draw a line between two arbitrary points.
#define gfx_draw_rect(x, y, width, height, color)   gfx_generic_draw_rect(x, y, width, height, color)
 Draw an outline of a rectangle.
#define gfx_draw_filled_rect(x, y, width, height, color)   gfx_generic_draw_filled_rect(x, y, width, height, color)
 Draw a filled rectangle.
#define gfx_draw_circle(x, y, radius, color, octant_mask)   gfx_generic_draw_circle(x, y, radius, color, octant_mask)
 Draw an outline of a circle or arc.
#define gfx_draw_filled_circle(x, y, radius, color, quadrant_mask)   gfx_generic_draw_filled_circle(x, y, radius, color, quadrant_mask)
 Draw a filled circle or sector.
#define gfx_get_pixmap(pixmap, map_width, map_x, map_y, x, y, width, height)
 Read a rectangular block of pixels from the screen into data memory.
#define gfx_put_pixmap(pixmap, map_width, map_x, map_y, x, y, width, height)
 Write a rectangular block of pixels stored in data memory to the screen.

Circle Sector Definitions



#define GFX_OCTANT0   (1 << 0)
 Bitmask for drawing circle octant 0.
#define GFX_OCTANT1   (1 << 1)
 Bitmask for drawing circle octant 1.
#define GFX_OCTANT2   (1 << 2)
 Bitmask for drawing circle octant 2.
#define GFX_OCTANT3   (1 << 3)
 Bitmask for drawing circle octant 3.
#define GFX_OCTANT4   (1 << 4)
 Bitmask for drawing circle octant 4.
#define GFX_OCTANT5   (1 << 5)
 Bitmask for drawing circle octant 5.
#define GFX_OCTANT6   (1 << 6)
 Bitmask for drawing circle octant 6.
#define GFX_OCTANT7   (1 << 7)
 Bitmask for drawing circle octant 7.
#define GFX_QUADRANT0   (GFX_OCTANT0 | GFX_OCTANT1)
 Bitmask for drawing circle quadrant 0.
#define GFX_QUADRANT1   (GFX_OCTANT2 | GFX_OCTANT3)
 Bitmask for drawing circle quadrant 1.
#define GFX_QUADRANT2   (GFX_OCTANT4 | GFX_OCTANT5)
 Bitmask for drawing circle quadrant 2.
#define GFX_QUADRANT3   (GFX_OCTANT6 | GFX_OCTANT7)
 Bitmask for drawing circle quadrant 3.
#define GFX_LEFTHALF   (GFX_QUADRANT3 | GFX_QUADRANT0)
 Bitmask for drawing left half of circle.
#define GFX_TOPHALF   (GFX_QUADRANT0 | GFX_QUADRANT1)
 Bitmask for drawing top half of circle.
#define GFX_RIGHTHALF   (GFX_QUADRANT1 | GFX_QUADRANT2)
 Bitmask for drawing right half of circle.
#define GFX_BOTTOMHALF   (GFX_QUADRANT2 | GFX_QUADRANT3)
 Bitmask for drawing bottom half of circle.
#define GFX_WHOLE   0xFF
 Bitmask for drawing whole circle.

Flags for gfx_set_orientation()



#define GFX_FLIP_X   1
 Bitmask for flipping X for gfx_set_orientation.
#define GFX_FLIP_Y   2
 Bitmask for flipping Y for gfx_set_orientation.
#define GFX_SWITCH_XY   4
 Bitmask for swapping X and Y for gfx_set_orientation.

Detailed Description

This library provides an interface to drawing graphics on a graphical display

The graphics drivers consists of the following:

The display driver interface provides an general interface to be used by the application or by libraries like Sysfont, Window system, Widget toolkit or other libraries.

The generic drawing primitives is a library of functions for drawing graphics primitives such as lines, rectangles and circles. It uses other functions implemented by the display driver for drawing the primitives. The implementation of these functions can optionally be used by a display driver, but if the hardware of the display allows faster handling of any of the primitives, the display driver can implement it directly.

The display specific drivers provides an interface to the graphical display. It implements the low level communication with the display hardware, putting pixels on the display and drawing primitives such as lines, circles and rectangles. Depending on the display driver implementation, drawing the graphics primitives might be handled by the generic graphics drawing primitves rather than the display driver itself.


Define Documentation

#define GFX_BOTTOMHALF   (GFX_QUADRANT2 | GFX_QUADRANT3)

Bitmask for drawing bottom half of circle.

Definition at line 163 of file gfx.h.

#define GFX_COLOR ( r,
g,
 ) 
Value:
((((uint16_t)r) & 0x00f8) | \
        ((((uint16_t)b) << 5) & 0x1f00) | \
        ((((uint16_t)g) >> 5) & 0x0007) | \
        ((((uint16_t)g) << 11) & 0xe000))

Generate a display-native color value from constant RGB components.

This macro does the same job as gfx_color(), except that the RGB values must be constant, and that it is usable as a static initializer.

Referenced by sub_frame_draw_handler().

#define GFX_COLOR_INVALID   GFX_COLOR(1,2,3)

Value returned by gfx_get_pixel() for pixels outside clipping region.

It is not possible to define a color that is outside the color spectrum for the HX8347A driver, hence use a dark color as invalid color.

Referenced by gfx_get_pixel().

#define GFX_COLOR_TRANSPARENT   GFX_COLOR(254,0,0)

Value used as input to font functions to give a transparent background region.

Referenced by gfx_draw_char(), sub_frame_draw_handler(), wtk_button_handler(), wtk_check_box_handler(), wtk_frame_handler(), wtk_label_handler(), and wtk_radio_button_handler().

#define gfx_draw_circle ( x,
y,
radius,
color,
octant_mask   )     gfx_generic_draw_circle(x, y, radius, color, octant_mask)

Draw an outline of a circle or arc.

HX8347A display driver uses generic gfx implementation for this function. See gfx_generic_draw_circle

The radius is the distance from the center to the circumference, which means that the total width or height of a circle will be (radius*2+1).

The octant_mask parameter is a bitmask that decides which octants of the circle to draw. Use the GFX_OCTANTn, GFX_QUADRANTn, GFX_xHALF and GFX_WHOLE contants and OR them together if required. Radius equal to zero gives a single pixel.

Parameters:
x X coordinate of center.
y Y coordinate of center.
radius Circle radius in pixels.
color Circle color in display native format.
octant_mask Bitmask indicating which octants to draw.

Referenced by touch_calibrate_task_handler(), and wtk_radio_button_handler().

#define gfx_draw_filled_circle ( x,
y,
radius,
color,
quadrant_mask   )     gfx_generic_draw_filled_circle(x, y, radius, color, quadrant_mask)

Draw a filled circle or sector.

HX8347A display driver uses generic gfx implementation for this function. See gfx_generic_draw_filled_circle

The radius is the distance from the center to the circumference, which means that the total width or height of a circle will be (radius*2+1).

The quadrant_mask parameter is a bitmask that decides which quadrants of the circle to draw. Use the GFX_QUADRANTn, GFX_xHALF and GFX_WHOLE contants and OR them together if required. Radius equal to zero gives a single pixel.

Note:
This function only supports quadrants while gfx_draw_circle() supports octants. This is to improve performance on drawing filled circles.
Parameters:
x X coordinate of center.
y Y coordinate of center.
radius Circle radius in pixels.
color Circle color in display native format.
quadrant_mask Bitmask indicating which quadrants to draw.

Referenced by wtk_continue_drag(), wtk_frame_handler(), wtk_radio_button_handler(), and wtk_start_drag().

#define gfx_draw_filled_rect ( x,
y,
width,
height,
color   )     gfx_generic_draw_filled_rect(x, y, width, height, color)

Draw a filled rectangle.

HX8347A display driver uses generic gfx implementation for this function. See gfx_generic_draw_filled_rect

Parameters:
x X coordinate of the left side.
y Y coordinate of the top side.
width Width of the rectangle.
height Height of the rectangle.
color Color of the rectangle, in display native format.

Referenced by gfx_draw_bitmap_tiled(), gfx_draw_char(), gfx_draw_char_hugemem(), gfx_draw_char_progmem(), gfx_generic_draw_horizontal_line(), gfx_generic_draw_vertical_line(), gfx_put_bitmap(), wtk_button_handler(), wtk_check_box_handler(), wtk_frame_handler(), wtk_progress_bar_handler(), and wtk_slider_handler().

#define gfx_draw_horizontal_line ( x,
y,
length,
color   )     gfx_generic_draw_horizontal_line(x, y, length, color)

Draw a horizontal line, one pixel wide.

HX8347A display driver uses generic gfx implementation for this function. See gfx_generic_draw_horizontal_line

Parameters:
x X coordinate of leftmost pixel.
y Y coordinate of the line.
length Length of the line in pixels.
color Color of the line, in display native format.

Referenced by gfx_generic_draw_rect().

#define gfx_draw_line ( x1,
y1,
x2,
y2,
color   )     gfx_generic_draw_line(x1, y1, x2, y2, color)

Draw a line between two arbitrary points.

HX8347A display driver uses generic gfx implementation for this function. See gfx_generic_draw_line

Parameters:
x1 Start X coordinate.
y1 Start Y coordinate.
x2 End X coordinate.
y2 End Y coordinate.
color Color of the line, in display native format.
#define gfx_draw_rect ( x,
y,
width,
height,
color   )     gfx_generic_draw_rect(x, y, width, height, color)

Draw an outline of a rectangle.

HX8347A display driver uses generic gfx implementation for this function. See gfx_generic_draw_rect

Parameters:
x X coordinate of the left side.
y Y coordinate of the top side.
width Width of the rectangle.
height Height of the rectangle.
color Color of the rectangle, in display native format.

Referenced by wtk_button_handler(), wtk_check_box_handler(), wtk_progress_bar_handler(), and wtk_slider_handler().

#define gfx_draw_vertical_line ( x,
y,
length,
color   )     gfx_generic_draw_vertical_line(x, y, length, color)

Draw a vertical line, one pixel wide.

HX8347A display driver uses generic gfx implementation for this function. See gfx_generic_draw_vertical_line

Parameters:
x X coordinate of the line.
y Y coordinate of the topmost pixel.
length Length of the line in pixels.
color Color of the line, in display native format.

Referenced by gfx_generic_draw_filled_circle(), and gfx_generic_draw_rect().

#define GFX_FLIP_X   1

Bitmask for flipping X for gfx_set_orientation.

Definition at line 173 of file gfx.h.

Referenced by gfx_set_orientation().

#define GFX_FLIP_Y   2

Bitmask for flipping Y for gfx_set_orientation.

Definition at line 175 of file gfx.h.

Referenced by gfx_set_orientation().

#define gfx_get_pixmap ( pixmap,
map_width,
map_x,
map_y,
x,
y,
width,
height   ) 
Value:
gfx_generic_get_pixmap(pixmap, map_width, map_x, map_y, x, y, width, \
                                height)

Read a rectangular block of pixels from the screen into data memory.

HX8347A display driver uses generic gfx implementation for this function. See gfx_generic_get_pixmap

If the area to read is outside the clipping region, those pixels will not be read, and the corresponding data memory will be left untouched. Note that this function fails if width or height is negative or the pixel rectangle is outside the pixmap buffer extents. Clipping is only performed on the screen, not inside the pixmap buffer itself. Note that there is no checking if the pixel rectangle exceeds the bottom of the pixmap buffer.

Parameters:
pixmap Pointer to pixel buffer in data memory.
map_width Width of the pixel buffer.
map_x X coordinate inside pixel buffer.
map_y Y coordinate inside pixel buffer.
x X coordinate on screen.
y Y coordinate on screen.
width Width of pixel rectangle to copy.
height Height of pixel rectangle to copy.

Referenced by wtk_continue_drag(), and wtk_start_drag().

#define GFX_LEFTHALF   (GFX_QUADRANT3 | GFX_QUADRANT0)

Bitmask for drawing left half of circle.

Definition at line 157 of file gfx.h.

#define GFX_OCTANT0   (1 << 0)

Bitmask for drawing circle octant 0.

Definition at line 131 of file gfx.h.

Referenced by gfx_generic_draw_circle().

#define GFX_OCTANT1   (1 << 1)

Bitmask for drawing circle octant 1.

Definition at line 133 of file gfx.h.

Referenced by gfx_generic_draw_circle().

#define GFX_OCTANT2   (1 << 2)

Bitmask for drawing circle octant 2.

Definition at line 135 of file gfx.h.

Referenced by gfx_generic_draw_circle().

#define GFX_OCTANT3   (1 << 3)

Bitmask for drawing circle octant 3.

Definition at line 137 of file gfx.h.

Referenced by gfx_generic_draw_circle().

#define GFX_OCTANT4   (1 << 4)

Bitmask for drawing circle octant 4.

Definition at line 139 of file gfx.h.

Referenced by gfx_generic_draw_circle().

#define GFX_OCTANT5   (1 << 5)

Bitmask for drawing circle octant 5.

Definition at line 141 of file gfx.h.

Referenced by gfx_generic_draw_circle().

#define GFX_OCTANT6   (1 << 6)

Bitmask for drawing circle octant 6.

Definition at line 143 of file gfx.h.

Referenced by gfx_generic_draw_circle().

#define GFX_OCTANT7   (1 << 7)

Bitmask for drawing circle octant 7.

Definition at line 145 of file gfx.h.

Referenced by gfx_generic_draw_circle().

#define gfx_put_pixmap ( pixmap,
map_width,
map_x,
map_y,
x,
y,
width,
height   ) 
Value:
gfx_generic_put_pixmap(pixmap, map_width, map_x, map_y, x, y, width, \
                                height)

Write a rectangular block of pixels stored in data memory to the screen.

HX8347A display driver uses generic gfx implementation for this function. See gfx_generic_put_pixmap

If the area to write is outside the clipping region, those pixels will not be written. Note that this function fails if the width or height is negative or the pixel rectangle is outside the pixmap buffer extents. Clipping is only performed on the screen, not inside the pixmap buffer itself. Note that there is no checking if the pixel rectangle exceeds the bottom of the pixmap buffer.

Parameters:
pixmap Pointer to pixel buffer in data memory.
map_width Width of the pixel buffer.
map_x X coordinate inside pixel buffer.
map_y Y coordinate inside pixel buffer.
x X coordinate on screen.
y Y coordinate on screen.
width Width of pixel rectangle to copy.
height Height of pixel rectangle to copy.

Referenced by wtk_continue_drag(), and wtk_stop_drag().

#define GFX_QUADRANT0   (GFX_OCTANT0 | GFX_OCTANT1)

Bitmask for drawing circle quadrant 0.

Definition at line 148 of file gfx.h.

Referenced by gfx_generic_draw_filled_circle().

#define GFX_QUADRANT1   (GFX_OCTANT2 | GFX_OCTANT3)

Bitmask for drawing circle quadrant 1.

Definition at line 150 of file gfx.h.

Referenced by gfx_generic_draw_filled_circle(), and wtk_frame_handler().

#define GFX_QUADRANT2   (GFX_OCTANT4 | GFX_OCTANT5)

Bitmask for drawing circle quadrant 2.

Definition at line 152 of file gfx.h.

Referenced by gfx_generic_draw_filled_circle().

#define GFX_QUADRANT3   (GFX_OCTANT6 | GFX_OCTANT7)

Bitmask for drawing circle quadrant 3.

Definition at line 154 of file gfx.h.

Referenced by gfx_generic_draw_filled_circle().

#define GFX_RIGHTHALF   (GFX_QUADRANT1 | GFX_QUADRANT2)

Bitmask for drawing right half of circle.

Definition at line 161 of file gfx.h.

#define GFX_SWITCH_XY   4

Bitmask for swapping X and Y for gfx_set_orientation.

Definition at line 177 of file gfx.h.

Referenced by gfx_set_orientation().

#define GFX_TOPHALF   (GFX_QUADRANT0 | GFX_QUADRANT1)

Bitmask for drawing top half of circle.

Definition at line 159 of file gfx.h.

#define GFX_WHOLE   0xFF

Bitmask for drawing whole circle.

Definition at line 166 of file gfx.h.

Referenced by touch_calibrate_task_handler(), wtk_continue_drag(), wtk_radio_button_handler(), and wtk_start_drag().


Typedef Documentation

Data type for color values native to the display.

Definition at line 117 of file gfx_hx8347a.h.

Data type representing a coordinate on the screen.

Definition at line 118 of file gfx_hx8347a.h.


Enumeration Type Documentation

Valid storage locations for font data

Todo:
Add support for fonts in regular ram
Enumerator:
FONT_LOC_PROGMEM 

Font data stored in program/flash memory.

FONT_LOC_HUGEMEM 

Font data stored in HUGEMEM.

Definition at line 206 of file gfx.h.

\ brief Valid bitmap types

Enumerator:
BITMAP_SOLID 

Solid color bitmap.

BITMAP_RAM 

Bitmap stored in SRAM.

BITMAP_PROGMEM 

Bitmap stored in progmem.

Definition at line 265 of file gfx.h.


Function Documentation

gfx_color_t gfx_color ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Generate native color value from R/G/B values.

Converts 8-bit R/G/B values to a color value native to the display. The format of the resulting color value depends on the display.

The macro GFX_COLOR does the same, only allows the preprocessor to handle the calculations.

Parameters:
r 8-bit red value.
g 8-bit green value.
b 8-bit blue value.
Returns:
Color value in display native format.

Definition at line 273 of file gfx_hx8347a.c.

Referenced by gfx_copy_pixels_from_screen().

void gfx_copy_hugemem_pixels_to_screen ( const hugemem_ptr_t  pixels,
uint32_t  count 
)

Copy a block of pixels from hugemem to screen.

Copy a block of pixels from hugemem to screen, given current limits.

Parameters:
pixels An array of pixel values in display native format, stored in program (flash) memory.
count Number of pixels to copy from the array.

Definition at line 346 of file hx8347a_xmega.h.

References assert, gfx_select_chip, gfx_select_register(), and hugemem_read8().

Referenced by gfx_put_bitmap().

void gfx_copy_pixels_from_screen ( gfx_color_t pixels,
uint32_t  count 
)

Copy a block of pixels from screen to data memory.

Copy a block of pixels from the screen into RAM, given current limits

Parameters:
pixels Array into which the pixel values are to be stored.
count Number of pixels to copy into the array.

Definition at line 374 of file hx8347a_xmega.h.

References assert, gfx_color(), gfx_select_chip, and gfx_select_register().

Referenced by gfx_generic_get_pixmap().

void gfx_copy_pixels_to_screen ( const gfx_color_t pixels,
uint32_t  count 
)

Copy a block of pixels from data memory to screen.

Copy pixels from RAM to the screen, given current limits.

Parameters:
pixels An array of pixel values in display native format.
count Number of pixels to copy from the array.

Definition at line 257 of file hx8347a_xmega.h.

References assert, gfx_select_chip, and gfx_select_register().

Referenced by gfx_generic_put_pixmap(), and gfx_put_bitmap().

void gfx_copy_progmem_pixels_to_screen ( const gfx_color_t __progmem_arg *  pixels,
uint32_t  count 
)

Copy a block of pixels from program memory to screen.

Copy a block of pixels from program memory to screen, given current limits.

Parameters:
pixels An array of pixel values in display native format, stored in program (flash) memory.
count Number of pixels to copy from the array.

Definition at line 318 of file hx8347a_xmega.h.

References __progmem_arg, assert, gfx_select_chip, gfx_select_register(), and progmem_read8().

Referenced by gfx_put_bitmap().

void gfx_draw_bitmap ( const struct gfx_bitmap bmp,
gfx_coord_t  x,
gfx_coord_t  y 
)

Draw a bitmap.

Draw a bitmap to the screen on the given display coordinates.

Parameters:
bmp Pointer to bitmap
x Display X coordinate
y Display Y coordinate

Definition at line 55 of file gfx_bitmap.c.

References assert, gfx_put_bitmap(), gfx_bitmap::height, and gfx_bitmap::width.

void gfx_draw_bitmap_tiled ( const struct gfx_bitmap bmp,
gfx_coord_t  x1,
gfx_coord_t  y1,
gfx_coord_t  x2,
gfx_coord_t  y2,
gfx_coord_t  tile_origin_x,
gfx_coord_t  tile_origin_y 
)

Draw a bitmap to the screen tiled to cover the output area.

The function starts at the tile origin and searches to find the coordinate closest to the top left of the output area that is a multiple of the bitmap width/height. It then draws the bitmap as many times as needed to cover the entire output area.

gfx_draw_bitmap_tiled.png

To draw a bitmap tiled on the entire screen, regardless of the bitmap size, the function can be used like this:

The function is used by the window system to redraw the background of a parent window when a transparent child window needs to be redrawn. In this case the full parent window does not need redrawing, only the area of the parent window that is under the child window. The tiles of the background image will for all windows start at the top left corner of the window, so the function is used like this:

 gfx_draw_bitmap_tiled(parent_background_bmp,
                       child_window_x1, child_window_y1,
                       child_window_x2, child_window_y2,
                       parent_window_origin_x, parent_window_origin_y);
Note:
If CONFIG_WIN_USE_CLIPPING is used, the output is clipped to the output area and nothing will be drawn outside the output area.
Parameters:
bmp Pointer to bitmap
x1 Output area left coordinate
y1 Output area top coordinate
x2 Output area right coordinate
y2 Output area bottom coordinate
tile_origin_x Tile origin left coordinate
tile_origin_y Tile origin top coordinate

Definition at line 104 of file gfx_bitmap.c.

References assert, BITMAP_SOLID, gfx_bitmap::color, gfx_draw_filled_rect, gfx_put_bitmap(), gfx_bitmap::height, gfx_bitmap::type, and gfx_bitmap::width.

Referenced by win_draw_contents().

void gfx_draw_char ( char  c,
gfx_coord_t  x,
gfx_coord_t  y,
struct font font,
gfx_color_t  color,
gfx_color_t  background_color 
)

Draws a character to the display.

If background_color is set to GFX_COLOR_TRANSPARENT, no background is drawn.

Parameters:
c Character to be drawn
x X coordinate on screen.
y Y coordinate on screen.
font Font to draw character in
color Foreground color of character
background_color Background color of character

Definition at line 200 of file gfx_text.c.

References assert, font::first_char, FONT_LOC_HUGEMEM, FONT_LOC_PROGMEM, GFX_COLOR_TRANSPARENT, gfx_draw_char_hugemem(), gfx_draw_char_progmem(), gfx_draw_filled_rect, font::height, font::last_char, font::scale, font::type, unhandled_case, and font::width.

Referenced by gfx_draw_progmem_string(), and gfx_draw_string().

void gfx_draw_line_pixel ( gfx_coord_t  x,
gfx_coord_t  y,
gfx_color_t  color 
)

Draw a single pixel on the screen (for lines, apparently).

This function draws a single pixel on screen only setting top limit which makes it more suitable for line drawing. If outside the clipping region, nothing is drawn.

Parameters:
x X coordinate of the pixel to be drawn.
y Y coordinate of the pixel to be drawn.
color Color value of the pixel in display native format.

Definition at line 321 of file gfx_hx8347a.c.

References gfx_max_x, gfx_max_y, gfx_min_x, gfx_min_y, and gfx_set_top_left_limit().

Referenced by gfx_generic_draw_line().

void gfx_draw_pixel ( gfx_coord_t  x,
gfx_coord_t  y,
gfx_color_t  color 
)

Draw a single pixel on the screen.

Draw a single pixel on screen setting top and bottom limits. If outside the clipping region, nothing is drawn.

Parameters:
x X coordinate of the pixel to be drawn.
y Y coordinate of the pixel to be drawn.
color Color value of the pixel in display native format.

Definition at line 308 of file gfx_hx8347a.c.

References gfx_max_x, gfx_max_y, gfx_min_x, gfx_min_y, and gfx_set_limits().

Referenced by gfx_draw_char_hugemem(), gfx_draw_char_progmem(), gfx_generic_draw_circle(), and gfx_generic_draw_filled_circle().

void gfx_draw_progmem_string ( const char __progmem_arg *  str,
gfx_coord_t  x,
gfx_coord_t  y,
struct font font,
gfx_color_t  color,
gfx_color_t  background_color 
)

This function draws a string from progmem onto the screen.

If background_color is set to GFX_COLOR_TRANSPARENT, no background is drawn.

Parameters:
str Pointer to string in progmem
x X coordinate on screen.
y Y coordinate on screen.
font Font to draw string in
color Foreground color of string
background_color Backround color of string

Definition at line 263 of file gfx_text.c.

References __progmem_arg, assert, gfx_draw_char(), font::height, progmem_read8(), font::scale, and font::width.

void gfx_draw_string ( char *  str,
gfx_coord_t  x,
gfx_coord_t  y,
struct font font,
gfx_color_t  color,
gfx_color_t  background_color 
)

Draws a string to the display.

If background_color is set to GFX_COLOR_TRANSPARENT, no background is drawn.

Parameters:
str Pointer to string
x X coordinate on screen.
y Y coordinate on screen.
font Font to draw string in
color Foreground color of string
background_color Background color of string

Definition at line 233 of file gfx_text.c.

References assert, gfx_draw_char(), font::height, font::scale, and font::width.

Referenced by sub_frame_draw_handler(), wtk_button_handler(), wtk_check_box_handler(), wtk_frame_handler(), wtk_label_handler(), and wtk_radio_button_handler().

void gfx_duplicate_pixel ( gfx_color_t  color,
uint32_t  count 
)

Draw multiple pixels all having the same color.

Draw count pixels using color within the current clipping limits.

Parameters:
color Color value in display native format.
count Number of times to write the color

Definition at line 198 of file hx8347a_xmega.h.

References assert, gfx_select_chip, and gfx_select_register().

Referenced by gfx_generic_draw_filled_rect().

static uint_fast8_t gfx_font_get_height ( struct font font  )  [inline, static]

Get scaled height of a font.

Returns:
Scaled height in pixels for font

Definition at line 242 of file gfx.h.

References font::height, and font::scale.

static uint_fast8_t gfx_font_get_width ( struct font font  )  [inline, static]

Get scaled width of a font.

Returns:
Scaled width in pixels for font

Definition at line 252 of file gfx.h.

References font::scale, and font::width.

gfx_coord_t gfx_get_height ( void   ) 

Return the current height of the screen.

Return the current height of the screen for the current orientation. Screen can be rotated runtime on supported displays with gfx_set_orientation.

Returns:
Height of the screen in pixels.

Definition at line 268 of file gfx_hx8347a.c.

References gfx_height.

Referenced by wtk_continue_drag(), wtk_start_drag(), and wtk_stop_drag().

gfx_color_t gfx_get_pixel ( gfx_coord_t  x,
gfx_coord_t  y 
)

Get the color of a pixel on the display.

Parameters:
x X coordinate of the pixel to be sampled.
y Y coordinate of the pixel to be sampled.
Returns:
Color value of the pixel at (x, y) in display native format, or GFX_COLOR_INVALID if outside the clipping region.

Definition at line 291 of file gfx_hx8347a.c.

References GFX_COLOR_INVALID, gfx_max_x, gfx_max_y, gfx_min_x, gfx_min_y, and gfx_set_limits().

void gfx_get_progmem_string_bounding_box ( const char __progmem_arg *  str,
struct font font,
gfx_coord_t width,
gfx_coord_t height 
)

Computes the bounding box of a string stored in progmem.

If string is empty the returned width will be 1 pixel and the height equal to the font height.

Parameters:
str String to calculate bounding box for
font Font used
width Pointer to width result
height Pointer to height result

Definition at line 334 of file gfx_text.c.

References __progmem_arg, assert, font::height, progmem_read8(), font::scale, and font::width.

void gfx_get_string_bounding_box ( char const *  str,
struct font font,
gfx_coord_t width,
gfx_coord_t height 
)

Computes the bounding box of a string.

If string is empty the returned width will be 1 pixel and the height equal to the font height.

Parameters:
str String to calculate bounding box for
font Font used
width Pointer to width result
height Pointer to height result

Definition at line 298 of file gfx_text.c.

References assert, font::height, font::scale, and font::width.

Referenced by wtk_button_handler(), wtk_button_size_hint(), wtk_check_box_size_hint(), wtk_label_handler(), wtk_label_size_hint(), and wtk_radio_button_size_hint().

gfx_coord_t gfx_get_width ( void   ) 

Return the current width of the screen.

Return the current width of the screen for the current orientation. Screen can be rotated runtime on supported displays with gfx_set_orientation.

Returns:
Width of the screen in pixels.

Definition at line 263 of file gfx_hx8347a.c.

References gfx_width.

Referenced by wtk_continue_drag(), wtk_start_drag(), and wtk_stop_drag().

void gfx_init ( void   ) 

Initialize the low-level graphics device driver.

This function should be called before doing any graphics.

Definition at line 190 of file gfx_hx8347a.c.

References gfx_display_init_all(), gfx_exit_standby(), gfx_init_comms(), gfx_reset_display(), gfx_set_orientation(), and gfx_setup_interface().

void gfx_put_bitmap ( const struct gfx_bitmap bmp,
gfx_coord_t  map_x,
gfx_coord_t  map_y,
gfx_coord_t  x,
gfx_coord_t  y,
gfx_coord_t  width,
gfx_coord_t  height 
)

Write a rectangular block of pixels from a bitmap to the screen.

This function draws a subset of a bitmap to the screen. The subset is given by (map_x, map_y, width, height), and is outputted to the screen at the screen coordinates (x, y).

If the area to write is outside the clipping region, those pixels will not be written.

Note:
This function fails if the width or height is negative or the pixel rectangle is outside the pixmap buffer extents. Clipping is only performed on the screen, not inside the pixmap buffer itself.
There is no checking if the pixel rectangle exceeds the bottom of the pixmap buffer.
Parameters:
bmp Pointer to bitmap.
map_x X coordinate inside pixel buffer.
map_y Y coordinate inside pixel buffer.
x X coordinate on screen.
y Y coordinate on screen.
width Width of pixel rectangle to copy.
height Height of pixel rectangle to copy.

Definition at line 178 of file gfx_bitmap.c.

References __progmem_arg, assert, BITMAP_PROGMEM, BITMAP_RAM, BITMAP_SOLID, gfx_bitmap::color, gfx_copy_hugemem_pixels_to_screen(), gfx_copy_pixels_to_screen(), gfx_copy_progmem_pixels_to_screen(), gfx_draw_filled_rect, gfx_max_x, gfx_max_y, gfx_min_x, gfx_min_y, gfx_set_bottom_right_limit(), gfx_set_top_left_limit(), gfx_bitmap::pixmap, gfx_bitmap::progmem, gfx_bitmap::type, and gfx_bitmap::width.

Referenced by gfx_draw_bitmap(), and gfx_draw_bitmap_tiled().

void gfx_set_bottom_right_limit ( gfx_coord_t  x,
gfx_coord_t  y 
)

Set the bottom-right limit for the display.

Set bottom-right clipping limit for displays that needs to set a hardware clipping region.

Parameters:
x Bottom right x coordinate.
y Bottom right y coordinate.

Definition at line 343 of file gfx_hx8347a.c.

References gfx_write_register().

Referenced by gfx_generic_draw_line(), gfx_generic_get_pixmap(), gfx_generic_put_pixmap(), gfx_put_bitmap(), and gfx_set_limits().

void gfx_set_clipping ( gfx_coord_t  min_x,
gfx_coord_t  min_y,
gfx_coord_t  max_x,
gfx_coord_t  max_y 
)

Set the clipping region.

Set the clipping region for all subsequent graphics operations. Nothing will be drawn outside the clipping region. Clipping is handled in software, and is enabled with CONFIG_GFX_USE_CLIPPING.

Parameters:
min_x Left edge of region.
min_y Top edge of region.
max_x Right edge of region.
max_y Bottom edge of region.

Definition at line 212 of file gfx_hx8347a.c.

References gfx_height, gfx_max_x, gfx_max_y, gfx_min_x, gfx_min_y, and gfx_width.

Referenced by gfx_set_orientation(), win_draw_contents(), wtk_continue_drag(), wtk_start_drag(), and wtk_stop_drag().

void gfx_set_limits ( gfx_coord_t  x1,
gfx_coord_t  y1,
gfx_coord_t  x2,
gfx_coord_t  y2 
)

Set the limits for the display.

Set clipping limit for displays that needs to set a hardware clipping region.

Parameters:
x1 Top left x coordinate.
y1 Top left y coordinate.
x2 Bottom right x coordinate.
y2 Bottom right y coordinate.

Definition at line 351 of file gfx_hx8347a.c.

References gfx_set_bottom_right_limit(), and gfx_set_top_left_limit().

Referenced by gfx_draw_pixel(), gfx_generic_draw_filled_rect(), and gfx_get_pixel().

void gfx_set_orientation ( uint8_t  flags  ) 

Change display orientation.

Changes the display orientation for displays that support this. Check the driver specific documentation if this is supported.

The following masks are available and can be ORed together:

Note that rotating the screen 90 degress means switching X/Y _and_ mirroring one of the axes. It is not enough to just switch X/Y.

Parameters:
flags A bitmask of which axes to flip and/or switch.

Definition at line 233 of file gfx_hx8347a.c.

References GFX_FLIP_X, GFX_FLIP_Y, gfx_height, GFX_HX_FLIP_X, GFX_HX_FLIP_Y, GFX_HX_SWITCH_XY, gfx_read_register(), gfx_set_clipping(), GFX_SWITCH_XY, gfx_width, and gfx_write_register().

Referenced by gfx_init().

void gfx_set_top_left_limit ( gfx_coord_t  x,
gfx_coord_t  y 
)

Set the top-left limit for the display.

Set top-left clipping limit for displays that needs to set a hardware clipping region.

Parameters:
x Top left x coordinate.
y Top left y coordinate.

Definition at line 335 of file gfx_hx8347a.c.

References gfx_write_register().

Referenced by gfx_draw_line_pixel(), gfx_generic_get_pixmap(), gfx_generic_put_pixmap(), gfx_put_bitmap(), and gfx_set_limits().

void gfx_sync ( void   ) 

Synchronize access to the display.

In case of a graphics driver implementation that queues graphics operations, this function will make sure all pending operations are completed before exiting. That way, if you want to read pixels from the display, you can be sure that the display information is fresh and updated. For implementations that does not queue operations, this function may do nothing, but for portability it should always be called before reading pixels, or performing other operations which rely on all pending drawing operations having actually been completed.

Definition at line 207 of file gfx_hx8347a.c.


Variable Documentation

Current height of screen.

Definition at line 63 of file gfx_hx8347a.c.

Referenced by gfx_generic_draw_line(), gfx_get_height(), gfx_set_clipping(), and gfx_set_orientation().

Current width of screen.

Definition at line 62 of file gfx_hx8347a.c.

Referenced by gfx_generic_draw_line(), gfx_get_width(), gfx_set_clipping(), and gfx_set_orientation().

Generated on Thu Apr 29 15:18:24 2010 for display-training by  doxygen 1.6.3