ELEC2645 (2017/18) / Mbed OS el16ajm
Revision:
1:a14415de3ad5
Parent:
0:66e5b37c127e
Child:
2:9ca5e1c221c3
--- a/main.cpp	Mon Apr 16 08:42:04 2018 +0000
+++ b/main.cpp	Mon Apr 16 09:07:17 2018 +0000
@@ -9,14 +9,53 @@
 */
 
 #include "mbed.h"
+#include "Gamepad.h"
+#include "N5110.h"
+#include "Engine.h"
 
-DigitalOut led1(LED1);
+/////////////// structs /////////////////
+struct UserInput {
+    Direction d;
+    float mag;
+};
+
+/////////////// objects ///////////////
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+Gamepad pad;
+Engine gameEngine;
 
-// main() runs in its own thread in the OS
-int main() {
-    while (true) {
-        led1 = !led1;
-        wait(0.5);
+///////////// prototypes ///////////////
+void init();
+void update_game(UserInput input);
+void render();
+void welcome();
+
+///////////// functions ////////////////
+int main()
+{
+    init();
+    welcome();
+}
+
+void welcome()
+{
+    lcd.printString("     Snake!    ",0,1);  
+    lcd.printString("  Press Start ",0,4);
+    lcd.refresh();
+     
+    // wait flashing LEDs until start button is pressed 
+    while ( pad.check_event(Gamepad::START_PRESSED) == false) {
+        pad.leds_on();
+        wait(0.1);
+        pad.leds_off();
+        wait(0.1);
     }
 }
 
+void init()
+{
+    // need to initialise LCD and Gamepad 
+    lcd.init();
+    pad.init();     
+
+}