LCDiesel: Yet another AVR HD44780 LCD library

I created an HD44780 LCD library for the AVR architecture today. There were a ton already, and mine is based off of one by Peter Fleury. I added a couple cool little features, and decided it needed to be on github to allow people to improve it and access it easier.

LCDiesel on Github

Here’s a quick code example using the library:

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include "lcd.h"

// Include the chars we want
#define CHAR_USE_OPEN_RECTANGLE
#define CHAR_USE_HEART
#include "chars.h"

int main(void)
{
    /* initialize display, cursor off */
    lcd_init(LCD_DISP_ON);
    lcd_command(LCD_FUNCTION_4BIT_2LINES );
    lcd_clrscr();

    // Testing if x,y are set wrong
    lcd_gotoxy(3, 1);

    // Load character
    lcd_custom_char_p(0x00, _char_open_rectangle);
    lcd_custom_char_p(0x01, _char_heart);

    // We better still be at 3, 1
    lcd_putc(0);
    lcd_putc(1);
    lcd_putc(255);

    for(;;);
}

See how easy it is to define custom characters? Cool, huh? I think so. The heart and rectangle bit vectors are in chars.h, and are only compiled in when they are defined, keeping code size down. Here’s how I have it hooked up on the breadboard (and the output of the program above):

Wiring


2 thoughts on “LCDiesel: Yet another AVR HD44780 LCD library

  1. Joe Hance

    Nice library. I note that the Adruino LCD library has an option to NOT use the “RW” line. You wire RW to GND. You can get away with this if you have only a single LCD on the data lines.

    It saves an I/O line (always scarce). Have you considered add this as an option?

    Thanks…

  2. Erik Post author

    I could probably do that. If you’re feeling frisky, you could clone my github repo, make the necessary changes, and send me a pull request and I’d be glad to roll it in. Or, you could send me a patch file. Otherwise, I’m not likely to get around to it any time soon. Thanks, though!

Leave a Reply

Your email address will not be published. Required fields are marked *