A sample program for custom character in lcd

Dependencies:   TextLCD mbed

Fork of mbed_lcd_custom by The Electronics Nuke

main.cpp

Committer:
mderrant
Date:
2014-07-16
Revision:
3:afd06ac5821b
Parent:
2:92cbf103315b

File content as of revision 3:afd06ac5821b:

#include "mbed.h"
#include "TextLCD.h"

TextLCD lcd(PTA13, PTD2, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2); // PARA PLACA KL46F

int cur = 0;
int mov = 1;

char smile[] = {0,0,10,0,17,14,0,0};
char tongue[] = {0,0,10,0,17,14,2,0};
char hello[] = {4,12,30,31,17,17,14,0};
char comey[] = {0,0,30,31,21,17,14,0};

int main()
{
    lcd.createChar(0, smile);
    lcd.createChar(1, hello);
    lcd.createChar(2, comey);
    lcd.createChar(7, tongue);
    while(1)
    {
        lcd.clear();
        lcd.setCursor(cur,0);
        lcd.printf("HOLA");
        lcd.setCursor(0,1);
        lcd.putc(0);
        lcd.setCursor(4,1);
        lcd.putc(1);
        cur = cur + mov;
        if(cur >= 11 || cur <= 0)
            mov = -mov;
        wait(1);

        lcd.clear();
        lcd.setCursor(cur,1);
        lcd.printf("ADIOS");
        lcd.setCursor(0,1);
        lcd.putc(7);
        lcd.setCursor(4,1);
        lcd.putc(2);
        cur = cur + mov;
        if(cur >= 11 || cur <= 0)
            mov = -mov; 
        wait(1);
    }
}