Graphic Display v1.0.0
Control any mochrome display, with any microcontroller, in any amount.
Loading...
Searching...
No Matches
Driver Definition and Creation

Driver definition for the Graphic Display library, this driver is the main reason why we can use any display with this library, you just need to create functions that are compatible with this structure. More...

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

Detailed Description

Driver definition for the Graphic Display library, this driver is the main reason why we can use any display with this library, you just need to create functions that are compatible with this structure.

>> Step by Step:

1. Create a folder inside drivers with the name of driver device.

Create a folder to place the source code of your driver, in this way, we can keep a clean and nice repository.

2. Create the .h and .c file for you device.

Suppose we create a driver for a fictional ss9090 device, we will create ss9090.h and ss9090.c files.

3. In header file, create the handle structure

The handle structure is used to keep data of a display, with this approach, we can have many displays our project requires, and this displays can be the same or different.

typedef struct{
// define the parameters that you need and functions to handle the device
}ss9090_t;

The most common parameters are the:

Other parameters, that's are optional, but recommended, if a function to mutex lock and unlock (useful for RTOS environments that need threadsafe), and Delay Milliseconds routine, some times, delay is mandatory in initialization.

Remember, the driver must be not glued with any chipset, this library must be compatible with any microcontroller.

4. Create routines

Here, we have the MANDATORY FUNCTIONS, must be implemented by you, following the fictional ss9090, we have this prototypes:

uint8_t SS9090_Init(ss9090_t *ss9090, ss9090_params_t *params);
uint8_t SS9090_Refresh(ss9090_t *ss9090);
uint8_t SS9090_WritePixel(ss9090_t *ss9090, uint32_t x, uint32_t y, bool color);
uint8_t SS9090_Fill(ss9090_t *ss9090, uint8_t color);

4.5 Test

At this point, test your library, check if initialization works, if the pixels are written into correct position, response speed, and everything else.

After you test your driver, you can move on to the next steps.

5. Add include into GraphicDisplay.h

Go to GraphicDisplay.h and include the new driver

#include "driver/ss9090/ss9090.h"

6. Create extern pointer to driver

Before the Public functions, you will see a piece of code with the Driver externs.

Here, you need to create the extern pointer to the driver, this will help developer to insert the driver on code. For SS9090, we write as follows the extern:

extern gd_driver_t* Gd_Driver_SS9090;
Struct that creates a driver for the display, holding the handle and functions that are private of th...
Definition GraphicDisplay.h:229

7. Instance the Driver Variable

Go to GraphicDisplay.c, in the beginning, you will see the structs containing the drivers, now, creates the instance attributing the function calls to the struct, and the pointer. Here, we use pointers, because they are more fast to pass as a parameters. For our fictional SS9090 driver, we have something similar to this:

// Diver for SS9090
gd_driver_t _Gd_Driver_SS9090Attr = {
.pHandle = NULL,
.fxnSetPixelColor = _SET_PIXEL_COLOR_TYPECAST SS9090_WritePixel,
.fxnFillFrameBuffer = _FILL_FRAME_BUFFER_TYPEFCAST SS9090_Fill,
.fxnRefreshDisp = _REFRESH_DISP_TYPECAST SS9090_Refresh,
.fxnSetOn = _SET_ON_TYPECASTAT NULL,
.fxnSetContrast = _SET_CONTRAST_TYPECAST NULL
};
gd_driver_t *Gd_Driver_SS9090 = &_Gd_Driver_SS9090Attr;
#define _FILL_FRAME_BUFFER_TYPEFCAST
Definition GraphicDisplay.c:23
#define _REFRESH_DISP_TYPECAST
Definition GraphicDisplay.c:24
#define _SET_CONTRAST_TYPECAST
Definition GraphicDisplay.c:26
#define _SET_ON_TYPECASTAT
Definition GraphicDisplay.c:25
#define _SET_PIXEL_COLOR_TYPECAST
Definition GraphicDisplay.c:22
void * pHandle
Handle of the display. The variable that holds all data of device.
Definition GraphicDisplay.h:231

8. Done

Your library is implemented, so, almost, all you need to do is test your implementation ans check if everything works as expected.

Any doubts, feel free to open issues into the repository.

Engineer: Pablo Jean Rozario.