Graphic Display v1.0.0
Control any mochrome display, with any microcontroller, in any amount.
Loading...
Searching...
No Matches
GraphicDisplay.h File Reference

Main header file of Graphic Display Library, here we have the middle layer of the library. Where we works on drawing elements (texts, bitmaps and geometric forms). In drivers folder we have the low layer, composed by display controller drivers. The drivers are independet of the Graphic Display files, you can use them in more advanced libraries, like LVGL. This library is created to be flexible and scalable, allowing the engineer to use any amount of display, of any type. More...

#include <assert.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdbool.h>
#include <string.h>
#include "drivers/ssd1306/ssd1306.h"
#include "drivers/st7920/st7920.h"

Go to the source code of this file.

Data Structures

struct  gd_driver_t
 Struct that creates a driver for the display, holding the handle and functions that are private of the display driver. This allows the library to be very flexible and can handles any display. More...
 
struct  gd_font_t
 Structure to holds Fonts. The default fonts are defined in GraphicDisplay_Fonts.h. You can create your own fonts. A software that creates this fonts must be searched. More...
 
struct  gd_vertex_t
 Structure used to support the creation of polylines. In normal use, this is declared as an array, with X and Y points to build lines, between this lines. More...
 
struct  gd_t
 Handler of Graphic Display. Each display must need your own handler. Yes, this library supports multiples displays. More...
 
struct  gd_t::t_fxn
 
struct  gd_t::t_intern
 
struct  gd_params_t
 Parameters to initialize the Graphic Display Handler. More...
 

Macros

#define GD_INCLUDE_FONT_6x8
 
#define GD_INCLUDE_FONT_7x10
 
#define GD_INCLUDE_FONT_11x18
 
#define GD_INCLUDE_FONT_16x26
 
#define GD_INCLUDE_FONT_16x24
 
#define GD_INCLUDE_FONT_16x15
 

Typedefs

typedef void(* fxnGd_mtxLock) (void)
 Locks the mutex to prevent overrun and conflicts over threads in RTOS environments.
 
typedef void(* fxnGd_mtxUnlock) (void)
 Unlock the mutex after use on threadsafe need operations.
 

Enumerations

enum  gd_error_e { GD_OK , GD_FAIL }
 Errors that can be generated by library. More...
 
enum  gd_color_e { GD_BLACK , GD_WHITE }
 Defines the pixel color of the display we want to write. More...
 

Functions

gd_error_e GD_Init (gd_t *Gd, gd_params_t *params)
 Initializes the Graphic Display module, configured with the parameters provided.
 
gd_error_e GD_Fill (gd_t *Gd, gd_color_e color)
 Fill the Frame Buffer with the provided color.
 
gd_error_e GD_UpdateScreen (gd_t *Gd)
 Update and refresh the update screen with the data into Frame Buffer.
 
gd_error_e GD_DrawPixel (gd_t *Gd, uint32_t x, uint32_t y, gd_color_e color)
 Write a color into the desired pixel in the frame buffer.
 
gd_error_e GD_WriteChar (gd_t *Gd, char ch, const gd_font_t *Font, gd_color_e color)
 Write a character into a Frame Buffer, with the lines with the desired color.
 
gd_error_e GD_WriteString (gd_t *Gd, char *str, const gd_font_t *Font, gd_color_e color)
 Write a string into frame buffer, with the character lines with the desired color.
 
gd_error_e GD_SetCursor (gd_t *Gd, uint32_t x, uint32_t y)
 Set the cursor to the position X,Y.
 
gd_error_e GD_Line (gd_t *Gd, uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, gd_color_e color)
 Write a line into the frame buffer between (x1,y1) (x2,y2).
 
gd_error_e GD_DrawArc (gd_t *Gd, uint32_t x, uint32_t y, uint32_t radius, uint16_t start_angle, uint16_t sweep, gd_color_e color)
 Draw an arc into the frame buffer with center, radius, start angle, and sweep.
 
gd_error_e GD_DrawArcWithRadiusLine (gd_t *Gd, uint32_t x, uint32_t y, uint32_t radius, uint16_t start_angle, uint16_t sweep, gd_color_e color)
 Draw an arc into frame buffer with lines in the radius line.
 
