Microcontroller Driver - LDC Display

Objective


Control a 16x2 LCD Display using a microcontroller.
Make the code as library since it is something that has to be done often and with different microcontrollers.
Make the library interrupt based so that use of resources is minimized.


The Arduino default library by contrast is blocking and uses wait to send comands to the display, making it painfully slow.

Architecture

This library is interrupt and queue based. The user calls API that write on a buffer. The driver is called periodically in interrupt and takes care of synchronizing the physical display with the buffer.
This approach has the advantage of decoupling the API with the display.



This is useful for instance if the user calls the display update function inside a fast loop. The write operation does not impact the loop speed too much since it's just a memory write, and the actual IO operation will be handled in background. The system will ignore multiple older write on a location and update a character on the screen with only the latest entry.

Example

In the H file tell the library what pins are used and if the LCD is in 4-bit H or L mode or 8 bit mode.

In the initialization configure the designated pins as output, strobe power on the LCD display and call the driver init procedure. It will take care of configuring the LCD display module with special one time commands.

In the main loop, or in an ISR call the ldc_update() driver function. This takes care of updating the LCD display in background.

This s it. Now the user can call the lcd API inside the code as needed.

Library

GitHub Repository



Library Header


Library Code

No comments: