Ahmed Hedait / Mbed 2 deprecated el16ah

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ahmedhedait
Date:
Mon May 07 17:35:34 2018 +0000
Parent:
12:48e30c78ed26
Child:
14:a6a905f2c430
Commit message:
Just added that the LCD clears the screen if the ball has reached its goal and show "Bravo!" as the message that the user ended the game.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat May 05 22:03:38 2018 +0000
+++ b/main.cpp	Mon May 07 17:35:34 2018 +0000
@@ -2,9 +2,13 @@
 #include "Joystick.h"
 #include "N5110.h"
 
+
+
 Joystick joystick(PTB10,PTB11,PTC16);
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
 
+
+
 int main( )
 {
     // first need to initialise display
@@ -15,12 +19,15 @@
     lcd.normalMode();      // normal colour mode
     lcd.setBrightness(0.5); // put LED backlight on 50%
 
+
     float circy = 5;
     float circx = 5;
     int a;
     int b;
     int c;
-    int d;
+    int d; 
+
+
 
 
     while(1) {
@@ -29,9 +36,11 @@
 
         lcd.clear();
 
+
         float mag = joystick.get_mag();
         float angle = joystick.get_angle();
 
+
         Direction dir = joystick.get_direction();
         //printf("direction %i\n", dir);
 
@@ -184,8 +193,7 @@
                 b = 25;
                 c = 18;
                 d = 1;
-            }
-            else if (i == 1) {
+            } else if (i == 1) {
                 a = 18;
                 b = 18;
                 c = 27;
@@ -197,8 +205,8 @@
                 b = 10;
                 c = 27;
                 d = 1;
-            } 
-            
+            }
+
             if (
                 (circy >= b - 2) && //top
                 (circy <= 1 + b) && //bottom
@@ -248,94 +256,12 @@
 
 
         if (circx > 63 & circy == 41) {
-            lcd.printString("  EndGame ",3,2);
+            lcd.clear(); 
+            lcd.printString("  Bravo!  ",3,2);
+            
         }
-
-
+        
         wait(.05);
         lcd.refresh();
     }
 }
-
-
-
-
-// TEST 100
-/* for (int i = 0; i <= 5; i++) {
-            //printf(" Stage  %d\n", i);
-
-            if(i == 0) {
-                a = 10;
-                b = 0;
-                c = 1;
-                d = 39;
-
-            } else if (i == 1) {
-                a = 18;
-                b = 32;
-                c = 1;
-                d = 15;
-            }
-
-            else if (i == 2) {
-                a = 36;
-                b = 25;
-                c = 1;
-                d = 25;
-            }
-
-            else if(i == 3) {
-                a = 45;
-                b = 0;
-                c = 1;
-                d = 11;
-            }
-
-            else if (i == 4) {
-                a = 45;
-                b = 18;
-                c = 1;
-                d = 30;
-            }
-
-            else if (i == 5) {
-                a = 55;
-                b = 6;
-                c = 1;
-                d = 45;
-            }
-
-            if (
-                (circy >= b - 2) && //top
-                (circy <= 1 + b + d) && //bottom
-                (circx >= a - 2) && //left
-                (circx <= a + 2)  //right
-            ) {
-                //left
-                if (circx <= a - 2) {
-                    if(circx >= a - 3) {
-                        circx = a - 3;
-                    }
-                }
-
-                //right
-                if(circx >= a + 2) {
-                    if(circx <= a + 3) {
-                        circx = a + 3;
-                    }
-                }
-
-                //top
-                if(circy <= b - 2) {
-                    if(circy >= b - 3)
-                        circy = b - 3;
-                }
-
-                //bottom
-                if(circy >= b + d) {
-                    if(circy <= 2 + b + d)
-                        (circy = 2 + b + d);
-                }
-            }
-        }
-        */
\ No newline at end of file