LV7 Zad01 priprema Sumejja Porca

Dependencies:   N5110 mbed

Files at this revision

API Documentation at this revision

Comitter:
tim008
Date:
Mon Apr 28 11:46:20 2014 +0000
Parent:
0:b7c72ff94dc1
Commit message:
LV7 Zad01 priprema; Sumejja Porca;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Apr 28 10:45:20 2014 +0000
+++ b/main.cpp	Mon Apr 28 11:46:20 2014 +0000
@@ -30,8 +30,9 @@
 //funkcija za pravljenje pravougaonika kad vec imamo tacke dijagonale
 void makeRectangle()
 {
+    taster1.disable_irq();
     int Ax, Ay, Bx, By, Cx, Cy, Dx, Dy;
-    if( xd1  <= xd2 && yd1 > yd2 )
+    if( xd1  < xd2 && yd1 > yd2 )
     {
         Bx = xd2;
         By = yd2;
@@ -43,7 +44,7 @@
         Cx = Bx;
         Cy = Dy;
     }
-    else if(  xd2  <= xd1 && yd2 > yd1 ) 
+    else if(  xd2  < xd1 && yd2 > yd1 ) 
     {
         Bx = xd1;
         By = yd1;
@@ -55,7 +56,7 @@
         Cx = Bx;
         Cy = Dy;    
     }
-    else if ( xd1 < xd2 && yd1 <= yd2 )
+    else if ( xd1 < xd2 && yd1 < yd2 )
     {
         Ax = xd1;
         Ay = yd1;
@@ -67,7 +68,7 @@
         Dx = Ax;
         Dy = Cy;
     }
-    else if ( xd2 < xd1 && yd2 <= yd1 )
+    else if ( xd2 < xd1 && yd2 < yd1 )
     {
         Ax = xd2;
         Ay = yd2;
@@ -89,12 +90,15 @@
         lcd.setPixel(j,i);
         lcd.refresh();
     }
+    taster1.enable_irq();
 }
 
 // funkcija za dodavanje tacke dijagonale/ pravljenje pravougaonika
+
 void setPoint()
 {
- if(timer.read() <= 0.001)
+ if( timer.read() < 0.001) return;
+ if(timer.read() <= 0.01)
  {
      lcd.clear();
      xd1 = -1;
@@ -117,7 +121,6 @@
      timer.reset();
      return;
  }  
- timer.reset();
  if( xd1 < 0 )
  {
      xd1 = x2;
@@ -127,6 +130,8 @@
  }
  else 
  {
+     if( xd2 != xd1 && yd2 != yd1)
+     {
      xd2 = x2;
      yd2 = y1;
      makeRectangle();
@@ -134,13 +139,15 @@
      yd1 = -1;
      xd2 = -1;
      yd2 = -1;
-
+     }
  }
+  timer.reset();
  }
  
 int main()
 {
     timer.start();
+    taster1.rise(&setPoint);
      enable=1;
  
     // inicijalizacija displaya