tim010 tim010
/
Projekat15_pai_grupa6_tim010
Hadžić Muharem Mousavi Maedeh
Revision 0:0a484beeccaf, committed 2014-06-09
- Comitter:
- tim010
- Date:
- Mon Jun 09 10:10:21 2014 +0000
- Commit message:
- PAI-Projekat-Tema15-Grupa6-Tim010
Changed in this revision
diff -r 000000000000 -r 0a484beeccaf N5110.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/N5110.lib Mon Jun 09 10:10:21 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/eencae/code/N5110/#7701f0126ba7
diff -r 000000000000 -r 0a484beeccaf PS2.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PS2.lib Mon Jun 09 10:10:21 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/shintamainjp/code/PS2/#a57bbbec16b1
diff -r 000000000000 -r 0a484beeccaf main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jun 09 10:10:21 2014 +0000 @@ -0,0 +1,141 @@ +#include "mbed.h" +#include "N5110.h" +#include "PS2Mouse.h" + +//N5100 ekran(VCC,SCE,RST,D/C,MOSI,SCLK,LED) +N5110 ekran(dp4,dp24,dp23,dp25,dp2,dp6,dp18); +//CLKpin, DATApin +PS2Mouse mis(dp10, dp11); + +PS2Mouse::mouse_event_t event; + +int x=42,y=24; +int x1=x,y1=y; +int X,Y; +int pomX=0,pomY=0,brojac=0; +bool crtaj=false,brisi=true; + +void nacrtaj_pom(int a,int b,int d1,int d2){ + for(int i=0;i<=d1;i++){ + for(int j=0;j<=d2;j++){ + if(i==0||j==0||i==d1||j==d2){ + ekran.setPixel(a+i,b+j); + } + } + } + ekran.refresh(); +} + +void ocistiEkran(){ + ekran.clear(); + crtaj=false; + brisi=true; +} + +void pomjeranjeMisa(){ + if(x<0||x>83||y<0||y>47){ + if(x<0) x=0; + if(x>83) x=83; + if(y<0) y=0; + if(y>47) y=47; + return; + } + char znak=ekran.getPixel(x,y); + if(znak!=0){ + return; + } + if(brisi){ + ekran.clearPixel(x1,y1); + } + brisi=true; + ekran.setPixel(x,y); + x1=x; + y1=y; + ekran.refresh(); +} + + + +void oznaci(int a,int b){ + ekran.setPixel(a,b); + ekran.refresh(); + crtaj=true; + brisi=false; +} + +void nacrtaj(int a,int b){ + int d1=a-X; + if(d1<0) d1=-d1; + int d2=b-Y; + if(d2<0) d2=-d2; + int k1,k2; + if(a<X){ + k1=a; + } + else{ + k1=X; + } + + if(b<Y){ + k2=b; + } + else{ + k2=Y; + } + + nacrtaj_pom(k1,k2,d1,d2); + + crtaj=false; + brisi=false; +} + +DigitalOut enable(dp14); + +int main() { + enable=1; + ekran.init(); + ekran.setXYAddress(0,0); + pomjeranjeMisa(); + while(1) { + if (mis.processing(&event)) { + pomX+=event.x; + pomY+=event.y; + brojac++; + if(brojac==3){ + + if(pomX>0){ + x+=1; + } + else{ + x-=1; + } + + if(pomY>0){ + y-=1; + } + else{ + y+=1; + } + + pomjeranjeMisa(); + + pomX=pomY=brojac=0; + } + + if (event.left){ + if(!crtaj){ + X=x; + Y=y; + oznaci(X,Y); + } + else{ + nacrtaj(x,y); + } + } + if (event.right){ + ocistiEkran(); + } + + } + } +} \ No newline at end of file
diff -r 000000000000 -r 0a484beeccaf mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jun 09 10:10:21 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877 \ No newline at end of file