Elma Kusundzija Amela Spica

Dependencies:   N5110 mbed

main.cpp

Committer:
tim007
Date:
2014-05-08
Revision:
0:91269f323f72

File content as of revision 0:91269f323f72:

#include "mbed.h"
#include "N5110.h"

Serial pc(USBTX, USBRX); 
N5110 display(dp4,dp24,dp23,dp25,dp2,dp6,dp18);
int x=0;
int y=0;

void ispisi(char znak)
{
    display.printChar(znak);
    x = x + 6;
    if(x==84 && y==6)return;
    if(x==84)
    { 
        x = 0;
        y = y + 1;
    }
    display.setXYAddress(x,y);
}
void backspace()
{
    if(x==0 && y==0)
    {   
        /*x = 84;
        y = 40;*/
        return;
    }
    else if(x==0)
    {
        y = y - 1;
        x = 78;
    display.setXYAddress(x,y); 
    ispisi(' ');
    x=x-6;
    display.setXYAddress(x,y);
        
    }
    else if(x==78)
    {
        x=x-6;
        display.setXYAddress(x,y); 
    ispisi(' ');
    x=x-6;
    display.setXYAddress(x,y);
        }
    else
    {x=x-6;
    display.setXYAddress(x,y); 
    ispisi(' ');
    x=x-6;
    display.setXYAddress(x,y);
       
    }
    /*display.setXYAddress(x,y); 
    ispisi(' ');
    if(x==0){
        y=y-1;
        x=84;}
   else {x=x-6;}
    display.setXYAddress(x,y);*/
    
}
void DeleteAll()
{
    display.clear();
    display.refresh();
    x = y = 0;
    display.setXYAddress(x,y);
}
void Enter()
{
    if(y==40) return;
    else y = y + 1;
    x = 0;
    display.setXYAddress(x,y);
    
}
int main()
{
    display.init();
    display.normalMode();
    display.setXYAddress(0,0);
 
    while(1)
    {
        char znak = pc.getc();
        if(znak==',')
            backspace();
        else if(znak=='.')
            DeleteAll();
        else if(znak=='-')
            Enter();
         else ispisi(znak);
    }
 
}