el15mh 200929957

Dependencies:   mbed

Revision:
5:55eee1d71c1d
Parent:
4:66ab008f7b06
Child:
6:84572bbd9c5c
diff -r 66ab008f7b06 -r 55eee1d71c1d main.cpp
--- a/main.cpp	Tue Apr 04 10:30:56 2017 +0000
+++ b/main.cpp	Fri Apr 07 10:29:30 2017 +0000
@@ -4,27 +4,38 @@
 #include "Menu.h"
 #include "Maze.h"
 #include "Ball.h"
+#include "MazeEngine.h"
 
 // CREATE OBJECTS //
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+MazeEngine engine;
 Gamepad pad;
 Menu menu;
 Maze maze;
 Ball ball;
 
+// STRUCT FOR INPUT //
+struct input {
+    
+    Direction direction;
+    float magnitude;
+};
+
 // FUNCTION PROTOTYPES //
 void init();
-void intro();
 
 int main()
 {
     init(); // initialise devices
+    printf("Devices initialised \n");
     
-    printf("Devices initialised \n");
+    menu.intro(lcd, pad);
     
     while(1) {
         
-        intro();
+        menu.main(lcd, pad);
+        
+        printf("Start menu \n");
         
         // menu.main(lcd, pad);
         // maze.drawBox(lcd);
@@ -38,105 +49,5 @@
 {
     lcd.init();
     pad.init();
-}
-
-void intro()
-{
-    
-    // printf("intro started \n");
-    
-    while (1){
-        
-        // animation sequence
-        // lcd.drawCircle(x, y, radius, type);
-        for (int i = 0; i < 61; i++){
-            
-            lcd.clear();
-            lcd.printString("  Welcome to  ", 0, 1);
-            lcd.printString("  Roller Maze ", 0, 2);
-            // printf("loop \n");
-            lcd.drawLine(56, 40, 68, 40, FILL_BLACK);
-            lcd.drawLine(56, 41, 68, 41, FILL_BLACK);
-            lcd.refresh();
-            
-            if (i < 57){
-                lcd.drawCircle(i, 36, 4, FILL_BLACK);
-                lcd.refresh();
-                wait_ms(50);
-                
-            }
-            else if (i == 57){
-                
-                lcd.drawCircle(i, 37, 4, FILL_BLACK);
-                lcd.refresh();
-                wait_ms(50);
-                
-                for (int c = 55; c < 68; c++){
-                    
-                    lcd.clearPixel(c, 42);
-                    lcd.clearPixel(c, 43);
-                    lcd.clearPixel(c, 44);
-                    lcd.clearPixel(c, 45);
-                    lcd.clearPixel(c, 46);
-                    lcd.refresh();
-                }
-            }
-            else if (i == 58){
-                
-                lcd.drawCircle(i, 38, 4, FILL_BLACK);
-                lcd.refresh();
-                wait_ms(50);
-                
-                for (int c = 55; c < 68; c++){
-                    
-                    lcd.clearPixel(c, 42);
-                    lcd.clearPixel(c, 43);
-                    lcd.clearPixel(c, 44);
-                    lcd.clearPixel(c, 45);
-                    lcd.clearPixel(c, 46);
-                    lcd.refresh();
-                }
-            }
-            else if (i == 59){
-                
-                lcd.drawCircle(i, 39, 4, FILL_BLACK);
-                lcd.refresh();
-                wait_ms(50);
-                
-                for (int c = 55; c < 68; c++){
-                    
-                    lcd.clearPixel(c, 42);
-                    lcd.clearPixel(c, 43);
-                    lcd.clearPixel(c, 44);
-                    lcd.clearPixel(c, 45);
-                    lcd.clearPixel(c, 46);
-                    lcd.refresh();
-                }
-            }
-            else{
-                
-                for (int j = 40, j < 45; j++){
-                    
-                    lcd.drawCirle(i, j, 4, FILL_BLACK);
-                    lcd.refresh();
-                    wait_ms(50);
-                    
-                    for (int c = 55; c < 68; c++){
-                        
-                        lcd.clearPixel(c, 42);
-                        lcd.clearPixel(c, 43);
-                        lcd.clearPixel(c, 44);
-                        lcd.clearPixel(c, 45);
-                        lcd.clearPixel(c, 46);
-                        lcd.refresh();
-                    }
-                }
-            }
-            
-            // printf("%i \n", i);
-        }
-    }
-    
-    
-}
-
+    lcd.setBrightness(pad.read_pot());
+}
\ No newline at end of file