Haris Spahic Ensar Muratovic

Dependencies:   N5110 mbed

main.cpp

Committer:
tim003
Date:
2014-05-08
Revision:
0:f42394c93668

File content as of revision 0:f42394c93668:

#include "mbed.h"
#include "N5110.h"
 
 
Serial pc(USBTX, USBRX);
N5110 lcd(dp4, dp24, dp23, dp25, dp2, dp6, dp18);


int X = 0;
int Y = 0;
 
void bckspc()
{
    if(X == 0 && Y == 0) return;
 
    if(X == 0)
    {
        Y -= 1;
        X = 84;
    }
 
    X -= 6;
    lcd.setXYAddress(X, Y);
    lcd.printChar(' ');
    lcd.setXYAddress(X, Y);
}
 
void CLS()
{
    lcd.clear();
    lcd.refresh();
    X = Y = 0;
    lcd.setXYAddress(X, Y);
}
 
void enter()
{
    if(Y == 5) Y = 0;
    else Y ++;
    X = 0;
    lcd.setXYAddress(X, Y);
}
 
void karakter(char c)
{
    lcd.printChar(c);
    X += 6;
    if(X == 84)
    {
        Y++;
        if(Y == 6) Y = 0;
        X = 0;
    }
}
 
int main()
{
    lcd.init();
    lcd.inverseMode();
    lcd.setXYAddress(0,0);
 
    while(1)
    {
        char c = pc.getc();
        if(c == '1') bckspc();
        else if(c == '2') CLS();
        else if(c == '3') enter();
        else karakter(c);
    }
 
}