Monochrome Graphic Display Source Code Driver Project
Section 02. Adding The Driver To Your Project

02. Adding The Driver To Your Project

a) Notes About Our Source Code Files

How We Organise Our Project Files

There are many different ways to organise your source code and many different opinions on the best method! We have chosen the following as a very good approach that is widely used, well suited to both small and large projects and simple to follow.

Each .c source code file has a matching .h header file. All function and memory definitions are made in the header file. The .c source code file only contains functions. The header file is separated into distinct sections to make it easy to find things you are looking for. The function and data memory definition sections are split up to allow the defining of local (this source code file only) and global (all source code files that include this header file) functions and variables. To use a function or variable from another .c source code file simply include the .h header file.

Variable types BYTE, WORD, SIGNED_WORD, DWORD, SIGNED_DWORD are used to allow easy compatibility with other compilers. Our projects include a ‘main.h’ global header file which is included in every .c source code file. This file contains the typedef statements mapping these variable types to the compiler specific types. You may prefer to use an alternative method in which case you should modify as required. Our main.h header file also includes project wide global defines.

This is much easier to see in use than to try and explain and a quick look through the included sample project will show you by example.

Please also refer to the resources section of the embedded-code.com web site for additional documentation which may be useful to you.

Modifying Our Project Files

We may issue new versions of our source code files from time to time due to improved functionality, bug fixes, additional device / compiler support, etc. Where possible you should try not to modify our source codes files and instead call the driver functions from other files in your application. Where you need to alter the source code it is a good idea to consider marking areas you have changed with some form of comment marker so that if you need to use an upgraded driver file its as easy as possible to upgrade and still include all of the additions and changes that you have made.

b) Step By Step Instructions

Move The Main Driver Files To Your Project Directory

The following files are the main driver files which you need to copy to your main project directory:

display.c – The main driver functions

display.h

display-model.c – The lower level functions tailored to a specific screen

display-model.h

If the driver includes the display-model files for your specific screen they should be copied from that screens sub-directory, or alternatively see later in this manual for details on creating your own version for a new screen model.

Move The Generic Global Defines File To You Project Directory

The generic global file is located in each driver sample project directory. Select the most suitable sample project based on the compiler used and copy the following file to your main project directory:

main.h - The embedded-code.com generic global file

Check Driver Definitions

Check the definitions in each of the following files to see if any need to be adjusted for the microcontroller / processor you are using, and your hardware connections.:-

display.h

display-model.h

Check the definitions in the following file and adjust if necessary for your compiler-

main.h

Application Requirements

In each .c file of your application that will use the driver functions include the ‘display.h’ file.

Your application needs to call the following function as part of its power-up initialisation:

display_initialise();

The display functions may now be called whenever you wish to update the display.

Bitmap Files

If using a C header file to store your bitmap files as part of the program memory then convert the files using the included bitmap converter application and store the cbitmaps.h output file in the following sub directory off your projects directory:

[your project directory]\bitmaps\output\

(You can simply store all of your source bitmap files in the subdirectory called [your project directory]\bitmaps\ and the bitmap converter application will then automatically create and store the output file in the \output\ sub directory)

If using a binary file to store your bitmap files then convert the files using the included bitmap converter application and provide the means to store them in your flash memory device. You will also need to provide the DISPLAY_FLASH_READ_FUNCTION function to allow the driver to read the files.

See later in this manual for details of how to create the bitmap output file from your source bitmaps.