Haskovic Nedzad Klacar Armin

Dependencies:   N5110 mbed

Files at this revision

API Documentation at this revision

Comitter:
tim007
Date:
Thu Apr 24 15:59:35 2014 +0000
Commit message:
Grupa6_LV7_PAI_Tim007

Changed in this revision

N5110.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/N5110.lib	Thu Apr 24 15:59:35 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/eencae/code/N5110/#adb79338d40f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Apr 24 15:59:35 2014 +0000
@@ -0,0 +1,120 @@
+#include "mbed.h"
+#include "N5110.h"
+  
+//Analogni ulazi sa dzojstika
+AnalogIn    VRx(dp11);
+AnalogIn    VRy(dp10);
+//Taster sa dzojstika
+DigitalIn   SW(dp17);
+//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
+DigitalOut enable(dp14);
+
+void baklava(int x, int y){
+    lcd.clear();
+    lcd.refresh();
+    lcd.setPixel(x,y);
+    lcd.setPixel(x+1,y); 
+    lcd.setPixel(x+2,y);
+    lcd.setPixel(x-1,y);  
+    lcd.setPixel(x-2,y); 
+    lcd.setPixel(x,y+1);
+    lcd.setPixel(x+1,y+1);
+    lcd.setPixel(x-1,y+1);
+    lcd.setPixel(x,y+2);
+    lcd.setPixel(x,y-1);
+    lcd.setPixel(x+1,y-1);
+    lcd.setPixel(x-1,y-1);
+    lcd.setPixel(x,y-2);
+    lcd.refresh();
+}
+
+void viljuska(int x,int y) {
+    lcd.refresh();
+    lcd.setPixel(x,y);
+    lcd.setPixel(x+1,y);
+    lcd.setPixel(x-1,y);
+    lcd.setPixel(x,y+1);
+    lcd.setPixel(x,y+2);
+    lcd.setPixel(x,y-1);
+    lcd.setPixel(x+2,y-1);
+    lcd.setPixel(x-2,y-1);
+    lcd.refresh();
+    
+    
+    }
+int main()
+{
+    enable=1;
+ static int x(0),y(0);
+ static int i(0),j(0);
+    // inicijalizacija displeja
+    lcd.init();
+    lcd.setXYAddress(0,0);
+    SW.mode(PullUp);
+ int a[10]={4,5,6,7,8,9,10,11,12,13};
+  int b[10]={3,4,5,6,7,8,9,10,11,12};
+     while(1)
+    {   
+     if (VRx<1.0/3.0) 
+     {
+         x=x-3;
+     baklava(x,y); 
+     ++i;
+     if(i>9) i=9;
+     viljuska(x+a[i],y+b[j]);
+    }
+     else if (VRx<2.0/3.0) 
+    {
+    baklava(x,y); 
+    if(i>9) i=9;
+    viljuska(x+a[i],y+b[j]);
+    }
+    else 
+    {x=x+3;
+    baklava(x,y);
+    ++i;
+    if(i>9) i=9;
+    viljuska(x+a[i],y+b[j]); }
+    wait(0.05);
+    
+    if (VRy<1.0/3.0) 
+     {
+      y=y-3;
+      baklava(x,y); 
+      ++j;
+      if(j>9) j=9;
+     viljuska(x+a[i],y+b[j]);
+ 
+    }
+     else if (VRy<2.0/3.0) 
+    {
+    baklava(x,y); 
+    if(j>9) j=9;
+    viljuska(x+a[i],y+b[j]);
+  
+    }  
+    else    
+    {
+     y=y+3;
+     baklava(x,y); 
+     ++j;
+    if(j>9) j=9;
+    viljuska(x+a[i],y+b[j]);
+    }
+    
+    if (VRx<2.0/3.0 && VRy<2.0/3.0){
+           baklava(x,y); 
+           --i;
+           --j;
+           if (i<0) i=0;
+           if (j<0) j=0;
+    viljuska(x+a[i],y+b[j]);
+       } 
+       wait(0.05); 
+    }
+}
+  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Apr 24 15:59:35 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e
\ No newline at end of file