A sample program for custom character in lcd

Dependencies:   TextLCD mbed

Fork of mbed_lcd_custom by The Electronics Nuke

main.cpp

Committer:
mbeded
Date:
2014-07-03
Revision:
0:310523b6696e
Child:
1:e6f698c0d7af

File content as of revision 0:310523b6696e:

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

TextLCD di(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x2);

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() 
{
    di.createChar(0, smile);
    di.createChar(1, hello);
    di.createChar(2, comey);
    di.createChar(7, tongue);
    while(1)
    {
        di.cls();
        di.setAddress(cur,0);
        di.printf("BELLO");
        di.setAddress(0,1);
        di.putc(0);
        di.setAddress(4,1);
        di.putc(1);
        cur = cur + mov;
        if(cur >= 11 || cur <= 0)
            mov = -mov;
        wait(1);

        di.cls();
        di.setAddress(cur,0);
        di.printf("BELLO");
        di.setAddress(0,1);
        di.putc(7);
        di.setAddress(4,1);
        di.putc(2);
        wait(1);
        cur = cur + mov;
        if(cur >= 11 || cur <= 0)
            mov = -mov;    
    }
}