tim007 tim007
/
Projekat_Tim007_Grupa3
Goro Faruk Predrag Simanić
main.cpp
- Committer:
- tim007
- Date:
- 2014-05-19
- Revision:
- 0:b89e95e065ac
File content as of revision 0:b89e95e065ac:
#include "mbed.h" #include "N5110.h" #define MAXWIDTH 84 #define MAXHEIGHT 48 Timer t; DigitalOut enable(dp14); int X=0;int Y=0; int x1=90,y1=90,x2,y2; AnalogIn VRy2(dp11); AnalogIn VRy1(dp10); DigitalIn SW1(dp9), SW2(dp13); N5110 lcd (dp4, dp24, dp23, dp25, dp2, dp6, dp18); void palija1(int x, int y) { for(int i=x; i<=x+2; i++) for(int j=y; j<=y+2; j++) { lcd.setPixel(i,j); lcd.setPixel(i,j+1); lcd.setPixel(i,j+2); lcd.refresh(); } } void palija2(int x, int y) { for(int i=x; i<=x+2; i++) for(int j=y; j<=y+2; j++) { lcd.setPixel(i,j); lcd.setPixel(i,j+1); lcd.setPixel(i,j+2); lcd.refresh(); } } void Teren() { lcd.setXYAddress(0,0); int j =5; for(int i =5;i<= 75;i++) //gornji desno... radi { lcd.setPixel(i,j); lcd.refresh(); } int k=75; for(int i=5;i<=40;i++) //od gore, prema dole ... radi { lcd.setPixel(k,i); lcd.refresh(); } j=40; for(int i =75;i>=5;i--) //donja linija .. radi { lcd.setPixel (i,j); lcd.refresh(); } k=5; for(int i = 40; i>= 5;i--) // Ne radi... { lcd.setPixel(k,i); lcd.refresh(); } //sredina j=40; for(int i=5;i<=40;i++) { lcd.setPixel(j,i); 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 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); } } int main(){ lcd.setXYAddress(0,0); enable = 1; SW1.mode(PullUp); SW2.mode(PullUp); t.start(); lcd.init(); Teren(); while(1){ if(VRy1 < 1.0/3.0) Gore(X,Y); else if(VRy1 > 2.0/3.0) Dole(X,Y); if(VRy2 < 1.0/3.0) Gore(X,Y); else if(VRy2 > 2.0/3.0) Dole(X,Y); palija1(X,Y); palija2(X,Y); } }