EFR32 Mighty Gecko 1 Software Documentation
efr32mg1-doc-5.1.2
|
Graphics Library.
Silicon Labs Graphics Library. Feature rich graphics library for memory constrained applications.
GLIB is a graphics library that can be used to draw pixels, common shapes, text or bitmaps to a display connected to an MCU. The main goal of this library is easy of use and small code and memory footprint. In this way GLIB can be used on even the smallest Cortex-M0 devices.
GLIB treats the display as a matrix of pixels which is a model of the physical display. This matrix is exposed to GLIB via an API called DMD (Dot Matrix Display). So in order to draw something on a physical display the user application needs to provide GLIB with a single implementation of the DMD interface. Sample DMD implementations are provided for the displays that are connected to the Silion Labs Starter Kits and the Silicon Labs Development Kits.
There are two things that must be initialized before GLIB can be used to draw pixels on the display. First the user needs to initialize the DMD implementation for the actual hardware display which is used. This initialization is display hardware specific.
After the DMD is initialized the user needs to initialize a GLIB_Context_t that can be used for all the drawing operations. A GLIB_Context_t structure is initialized using the GLIB_contextInit() function.
Every GLIB drawing function will require a GLIB_Context_t as one of the functions arguments. The GBLI context contains important configuration values that all the drawing functions use. It contains the foreground and background color, and it also contains information on what font to use when rendering text on the display.
GLIB represent color in a pixel as three 8 bit color values representing red, green and blue, giving the user support for a 24 bit color depth. The GLIB_rgbColor() function can be used to convert from distinct red, green and blue values to an 32-bit integer representing the color of single pixel. Similarly the GLIB_colorTranslate24bpp() function can be used to convert from the 32-bit integer representation into the 3 separate red, green and blue components. The 32-bit integer representation of a pixel color is used when configuring the foreground and background color.
GLIB also contains some common predefined colors for use in places where a 32-bit integer is used to represent the color. These predefined colors include White, Black, Brown, Orange, and many more. See the glib_color.h file for the full list of colors.
Some displays are monochrome, meaning that they only support 2 colors. When using GLIB to draw shapes on these displays the applications should use only the 2 colors White and Black.
GLIB contains functions for drawing common shapes to a display. Here is a list containing all the drawing functions.
These are functions that GLIB provides for drawing one pixel.
GLIB Supports fixed width font rendering. The functions GLIB_drawString() and GLIB_drawChar() are used to render text on the display.
GLIB provides these fonts for the user
To change the font the user calls GLIB_setFont() with a pointer to a GLIB_Font_t structure which describes the whole font. The GLIB_Font_t structure contains a pointer to the bitmap for each character and it describes attributes of the font like the width and height of each character and it also contains the bitmap of each character.
To draw an image or custom bitmaps on the display the GLIB_drawBitmap() function can be used. Note that the format of the bitmap depends on the DMD implementation of the display. The color displays typically use a bitmap format where each pixel is represented by 3 consecutive bytes representing the red, green and blue color components. While a monochrome display typically use a bitmap format where 1 byte represents 8 pixels where a 0 bit is white and a 1 bit is black.
This examples shows how to initialize a GLIB context and draw something on a display.
Data Structures | |
struct | __BMP_DataType |
BMP Data type structure to hold information about the bmp data returned. More... | |
struct | __BMP_Header |
BMP Module header structure. Must be packed to exact 54 bytes. More... | |
struct | __BMP_Palette |
BMP palette structure to hold palette pointer and size. More... | |
struct | __GLIB_Context_t |
GLIB Drawing Context (Multiple instances of GLIB_Context_t can exist) More... | |
struct | __GLIB_Font_t |
Font definition structure. More... | |
struct | __GLIB_Rectangle_t |
Rectangle structure. More... | |
Typedefs | |
typedef struct __BMP_DataType | BMP_DataType |
BMP Data type structure to hold information about the bmp data returned. | |
typedef struct __BMP_Header | BMP_Header |
typedef struct __BMP_Palette | BMP_Palette |
BMP palette structure to hold palette pointer and size. | |
typedef struct __GLIB_Context_t | GLIB_Context_t |
GLIB Drawing Context (Multiple instances of GLIB_Context_t can exist) | |
typedef enum __GLIB_Font_Class | GLIB_Font_Class |
Font classes. | |
typedef struct __GLIB_Font_t | GLIB_Font_t |
Font definition structure. | |
typedef struct __GLIB_Rectangle_t | GLIB_Rectangle_t |
Rectangle structure. | |
Enumerations | |
enum | __GLIB_Font_Class { InvalidFont = 0, FullFont, NumbersOnlyFont } |
Font classes. More... | |
Functions | |
int16_t | BMP_getBitsPerPixel (void) |
Get color depth (bits per pixel) More... | |
int32_t | BMP_getCompressionType (void) |
Get compression type. More... | |
int32_t | BMP_getDataOffset (void) |
Get the offset, i.e. starting address, of the byte where the bitmap data can be found. More... | |
int32_t | BMP_getFileSize (void) |
Get the fileSize in bytes. More... | |
int32_t | BMP_getHeight (void) |
Get height of BMP image in pixels. More... | |
int32_t | BMP_getImageDataSize (void) |
Get imageDataSize in bytes. More... | |
int32_t | BMP_getWidth (void) |
Get width of BMP image in pixels. More... | |
EMSTATUS | BMP_init (uint8_t *palette, uint32_t paletteSize, EMSTATUS(*fp)(uint8_t buffer[], uint32_t bufLength, uint32_t bytesToRead)) |
Initializes BMP Module. More... | |
EMSTATUS | BMP_readRawData (BMP_DataType *dataType, uint8_t buffer[], uint32_t bufLength) |
Fills buffer with raw data from BMP file. More... | |
EMSTATUS | BMP_readRgbData (uint8_t buffer[], uint32_t bufLength, uint32_t *pixelsRead) |
Reads in data from BMP file and fills buffer with RGB values. This function terminates either when the buffer is full, end of row is reached or end of file is reached. More... | |
EMSTATUS | BMP_reset (void) |
Makes the module ready for new bmp file. Reads in header from file, and checks if the provided bmp file is valid and supported. It reads in palette if BMP file is 8bpp. Uses function pointer set in BMP_init(). More... | |
EMSTATUS | GLIB_applyClippingRegion (const GLIB_Context_t *pContext) |
Apply the clipping region from the GLIB_Context_t in the DMD driver. More... | |
EMSTATUS | GLIB_clear (GLIB_Context_t *pContext) |
Clears the display with the background color of the GLIB_Context_t. More... | |
EMSTATUS | GLIB_clearRegion (const GLIB_Context_t *pContext) |
Clears the clipping region by filling it with the background color of the GLIB_Context_t. More... | |
void | GLIB_colorTranslate24bpp (uint32_t color, uint8_t *red, uint8_t *green, uint8_t *blue) |
Extracts the color components from the 32-bit color passed and puts them in the passed in 8-bits ints. The color is 24-bit RGB. More... | |
EMSTATUS | GLIB_contextInit (GLIB_Context_t *pContext) |
Initialize the GLIB_Context_t. More... | |
EMSTATUS | GLIB_displaySleep (void) |
Sets the display in sleep mode. More... | |
EMSTATUS | GLIB_displayWakeUp (void) |
Returns the display from sleep mode. More... | |
EMSTATUS | GLIB_drawBitmap (GLIB_Context_t *pContext, int32_t x, int32_t y, uint32_t width, uint32_t height, const uint8_t *picData) |
Draws a bitmap. More... | |
EMSTATUS | GLIB_drawChar (GLIB_Context_t *pContext, char myChar, int32_t x, int32_t y, bool opaque) |
Draws a char using the font supplied with the library. More... | |
EMSTATUS | GLIB_drawCircle (GLIB_Context_t *pContext, int32_t x, int32_t y, uint32_t radius) |
Draws a circle with center at x, y, and a radius. More... | |
EMSTATUS | GLIB_drawCircleFilled (GLIB_Context_t *pContext, int32_t x, int32_t y, uint32_t radius) |
Draws a filled circle with center at x, y, and a radius. More... | |
EMSTATUS | GLIB_drawLine (GLIB_Context_t *pContext, int32_t x1, int32_t y1, int32_t x2, int32_t y2) |
Draws a line from x1,y1 to x2, y2. More... | |
EMSTATUS | GLIB_drawLineH (GLIB_Context_t *pContext, int32_t x1, int32_t y1, int32_t x2) |
Draws a horizontal line from x1, y1 to x2, y2. More... | |
EMSTATUS | GLIB_drawLineV (GLIB_Context_t *pContext, int32_t x1, int32_t y1, int32_t y2) |
Draws a vertical line from x1, y1 to x1, y2. More... | |
EMSTATUS | GLIB_drawPartialCircle (GLIB_Context_t *pContext, int32_t xCenter, int32_t yCenter, uint32_t radius, uint8_t bitMask) |
Draws a partial circle with center at x, y, and a radius. More... | |
EMSTATUS | GLIB_drawPixel (GLIB_Context_t *pContext, int32_t x, int32_t y) |
Draws a pixel at x, y using foregroundColor defined in the GLIB_Context_t. More... | |
EMSTATUS | GLIB_drawPixelColor (GLIB_Context_t *pContext, int32_t x, int32_t y, uint32_t color) |
Draws a pixel at x, y using the color parameter. More... | |
EMSTATUS | GLIB_drawPixelRGB (GLIB_Context_t *pContext, int32_t x, int32_t y, uint8_t red, uint8_t green, uint8_t blue) |
Draws a pixel at x, y with color defined by red, green and blue 1 byte per channel. More... | |
EMSTATUS | GLIB_drawPolygon (GLIB_Context_t *pContext, uint32_t numPoints, const int32_t *polyPoints) |
Draws a polygon using Bresnham's Midpoint Line Algorithm. More... | |
EMSTATUS | GLIB_drawRect (GLIB_Context_t *pContext, const GLIB_Rectangle_t *pRect) |
Draws a rectangle outline defined by the passed in rectangle. More... | |
EMSTATUS | GLIB_drawRectFilled (GLIB_Context_t *pContext, const GLIB_Rectangle_t *pRect) |
Draws a filled rectangle defined by the passed in rectangle. The filled rectangle is drawn from (xMin, yMin) to (xMax, yMax), inclusive, of the rectangle passed in. More... | |
EMSTATUS | GLIB_drawString (GLIB_Context_t *pContext, const char *pString, uint32_t sLength, int32_t x0, int32_t y0, bool opaque) |
Draws a string using the font supplied with the library. More... | |
void | GLIB_normalizeRect (GLIB_Rectangle_t *pRect) |
Normalize the rectangle that is passed in. Sets yMin to the minimum value of yMin and yMax. Sets yMax to the maximum value of yMin and yMax. And the same for xMin and xMax. More... | |
bool | GLIB_rectContainsPoint (const GLIB_Rectangle_t *pRect, int32_t xCenter, int32_t yCenter) |
Checks if the point passed in is in the interior of the rectangle passed in. More... | |
EMSTATUS | GLIB_resetClippingRegion (GLIB_Context_t *pContext) |
Reset the GLIB_Context_t clipping region to the whole display. More... | |
EMSTATUS | GLIB_resetDisplayClippingArea (GLIB_Context_t *pContext) |
Reset the display driver clipping area to the whole display. More... | |
uint32_t | GLIB_rgbColor (uint8_t red, uint8_t green, uint8_t blue) |
Convert 3 uint8_t color components into a 24-bit color. More... | |
EMSTATUS | GLIB_setClippingRegion (GLIB_Context_t *pContext, const GLIB_Rectangle_t *pRect) |
Sets the clippingRegion of the passed in GLIB_Context_t. More... | |
EMSTATUS | GLIB_setFont (GLIB_Context_t *pContext, GLIB_Font_t *pFont) |
Set new font for the library. Note that GLIB defines a default font in glib.c. Redefine GLIB_DEFAULT_FONT to change the default font. More... | |
Variables | |
const GLIB_Font_t | GLIB_FontNarrow6x8 |
Narrow 6x8 pixels font containing characters and numbers. | |
const GLIB_Font_t | GLIB_FontNormal8x8 |
Normal 8x8 pixels font containing characters and numbers. | |
const GLIB_Font_t | GLIB_FontNumber16x20 |
Large 16x20 pixels font containing only numbers. | |
#define BMP_ERROR_BUFFER_TOO_SMALL (ECODE_BMP_BASE | 0x0020) |
Buffer provided is too small
Definition at line 62 of file bmp.h.
Referenced by BMP_init(), and BMP_readRgbData().
#define BMP_ERROR_END_OF_FILE (ECODE_BMP_BASE | 0x0010) |
End of bmp file is reached
Definition at line 60 of file bmp.h.
Referenced by BMP_readRawData(), and BMP_readRgbData().
#define BMP_ERROR_ENDIAN_MISMATCH (ECODE_BMP_BASE | 0x0003) |
#define BMP_ERROR_FILE_INVALID (ECODE_BMP_BASE | 0x0005) |
#define BMP_ERROR_FILE_NOT_RESET (ECODE_BMP_BASE | 0x0009) |
File not reset. Call BMP_reset()
Definition at line 58 of file bmp.h.
Referenced by BMP_readRawData(), and BMP_readRgbData().
#define BMP_ERROR_FILE_NOT_SUPPORTED (ECODE_BMP_BASE | 0x0004) |
#define BMP_ERROR_HEADER_SIZE_MISMATCH (ECODE_BMP_BASE | 0x0002) |
BMP_Header size in bytes is different from BMP_HEADER_SIZE
Definition at line 44 of file bmp.h.
Referenced by BMP_init().
#define BMP_ERROR_INVALID_ARGUMENT (ECODE_BMP_BASE | 0x0006) |
Argument passed to function is invalid
Definition at line 52 of file bmp.h.
Referenced by BMP_readRawData().
#define BMP_ERROR_INVALID_PALETTE_SIZE (ECODE_BMP_BASE | 0x0008) |
#define BMP_ERROR_IO (ECODE_BMP_BASE | 0x0001) |
#define BMP_ERROR_MODULE_NOT_INITIALIZED (ECODE_BMP_BASE | 0x0007) |
BMP module is not initialized. Call BMP_init()
Definition at line 54 of file bmp.h.
Referenced by BMP_readRawData(), BMP_readRgbData(), and BMP_reset().
#define BMP_ERROR_PALETTE_NOT_READ (ECODE_BMP_BASE | 0x0030) |
Bmp palette is not read
Definition at line 64 of file bmp.h.
Referenced by BMP_readRawData(), BMP_readRgbData(), and BMP_reset().
#define BMP_HEADER_SIZE (54) |
BMP Header Size in bytes
Definition at line 69 of file bmp.h.
Referenced by BMP_init(), and BMP_reset().
#define BMP_LOCAL_CACHE_LIMIT (3) |
#define BMP_LOCAL_CACHE_SIZE (BMP_CONFIG_LOCAL_CACHE_SIZE) |
BMP Local cache size
Definition at line 79 of file bmp.h.
Referenced by BMP_init(), and BMP_readRgbData().
#define BMP_OK 0x00000000 |
Successful call
Definition at line 38 of file bmp.h.
Referenced by BMP_getPressure(), BMP_getTemperature(), BMP_init(), BMP_readRawData(), BMP_readRgbData(), and BMP_reset().
#define GLIB_ERROR_FILE_NOT_SUPPORTED (ECODE_GLIB_BASE | 0x0007) |
#define GLIB_ERROR_INVALID_ARGUMENT (ECODE_GLIB_BASE | 0x0005) |
Invalid argument
Definition at line 200 of file glib.h.
Referenced by GLIB_applyClippingRegion(), GLIB_clear(), GLIB_clearRegion(), GLIB_contextInit(), GLIB_drawChar(), GLIB_drawCircleFilled(), GLIB_drawLine(), GLIB_drawLineH(), GLIB_drawLineV(), GLIB_drawPartialCircle(), GLIB_drawPixel(), GLIB_drawPixelColor(), GLIB_drawPixelRGB(), GLIB_drawPolygon(), GLIB_drawString(), GLIB_resetClippingRegion(), GLIB_resetDisplayClippingArea(), GLIB_setClippingRegion(), and GLIB_setFont().
#define GLIB_ERROR_INVALID_CHAR (ECODE_GLIB_BASE | 0x0002) |
Invalid char
Definition at line 194 of file glib.h.
Referenced by GLIB_drawChar(), and GLIB_drawString().
#define GLIB_ERROR_INVALID_CLIPPINGREGION (ECODE_GLIB_BASE | 0x0004) |
Invalid coordinates (ex. xMin > xMax)
Definition at line 198 of file glib.h.
Referenced by GLIB_setClippingRegion().
#define GLIB_ERROR_INVALID_FILE (ECODE_GLIB_BASE | 0x0009) |
#define GLIB_ERROR_IO (ECODE_GLIB_BASE | 0x0008) |
#define GLIB_ERROR_NOTHING_TO_DRAW (ECODE_GLIB_BASE | 0x0001) |
Function did not draw
Definition at line 192 of file glib.h.
Referenced by GLIB_drawChar(), GLIB_drawCircleFilled(), GLIB_drawLine(), GLIB_drawLineH(), GLIB_drawLineV(), GLIB_drawPartialCircle(), GLIB_drawPartialCirclePoints(), GLIB_drawPixel(), GLIB_drawPixelColor(), GLIB_drawPixelRGB(), GLIB_drawPolygon(), and GLIB_drawString().
#define GLIB_ERROR_OUT_OF_MEMORY (ECODE_GLIB_BASE | 0x0006) |
#define GLIB_OK 0x00000000 |
Successful call
Definition at line 190 of file glib.h.
Referenced by GLIB_clear(), GLIB_contextInit(), GLIB_drawChar(), GLIB_drawCircleFilled(), GLIB_drawLine(), GLIB_drawPartialCircle(), GLIB_drawPartialCirclePoints(), GLIB_drawPolygon(), GLIB_drawRect(), GLIB_drawString(), GLIB_resetClippingRegion(), and GLIB_setFont().
#define GLIB_OUT_OF_BOUNDS (ECODE_GLIB_BASE | 0x0003) |
Coordinates out of bounds
Definition at line 196 of file glib.h.
Referenced by GLIB_setClippingRegion().
#define NO_COMPRESSION (0) |
Use no compression
Definition at line 76 of file bmp.h.
Referenced by BMP_readRawData(), and BMP_readRgbData().
#define RLE8_COMPRESSION (1) |
Use RLE8 compression
Definition at line 74 of file bmp.h.
Referenced by BMP_readRawData(), and BMP_readRgbData().
enum __GLIB_Font_Class |
int16_t BMP_getBitsPerPixel | ( | void | ) |
Get color depth (bits per pixel)
Definition at line 952 of file bmp.c.
References __BMP_Header::bitsPerPixel.
int32_t BMP_getCompressionType | ( | void | ) |
Get compression type.
0 - No compression 1 - RLE 8bpp 2 - RLE 4bpp
Definition at line 970 of file bmp.c.
References __BMP_Header::compressionType.
int32_t BMP_getDataOffset | ( | void | ) |
Get the offset, i.e. starting address, of the byte where the bitmap data can be found.
Definition at line 998 of file bmp.c.
References __BMP_Header::dataOffset.
int32_t BMP_getFileSize | ( | void | ) |
Get the fileSize in bytes.
Definition at line 1012 of file bmp.c.
References __BMP_Header::fileSize.
int32_t BMP_getHeight | ( | void | ) |
Get height of BMP image in pixels.
Definition at line 938 of file bmp.c.
References __BMP_Header::height.
int32_t BMP_getImageDataSize | ( | void | ) |
Get imageDataSize in bytes.
Definition at line 984 of file bmp.c.
References __BMP_Header::imageDataSize.
int32_t BMP_getWidth | ( | void | ) |
Get width of BMP image in pixels.
Definition at line 924 of file bmp.c.
References __BMP_Header::width.
EMSTATUS BMP_init | ( | uint8_t * | palette, |
uint32_t | paletteSize, | ||
EMSTATUS(*)(uint8_t buffer[], uint32_t bufLength, uint32_t bytesToRead) | fp | ||
) |
Initializes BMP Module.
Support:
palette | Data buffer to hold palette. Required for 8bpp BMPs. |
paletteSize | Size of palette in bytes. If BMP is 8-bit, this potentially has to be 256 * 4 bytes. If the user knows that he only loads BMPs with N bytes, he can pass in paletteSize = N. Otherwise this value should be 256 * 4 = 1024 bytes to ensure that the palette is big enough for all 8-bits BMPs. |
fp | Function pointer that is used to read in bytes from BMP file. The function has to return an EMSTATUS and have the following parameter list (uint32_t buffer[], uint32_t bufLength, uint32_t bytesToRead). The function should fill (buffer) with (bytesToRead) bytes from the beginning. If it succeds it has to return BMP_OK, otherwise it should return BMP_ERROR_IO. When the function returns it should be ready to read from where it left off. |
Definition at line 99 of file bmp.c.
References BMP_ERROR_BUFFER_TOO_SMALL, BMP_ERROR_HEADER_SIZE_MISMATCH, BMP_HEADER_SIZE, BMP_LOCAL_CACHE_LIMIT, BMP_LOCAL_CACHE_SIZE, BMP_OK, __BMP_Palette::data, and __BMP_Palette::size.
EMSTATUS BMP_readRawData | ( | BMP_DataType * | dataType, |
uint8_t | buffer[], | ||
uint32_t | bufLength | ||
) |
Fills buffer with raw data from BMP file.
dataType | Data type struct which holds information about the data returned |
buffer | Buffer to be filled with raw data |
bufLength | Length of buffer |
Definition at line 850 of file bmp.c.
References __BMP_Header::bitsPerPixel, __BMP_DataType::bitsPerPixel, BMP_ERROR_END_OF_FILE, BMP_ERROR_FILE_NOT_RESET, BMP_ERROR_INVALID_ARGUMENT, BMP_ERROR_MODULE_NOT_INITIALIZED, BMP_ERROR_PALETTE_NOT_READ, BMP_OK, __BMP_Header::compressionType, __BMP_DataType::compressionType, __BMP_DataType::endOfRow, __BMP_Header::height, __BMP_Header::imageDataSize, NO_COMPRESSION, RLE8_COMPRESSION, __BMP_DataType::size, and __BMP_Header::width.
Referenced by BMP_readRgbData().
EMSTATUS BMP_readRgbData | ( | uint8_t | buffer[], |
uint32_t | bufLength, | ||
uint32_t * | pixelsRead | ||
) |
Reads in data from BMP file and fills buffer with RGB values. This function terminates either when the buffer is full, end of row is reached or end of file is reached.
buffer | Buffer to hold RGB values. |
bufLength | Buffer length in bytes. |
pixelsRead | Pointer to a uint32_t which holds how many bytes that are read. |
Definition at line 247 of file bmp.c.
References __BMP_Header::bitsPerPixel, BMP_ERROR_BUFFER_TOO_SMALL, BMP_ERROR_END_OF_FILE, BMP_ERROR_FILE_NOT_RESET, BMP_ERROR_MODULE_NOT_INITIALIZED, BMP_ERROR_PALETTE_NOT_READ, BMP_LOCAL_CACHE_SIZE, BMP_OK, BMP_readRawData(), __BMP_Header::compressionType, __BMP_Palette::data, __BMP_DataType::endOfRow, __BMP_Header::height, __BMP_Header::imageDataSize, NO_COMPRESSION, RLE8_COMPRESSION, __BMP_DataType::size, and __BMP_Header::width.
EMSTATUS BMP_reset | ( | void | ) |
Makes the module ready for new bmp file. Reads in header from file, and checks if the provided bmp file is valid and supported. It reads in palette if BMP file is 8bpp. Uses function pointer set in BMP_init().
Definition at line 131 of file bmp.c.
References __BMP_Header::bitsPerPixel, BMP_ERROR_ENDIAN_MISMATCH, BMP_ERROR_FILE_INVALID, BMP_ERROR_FILE_NOT_SUPPORTED, BMP_ERROR_INVALID_PALETTE_SIZE, BMP_ERROR_MODULE_NOT_INITIALIZED, BMP_ERROR_PALETTE_NOT_READ, BMP_HEADER_SIZE, BMP_OK, __BMP_Header::compressionType, __BMP_Palette::data, __BMP_Header::dataOffset, __BMP_Header::fileSize, __BMP_Header::headerSize, __BMP_Header::height, __BMP_Header::imageDataSize, __BMP_Header::magic, and __BMP_Palette::size.
EMSTATUS GLIB_applyClippingRegion | ( | const GLIB_Context_t * | pContext | ) |
Apply the clipping region from the GLIB_Context_t in the DMD driver.
pContext | Pointer to a GLIB_Context_t |
Definition at line 278 of file glib.c.
References __GLIB_Context_t::clippingRegion, GLIB_ERROR_INVALID_ARGUMENT, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.
Referenced by GLIB_clearRegion(), GLIB_drawBitmap(), GLIB_drawLineH(), GLIB_drawLineV(), GLIB_drawRectFilled(), and GLIB_setClippingRegion().
EMSTATUS GLIB_clear | ( | GLIB_Context_t * | pContext | ) |
Clears the display with the background color of the GLIB_Context_t.
pContext | Pointer to a GLIB_Context_t which holds the background color. |
Definition at line 163 of file glib.c.
References __GLIB_Context_t::backgroundColor, GLIB_colorTranslate24bpp(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_OK, GLIB_resetDisplayClippingArea(), and __GLIB_Context_t::pDisplayGeometry.
EMSTATUS GLIB_clearRegion | ( | const GLIB_Context_t * | pContext | ) |
Clears the clipping region by filling it with the background color of the GLIB_Context_t.
pContext | Pointer to a GLIB_Context_t which holds the background color. |
Definition at line 199 of file glib.c.
References __GLIB_Context_t::backgroundColor, __GLIB_Context_t::clippingRegion, GLIB_applyClippingRegion(), GLIB_colorTranslate24bpp(), GLIB_ERROR_INVALID_ARGUMENT, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.
void GLIB_colorTranslate24bpp | ( | uint32_t | color, |
uint8_t * | red, | ||
uint8_t * | green, | ||
uint8_t * | blue | ||
) |
Extracts the color components from the 32-bit color passed and puts them in the passed in 8-bits ints. The color is 24-bit RGB.
Example: color = 0x00FFFF00 -> red = 0xFF, green = 0xFF, blue = 0x00.
color | The color which is to be translated |
red | Pointer to a uint8_t holding the red component |
green | Pointer to a uint8_t holding the green component |
blue | Pointer to a uint8_t holding the blue component |
Definition at line 309 of file glib.c.
Referenced by GLIB_clear(), GLIB_clearRegion(), GLIB_drawLineH(), GLIB_drawLineV(), and GLIB_drawRectFilled().
EMSTATUS GLIB_contextInit | ( | GLIB_Context_t * | pContext | ) |
Initialize the GLIB_Context_t.
The context is set to default values and gets information about the display from the display driver.
pContext | Pointer to a GLIB_Context_t |
Definition at line 59 of file glib.c.
References __GLIB_Context_t::backgroundColor, Black, __GLIB_Context_t::foregroundColor, GLIB_DEFAULT_FONT, GLIB_ERROR_INVALID_ARGUMENT, GLIB_OK, GLIB_setClippingRegion(), GLIB_setFont(), __GLIB_Context_t::pDisplayGeometry, and White.
EMSTATUS GLIB_displaySleep | ( | void | ) |
EMSTATUS GLIB_displayWakeUp | ( | void | ) |
EMSTATUS GLIB_drawBitmap | ( | GLIB_Context_t * | pContext, |
int32_t | x, | ||
int32_t | y, | ||
uint32_t | width, | ||
uint32_t | height, | ||
const uint8_t * | picData | ||
) |
Draws a bitmap.
Sets up a bitmap that starts at x0,y0 and draws bitmap. The picture is a 24-bit bitmap. It is organized as 8-bit per color per pixel, and the color order is RGB. So picData is supposed to contain at least (width * height * 3) entries. picData has be organized like this: picData = { R, G, B, R, G, B, R, G, B ... }
pContext | Pointer to a GLIB_Context_t in which the bitmap is drawn. |
x | Start x-coordinate for bitmap |
y | Start y-coordinate for bitmap |
width | Width of picture |
height | Height of picture |
picData | Bitmap data 24-bit RGB |
Definition at line 51 of file glib_bitmap.c.
References GLIB_applyClippingRegion().
EMSTATUS GLIB_drawChar | ( | GLIB_Context_t * | pContext, |
char | myChar, | ||
int32_t | x, | ||
int32_t | y, | ||
bool | opaque | ||
) |
Draws a char using the font supplied with the library.
pContext | Pointer to the GLIB_Context_t |
myChar | Char to be drawn |
x | Start x-coordinate for the char (Upper left corner) |
y | Start y-coordinate for the char (Upper left corner) |
opaque | Determines whether to show the background or color it with the background color specified by the GLIB_Context_t. If opaque == true, the background color is used. |
Definition at line 51 of file glib_string.c.
References __GLIB_Context_t::backgroundColor, __GLIB_Font_t::charSpacing, __GLIB_Font_t::class, __GLIB_Font_t::cntOfMapElements, __GLIB_Context_t::font, __GLIB_Font_t::fontHeight, __GLIB_Font_t::fontRowOffset, __GLIB_Font_t::fontWidth, GLIB_drawPixel(), GLIB_drawPixelColor(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_INVALID_CHAR, GLIB_ERROR_NOTHING_TO_DRAW, GLIB_OK, NumbersOnlyFont, __GLIB_Font_t::pFontPixMap, and __GLIB_Font_t::sizeOfMapElement.
Referenced by GLIB_drawString().
EMSTATUS GLIB_drawCircle | ( | GLIB_Context_t * | pContext, |
int32_t | xCenter, | ||
int32_t | yCenter, | ||
uint32_t | radius | ||
) |
Draws a circle with center at x, y, and a radius.
Draws a circle using the Midpoint Circle Algorithm. See Wikipedia for algorithm. Algorithm is optimized to use only integer arithmetic, so no floating point arithmetic is needed.
pContext | Pointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color. |
xCenter | Center x-coordinate |
yCenter | Center y-coordinate |
radius | Radius of the circle |
Definition at line 51 of file glib_circle.c.
References GLIB_drawPartialCircle().
EMSTATUS GLIB_drawCircleFilled | ( | GLIB_Context_t * | pContext, |
int32_t | xCenter, | ||
int32_t | yCenter, | ||
uint32_t | radius | ||
) |
Draws a filled circle with center at x, y, and a radius.
Draws a circle using the Midpoint Circle Algorithm and using horizontal lines. See Wikipedia for algorithm.
pContext | Pointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color. |
xCenter | Center x-coordinate |
yCenter | Center y-coordinate |
radius | Radius of the circle |
Definition at line 142 of file glib_circle.c.
References GLIB_drawLineH(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_OK.
EMSTATUS GLIB_drawLine | ( | GLIB_Context_t * | pContext, |
int32_t | x1, | ||
int32_t | y1, | ||
int32_t | x2, | ||
int32_t | y2 | ||
) |
Draws a line from x1,y1 to x2, y2.
Draws a straight line using the Bresnham's Midpoint Line Algorithm. Checks for vertical and horizontal line.
pContext | Pointer to the GLIB_Context_t which holds the clipping region |
x1 | Start x-coordinate |
y1 | Start y-coordinate |
x2 | End x-coordinate |
y2 | End y-coordinate |
Definition at line 303 of file glib_line.c.
References GLIB_clipLine(), GLIB_drawLineH(), GLIB_drawLineV(), GLIB_drawPixel(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_OK.
Referenced by GLIB_drawPolygon().
EMSTATUS GLIB_drawLineH | ( | GLIB_Context_t * | pContext, |
int32_t | x1, | ||
int32_t | y1, | ||
int32_t | x2 | ||
) |
Draws a horizontal line from x1, y1 to x2, y2.
pContext | Pointer to a GLIB_Context_t in which the line is drawn. The line is drawn using the foreground color. |
x1 | Start x-coordinate |
y1 | Start y-coordinate |
x2 | End x-coordinate |
Definition at line 49 of file glib_line.c.
References __GLIB_Context_t::clippingRegion, __GLIB_Context_t::foregroundColor, GLIB_applyClippingRegion(), GLIB_colorTranslate24bpp(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, and __GLIB_Rectangle_t::yMax.
Referenced by GLIB_drawCircleFilled(), GLIB_drawLine(), and GLIB_drawRect().
EMSTATUS GLIB_drawLineV | ( | GLIB_Context_t * | pContext, |
int32_t | x1, | ||
int32_t | y1, | ||
int32_t | y2 | ||
) |
Draws a vertical line from x1, y1 to x1, y2.
pContext | Pointer to a GLIB_Context_t which the line is drawn. The line is drawn using the foreground color. |
x1 | Start x-coordinate |
y1 | Start y-coordinate |
y2 | End y-coordinate |
Definition at line 113 of file glib_line.c.
References __GLIB_Context_t::clippingRegion, __GLIB_Context_t::foregroundColor, GLIB_applyClippingRegion(), GLIB_colorTranslate24bpp(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.
Referenced by GLIB_drawLine(), and GLIB_drawRect().
EMSTATUS GLIB_drawPartialCircle | ( | GLIB_Context_t * | pContext, |
int32_t | xCenter, | ||
int32_t | yCenter, | ||
uint32_t | radius, | ||
uint8_t | bitMask | ||
) |
Draws a partial circle with center at x, y, and a radius.
Draws a partial circle using the Midpoint Circle Algorithm. Algorithm is optimized to use only integer arithmetic, so no floating point arithmetic is needed. The bitMask passed in decides which octant that should be drawn. The octants is numbered 1 to 8 in counterclockwise order.
Example: bitMask == 4 draws only pixels in 3. octant (00000100). bitMask == 5 draws only pixels in 3. and 1. octant (00000101).
pContext | Pointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color. |
xCenter | Center x-coordinate |
yCenter | Center y-coordinate |
radius | Radius of the circle |
bitMask | Bitmask which decides which octants pixels should be drawn. The LSB is 1. octant, and the MSB is 8. octant. |
Definition at line 84 of file glib_circle.c.
References GLIB_drawPartialCirclePoints(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_OK.
Referenced by GLIB_drawCircle().
EMSTATUS GLIB_drawPixel | ( | GLIB_Context_t * | pContext, |
int32_t | x, | ||
int32_t | y | ||
) |
Draws a pixel at x, y using foregroundColor defined in the GLIB_Context_t.
pContext | Pointer to a GLIB_Context_t which holds the foreground color and clipping region |
x | X-coordinate |
y | Y-coordinate |
Definition at line 350 of file glib.c.
References __GLIB_Context_t::clippingRegion, __GLIB_Context_t::foregroundColor, GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_rectContainsPoint().
Referenced by GLIB_drawChar(), GLIB_drawLine(), and GLIB_drawPartialCirclePoints().
EMSTATUS GLIB_drawPixelColor | ( | GLIB_Context_t * | pContext, |
int32_t | x, | ||
int32_t | y, | ||
uint32_t | color | ||
) |
Draws a pixel at x, y using the color parameter.
pContext | Pointer to a GLIB_Context_t which holds the clipping region |
x | X-coordinate |
y | Y-coordinate |
color | 32-bit int defining the RGB color. The 24 LSB defines the RGB color like this: RRRRRRRRGGGGGGGGBBBBBBBB. Example: Yellow = 0x00FFFF00 |
Definition at line 381 of file glib.c.
References __GLIB_Context_t::clippingRegion, GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_rectContainsPoint().
Referenced by GLIB_drawChar().
EMSTATUS GLIB_drawPixelRGB | ( | GLIB_Context_t * | pContext, |
int32_t | x, | ||
int32_t | y, | ||
uint8_t | red, | ||
uint8_t | green, | ||
uint8_t | blue | ||
) |
Draws a pixel at x, y with color defined by red, green and blue 1 byte per channel.
Example: To draw a yellow pixel at (10, 10). x = 10, y = 10, red = 0xFF, green = 0xFF, blue = 0x00
pContext | Pointer to a GLIB_Context_t which holds the clipping region |
x | X-coordinate |
y | Y-coordinate |
red | 8-bit red code |
green | 8-bit green code |
blue | 8-bit blue code |
Definition at line 421 of file glib.c.
References __GLIB_Context_t::clippingRegion, GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_rectContainsPoint().
EMSTATUS GLIB_drawPolygon | ( | GLIB_Context_t * | pContext, |
uint32_t | numPoints, | ||
const int32_t * | polyPoints | ||
) |
Draws a polygon using Bresnham's Midpoint Line Algorithm.
This function draws a line between all points outlining the polygon. The first and last point doesn't have to be the same. The function automatically draws a line from the start point to the end point.
pContext | Pointer to a GLIB_Context_t which the line is drawn. The lines are drawn using the foreground color. |
numPoints | Number of points in the polygon ( Has to be greater than 1 ) |
polyPoints | Pointer to array of polygon points. The points are laid out like this: polyPoints = {x1,y1,x2,y2 ... } Polypoints has to contain at least (numPoints * 2) entries |
Definition at line 46 of file glib_polygon.c.
References GLIB_drawLine(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_OK.
EMSTATUS GLIB_drawRect | ( | GLIB_Context_t * | pContext, |
const GLIB_Rectangle_t * | pRect | ||
) |
Draws a rectangle outline defined by the passed in rectangle.
pContext | Pointer to a GLIB_Context_t in which the rectangle is drawn. The rectangle is drawn using the foreground color. |
pRect | Pointer to a rectangle structure |
Definition at line 96 of file glib_rectangle.c.
References __GLIB_Context_t::clippingRegion, GLIB_drawLineH(), GLIB_drawLineV(), GLIB_normalizeRect(), GLIB_OK, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.
EMSTATUS GLIB_drawRectFilled | ( | GLIB_Context_t * | pContext, |
const GLIB_Rectangle_t * | pRect | ||
) |
Draws a filled rectangle defined by the passed in rectangle. The filled rectangle is drawn from (xMin, yMin) to (xMax, yMax), inclusive, of the rectangle passed in.
pContext | Pointer to a GLIB_Context_t in which the rectangle is drawn. The rectangle is filled with the foreground color. |
pRect | Pointer to a rectangle structure |
Definition at line 162 of file glib_rectangle.c.
References __GLIB_Context_t::clippingRegion, __GLIB_Context_t::foregroundColor, GLIB_applyClippingRegion(), GLIB_colorTranslate24bpp(), GLIB_normalizeRect(), __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.
EMSTATUS GLIB_drawString | ( | GLIB_Context_t * | pContext, |
const char * | pString, | ||
uint32_t | sLength, | ||
int32_t | x0, | ||
int32_t | y0, | ||
bool | opaque | ||
) |
Draws a string using the font supplied with the library.
pContext | Pointer to a GLIB_Context_t |
pString | Pointer to the string that is drawn |
sLength | number of characters in the string |
x0 | Start x-coordinate for the string (Upper left corner) |
y0 | Start y-coordinate for the string (Upper left corner) |
opaque | Determines whether to show the background or color it with the background color specified by the GLIB_Context_t. If opaque == 1, the background color is used. |
Definition at line 166 of file glib_string.c.
References __GLIB_Font_t::charSpacing, __GLIB_Font_t::class, __GLIB_Context_t::font, __GLIB_Font_t::fontHeight, __GLIB_Font_t::fontWidth, GLIB_drawChar(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_INVALID_CHAR, GLIB_ERROR_NOTHING_TO_DRAW, GLIB_OK, InvalidFont, and __GLIB_Font_t::lineSpacing.
void GLIB_normalizeRect | ( | GLIB_Rectangle_t * | pRect | ) |
Normalize the rectangle that is passed in. Sets yMin to the minimum value of yMin and yMax. Sets yMax to the maximum value of yMin and yMax. And the same for xMin and xMax.
pRect | Pointer to a rectangle structure |
Definition at line 66 of file glib_rectangle.c.
References __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.
Referenced by GLIB_drawRect(), and GLIB_drawRectFilled().
bool GLIB_rectContainsPoint | ( | const GLIB_Rectangle_t * | pRect, |
int32_t | x, | ||
int32_t | y | ||
) |
Checks if the point passed in is in the interior of the rectangle passed in.
If the point is on the edge of the rectangle the function returns 1.
pRect | Pointer to a rectangle structure |
x | X-coordinate of point |
y | Y-coordinate of point |
Definition at line 41 of file glib_rectangle.c.
References __GLIB_Rectangle_t::xMax, and __GLIB_Rectangle_t::yMax.
Referenced by GLIB_drawPixel(), GLIB_drawPixelColor(), and GLIB_drawPixelRGB().
EMSTATUS GLIB_resetClippingRegion | ( | GLIB_Context_t * | pContext | ) |
Reset the GLIB_Context_t clipping region to the whole display.
pContext | Pointer to a GLIB_Context_t |
Definition at line 255 of file glib.c.
References __GLIB_Context_t::clippingRegion, GLIB_ERROR_INVALID_ARGUMENT, GLIB_OK, __GLIB_Context_t::pDisplayGeometry, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.
EMSTATUS GLIB_resetDisplayClippingArea | ( | GLIB_Context_t * | pContext | ) |
Reset the display driver clipping area to the whole display.
pContext | Pointer to a GLIB_Context_t |
Definition at line 236 of file glib.c.
References GLIB_ERROR_INVALID_ARGUMENT, and __GLIB_Context_t::pDisplayGeometry.
Referenced by GLIB_clear().
uint32_t GLIB_rgbColor | ( | uint8_t | red, |
uint8_t | green, | ||
uint8_t | blue | ||
) |
Convert 3 uint8_t color components into a 24-bit color.
Example: red = 0xFF, green = 0xFF, blue = 0x00 -> 0x00FFFF00 = Yellow
red | Red component |
green | Green component |
blue | Blue component |
Definition at line 331 of file glib.c.
References BlueShift, GreenShift, and RedShift.
EMSTATUS GLIB_setClippingRegion | ( | GLIB_Context_t * | pContext, |
const GLIB_Rectangle_t * | pRect | ||
) |
Sets the clippingRegion of the passed in GLIB_Context_t.
pContext | Pointer to a GLIB_Context_t |
pRect | Pointer to a GLIB_Rectangle_t which is the clipping region to be set. |
Definition at line 131 of file glib.c.
References __GLIB_Context_t::clippingRegion, GLIB_applyClippingRegion(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_INVALID_CLIPPINGREGION, GLIB_OUT_OF_BOUNDS, __GLIB_Context_t::pDisplayGeometry, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.
Referenced by GLIB_contextInit().
EMSTATUS GLIB_setFont | ( | GLIB_Context_t * | pContext, |
GLIB_Font_t * | pFont | ||
) |
Set new font for the library. Note that GLIB defines a default font in glib.c. Redefine GLIB_DEFAULT_FONT to change the default font.
pContext | Pointer to the GLIB_Context_t |
pFont | Pointer to the new font |
Definition at line 223 of file glib_string.c.
References __GLIB_Context_t::font, GLIB_ERROR_INVALID_ARGUMENT, and GLIB_OK.
Referenced by GLIB_contextInit().