Power Grid Board Game Timer. Acts like a chess timer for 3-6 people. Uses an ADXL accelerometer to pause the timer and change players. Uses an LCD screen to prompt the players for input, read that input, and change between rounds.

Dependencies:   DmTouch_UniGraphic UniGraphic-forLdelaney17FinalProject mbed

Revision:
1:ba0f395e8c11
Parent:
0:1abea3982908
Child:
2:e6788e73de54
--- a/main.cpp	Wed Jan 25 00:07:44 2017 +0000
+++ b/main.cpp	Wed Jan 25 05:58:30 2017 +0000
@@ -1,16 +1,49 @@
 #include "mbed.h"
 #include "acc.h"
+#include "display.h"
+#include "DmTouch.h"
+#include "lcd_prompts.h"
+#include <sstream>
+
 DigitalOut gpo(D0);
 DigitalOut led(LED_RED);
 DigitalOut led_blue(LED_BLUE);
 I2C connection(D14, D15);
 InterruptIn acc_int(D8);
+PinName dataBus[] = {PTC16, PTC17, PTB9, PTA1, PTB23, PTA2, PTC2, PTC3};
+ILI932x myLCD(BUS_8, dataBus, PTB18, PTB19, PTC1, PTC8, PTC9, "myLCD", 240, 320);
+DmTouch touch(DmTouch::DM_TFT24_104, PTD2, PTD3, PTD1, PTC0, PTC7);
+Timeout read_again;
+int num_choices_global;
+int prompt_input_val;
+Serial pc(USBTX, USBRX);
+bool waiting_for_touch;
+
+void setup();
 
 int main()
 {
-    acc_init( 10 , 0.5 , 6 , 318.75 );  
-    led_blue = 1;
+    setup();
+    
+    //display_prompt("this is a moderately long message. Press 1 to acknowledge this message", 6);
+    //int n = read_prompt(6);
+    prompt(6, "starting prompt");
+    int n;
     while (true) {
+        if (waiting_for_touch == false){
+            n = prompt_input_val;
+            stringstream ss;
+            ss << "the last number selected was " << n << "\r\n";
+            
+            if (n > 0 && n < 7) 
+                n = prompt(7-n, ss.str());
+            else
+                pc.printf("n is %d\t", n);
+        }
+        else {//waiting_for_touch is true
+           pc.printf("waiting for x\r\n"); 
+        }
+            
         gpo = !gpo; // toggle pin
         led = !led; // toggle led
         if (acc_int){
@@ -21,5 +54,17 @@
                 led_blue = 0;    
         }
         wait(0.2f);
+        pc.printf("completed a loop through main \r\n");
+        wait(0.2f);
     }
+}
+
+void setup(){
+    acc_init( 10 , 0.5 , 6 , 318.75 );  
+    led_blue = 1;
+    touch.init();
+    touch.setOrientation(3);
+    display_init();
+    prompt_init();
+    waiting_for_touch = false;
 }
\ No newline at end of file