ELEC2645 (2018/19) / Mbed 2 deprecated el16y2m

Dependencies:   mbed

Revision:
11:ef3d6696ae84
Parent:
10:3ecbf164c0d3
Child:
17:9f7ff626210b
--- a/main.cpp	Mon May 06 13:33:13 2019 +0000
+++ b/main.cpp	Thu May 09 02:52:04 2019 +0000
@@ -1,21 +1,15 @@
 #include "Level.h"
-#include "Initialization.h"
-
-
 
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
-
 Menu Menu;
 Level Level;
 Rotate Rotate;
 Release Release;
 Detect detect;
-Draw Draw;
+Pull Pull;
 logistic logistic;
-TNT TNT;
-Timer_cal Timer_cal;
+Tool Tool;
 Image Image;
-Initialization Initialization;
 InterruptIn A(PTB9);
 InterruptIn START(PTC5);
 InterruptIn B(PTD0);
@@ -23,28 +17,40 @@
 Gamepad Gamepad;
 
 void init();
-void init_value();
 
 int main()
-{
-    Initialization.init(lcd, A, B, Back, START, Gamepad);
-    Initialization.init_value(Rotate, Level);
+{   //initialize lcd, gamepad, and debut values
+    init();
     while(1) {
+        //this switch decides which level you are at, whenever you finish one level, you can break and change the value of variable "value". So switch can transfer you to another level.
         switch(level) {
             case 1:
-                Level.level_1(Menu, Image, lcd, Rotate, Release, detect, Draw, START, B, Back, A, TNT, Gamepad, logistic, Timer_cal, Level);
+                Level.level_1(Menu, Image, lcd, Rotate, Release, detect, Pull, START, B, Back, A, Gamepad, logistic, Level, Tool);
                 break;
 
             case 2:
                 Menu.TNT_m(lcd, A, B);
-                Level.level_2(Image, lcd, Rotate, Release, detect, Draw, A, B, TNT, logistic, Timer_cal, Level);
+                Level.level_2(Image, lcd, Rotate, Release, detect, Pull, A, B, logistic, Level, Tool);
                 break;
 
             case 3:
                 Menu.TNT_m(lcd, A, B);
-                Level.level_3(Image, lcd, Rotate, Release, detect, Draw, A, B, TNT, logistic, Timer_cal, Level);
+                Level.level_3(Image, lcd, Rotate, Release, detect, Pull, Gamepad, A, B, logistic, Level, Menu, Tool);
                 break;
         }
     }
 }
 
+void init()
+{   Gamepad.init();
+    lcd.init();
+    int ii;
+    for(ii=0; ii<3; ii=ii+1) {
+    Rotate.return_angle[ii]=PI;
+    Rotate.return_flag[ii]=1;
+    }
+    Level.g_Start_flag=0;
+    Level.g_Back_flag=0;
+    Level.g_B_flag=0;
+    Level.detector=0;
+}
\ No newline at end of file