Kenan Mahmutović Edis Kunić

Dependencies:   N5110 mbed

main.cpp

Committer:
tim010
Date:
2014-04-24
Revision:
0:46f889af93c0

File content as of revision 0:46f889af93c0:

#include "mbed.h"
#include "N5110.h"
#include <string>
AnalogIn VRx(dp11);
AnalogIn VRy(dp10);
DigitalIn SW(dp9);
DigitalOut enable(dp14);
//Deklaracija LCD objekta
//N5110 lcd(VCC,SCE,RST,D/C,MOSI,SCLK,LED)
N5110 lcd(dp4,dp24,dp23,dp25,dp2,dp6,dp18);
 
//Digitalni izlaz za deaktivaciju LED buffera

void funkcijakrug(int x, int y){
    lcd.clear();
    lcd.setPixel(x,y);
    int a=-1;
    for(int i=0;i<3;i++){
        lcd.setPixel(x-3,y+a);
        a++;
    }
    lcd.setPixel(x-2,y-2);
    lcd.setPixel(x-2,y+2);
    lcd.setPixel(x-1,y-3);
    lcd.setPixel(x-1,y+3);
    lcd.setPixel(x,y-3);
    lcd.setPixel(x,y+3);
    lcd.setPixel(x+1,y-3);
    lcd.setPixel(x+1,y+3);
    lcd.setPixel(x+2,y-2);
    lcd.setPixel(x+2,y+2);
    a=-1;
    for(int i=0;i<3;i++){
        lcd.setPixel(x+3,y+a);
        a++;
    }
    lcd.refresh();
}
int main(){
int x=42, y=24;
enable=1;
lcd.init();
lcd.setXYAddress(0,0);
funkcijakrug(x,y);
while(1){
    int prva=int(VRx);
    int druga=(VRx-prva)*10;
    char c,b;
    switch (prva){
        case 0: c='0'; break;
        case 1: c='1'; break;
        case 2: c='2'; break;
        case 3: c='3'; break;
    }    
    switch (druga){
        case 0: b='0'; break;
        case 1: b='1'; break;
        case 2: b='2'; break;
        case 3: b='3'; break;
        case 4: b='4'; break;
        case 5: b='5'; break;
        case 6: b='6'; break;
        case 7: b='7'; break;
        case 8: b='8'; break;
        case 9: b='9'; break;
    }
    lcd.printChar(c);
    lcd.printChar(',');
    lcd.printChar(b);
    lcd.setXYAddress(0,0);
       
    lcd.printString(c+","+b,0,0);   
        if (VRx<1.0/3.0){
            if(x>3)x=x-1;
            funkcijakrug(x,y);
        }else if (VRx<2.0/3.0) {
            funkcijakrug(x,y);
        }else {
            if(x<80) x=x+1;
            funkcijakrug(x,y);
        }
        if (VRy<1.0/3.0) {
            if(y>3)y=y-1;
            funkcijakrug(x,y);
        }
        else if (VRy<2.0/3.0){ funkcijakrug(x,y);}
        else {
            if(y<44) y=y+1;
            funkcijakrug(x,y);
        }
        if (SW==1) wait(5);
        wait(0.05);
    }
}