Tarik Demirović Aida Pločo

Dependencies:   N5110 mbed

main.cpp

Committer:
tim003
Date:
2014-05-12
Revision:
0:dd95051d5d71

File content as of revision 0:dd95051d5d71:

#include "mbed.h"
#include "N5110.h"
#include <string>

Serial pc(USBTX, USBRX);
N5110 lcd(dp4,dp24,dp23,dp25,dp2,dp6,dp18);

DigitalOut enable (dp14);

int x = 0;
int y = 0;

void ocitaj()
{
    char buf[50];
    buf[0] = pc.getc();
    
    if(buf[0] == '1')
    {
        y++;
        if(y > 5) y = 0;
        x = 0;
    }

    else if(buf[0] == '2')
    {
        lcd.clear();
        x = 0;
        y = 0;
    }
    
    else if(buf[0] == '3')
    {
        x -= 5;
        if(x < 0 and y > 0){
            x = 82;
            y--;
        }
        
        lcd.printString(" ", x, y);
    }
    
    else
    {
        lcd.printString(buf, x, y);
        x += 5;
        if(x > 83)
        {
            x = 0;
            y++;
            if( y > 5) y = 0;
        }
    }
}

int main() {
    enable = 1;
    lcd.init();
    lcd.setXYAddress(0, 0);
    pc.attach(&ocitaj);
    while(1) {}
}