tim004 tim004
/
LV7_Grupa3_Tim004_Zadatak1
Mirza Omerović Predrag Simanić
Revision 0:b50b7e510883, committed 2014-04-28
- Comitter:
- tim004
- Date:
- Mon Apr 28 15:57:22 2014 +0000
- Commit message:
- LV7 - PAI- Grupa3- Tim004-Zadatak1
Changed in this revision
diff -r 000000000000 -r b50b7e510883 N5110.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/N5110.lib Mon Apr 28 15:57:22 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/eencae/code/N5110/#adb79338d40f
diff -r 000000000000 -r b50b7e510883 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 28 15:57:22 2014 +0000 @@ -0,0 +1,139 @@ +#include "mbed.h" +#include "N5110.h" + +#define MAXWIDTH 84 +#define MAXHEIGHT 48 + +Timer t; +DigitalOut enable(dp14); +InterruptIn taster(dp1); + int X=0;int Y=0; + int x1=90,y1=90,x2,y2; +AnalogIn VRx(dp11); +AnalogIn VRy(dp10); +DigitalIn SW(dp9); + +N5110 lcd (dp4, dp24, dp23, dp25, dp2, dp6, dp18); + +void cursor(int x, int y) +{ + for(int i=x; i<=x+2; i++) + for(int j=y; j<=y+2; j++) + {lcd.setXYAddress(0,0); + lcd.setPixel(i,j); + lcd.refresh(); + } +} + +void brisi(int x, int y) +{ + for(int i=x; i<=x+2; i++) + for(int j=y; j<=y+2; j++) + { + lcd.clearPixel(i,j); + lcd.refresh(); + } +} + +void Lijevo(int &x, int &y) +{ + if(x>0){ + brisi(x,y); + x=x-1; + cursor(x,y); + + } +} + +void Desno(int &x, int &y) +{ + if(x<81){ + brisi(x,y); + x=x+1; + cursor(x,y); + } +} + +void Gore(int &x, int &y) +{ + if(y>0){ + brisi(x,y); + y=y-1; + cursor(x,y); + } +} + +void Dole(int &x, int &y) +{ + if(y<45){ + brisi(x,y); + y=y+1; + cursor(x,y); + } +} + + void line(int x0,int y0,int x2,int y2) + { + + int dx=x2-x0,dy=y2-y0; + int p=2*dy-dx,i=dx; + while(i!=0) + { + cursor(x0,y0); + if(p<0) + { + x0=x0+1; + p=p+2*dy; + } + else + { + x0=x0+1; + y0=y0+1; + p=p+2*dy-2*dx; + } + if(i>=0) i--; + else i++; + } +} + + +static int a =1; +void tacka() +{ + + if(t.read_ms() > 400) + if(a%2!=0) {x1=X; y1=Y;a++;} + else{ + x2=X; y2=Y; + line(x1,y1,x2,y2); + wait(5); + lcd.clear(); + lcd.setXYAddress(0,0); + x1=90; y1=90; lcd.setXYAddress(0,0); X=0; Y=0;a=1; + + } + t.reset(); +} + +int main(){ + + enable = 1; + SW.mode(PullUp); + t.start(); + lcd.init(); + + + lcd.setXYAddress(X,Y); + cursor(X,Y); + taster.rise(&tacka); + while(1){ + if(VRx < 1.0/3.0) Lijevo(X,Y); + else if(VRx > 2.0/3.0) Desno(X,Y); + + if(VRy < 1.0/3.0) Gore(X,Y); + else if(VRy > 2.0/3.0) Dole(X,Y); + + cursor(x1,y1); + + } +} \ No newline at end of file
diff -r 000000000000 -r b50b7e510883 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Apr 28 15:57:22 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e \ No newline at end of file