gd_error_e GD_DrawCircle (gd_t *Gd, uint32_t par_x, uint32_t par_y, uint32_t par_r, gd_color_e color)
 Draw a complete circle with defined radius.
 
gd_error_e GD_FillCircle (gd_t *Gd, uint32_t par_x, uint32_t par_y, uint32_t par_r, gd_color_e par_color)
 Draw a circle filled with the provided color.
 
gd_error_e GD_Polyline (gd_t *Gd, gd_vertex_t *par_vertex, uint16_t par_size, gd_color_e color)
 Draw a polyline, composed by staigth lines connecting the points given by vertex array.
 
gd_error_e GD_DrawRectangle (gd_t *Gd, uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, gd_color_e color)
 Draw a Rectangle between the position (x1,y1) and (x2,y2). The rectangle is not filled, just four lines of a thickness of 1px.
 
gd_error_e GD_FillRectangle (gd_t *Gd, uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, gd_error_e color)
 Draw a filled rectangle between the pointes (x1,y1) and (x2,y2).
 
gd_error_e GD_DrawBitmap (gd_t *Gd, uint32_t x, uint32_t y, const unsigned char *bitmap, uint32_t w, uint32_t h, gd_color_e color)
 Draw a bitmap into the Frame Buffer. The bitmap is an array with the pixels on/off.
 
gd_error_e GD_SetContrast (gd_t *Gd, const uint8_t value)
 Set the contrast of the display, if are supported. If display doesn't have this routine, nothing will happens.
 
gd_error_e GD_SetDisplayOn (gd_t *Gd, bool on)
 Set display On or Off, if the display implements this routine.
 
bool GD_GetDisplayOn (gd_t *Gd)
 Gets the display On/Off state.
 

Variables

gd_driver_tGd_Driver_SSD1306
 SSD1306 Display Driver pointer.
 
gd_driver_tGd_Driver_ST7920
 ST7920 Display Driver poointer.
 

Detailed Description

Main header file of Graphic Display Library, here we have the middle layer of the library. Where we works on drawing elements (texts, bitmaps and geometric forms). In drivers folder we have the low layer, composed by display controller drivers. The drivers are independet of the Graphic Display files, you can use them in more advanced libraries, like LVGL. This library is created to be flexible and scalable, allowing the engineer to use any amount of display, of any type.

Author
Pablo Jean Rozario
Note
This library only works with monochrome displays.
Version
1.0.0
Date
2024-06-28

Macro Definition Documentation

◆ GD_INCLUDE_FONT_11x18

#define GD_INCLUDE_FONT_11x18

◆ GD_INCLUDE_FONT_16x15

#define GD_INCLUDE_FONT_16x15

◆ GD_INCLUDE_FONT_16x24

#define GD_INCLUDE_FONT_16x24

◆ GD_INCLUDE_FONT_16x26

#define GD_INCLUDE_FONT_16x26

◆ GD_INCLUDE_FONT_6x8

#define GD_INCLUDE_FONT_6x8

◆ GD_INCLUDE_FONT_7x10

#define GD_INCLUDE_FONT_7x10

Typedef Documentation

◆ fxnGd_mtxLock

typedef void(* fxnGd_mtxLock) (void)

Locks the mutex to prevent overrun and conflicts over threads in RTOS environments.

Precondition
Call a function where waits and locks the mutex.

◆ fxnGd_mtxUnlock

typedef void(* fxnGd_mtxUnlock) (void)

Unlock the mutex after use on threadsafe need operations.

Precondition
Call a function where mutex is freed.

Enumeration Type Documentation

◆ gd_color_e

enum gd_color_e

Defines the pixel color of the display we want to write.

Enumerator
GD_BLACK 

it's similar to a blank pixel, turned off

GD_WHITE 

Turns the pixel opaque, or turn it on

◆ gd_error_e

enum gd_error_e

Errors that can be generated by library.

Enumerator
GD_OK 

Operation was performed succefully

GD_FAIL 

Operation was failed, in most cases, is a wrong parameter