kekw

Dependencies:   mbed C12832_lcd MMA7660

Revision:
2:b07d155d316c
Parent:
1:876f52a697c1
--- a/main.cpp	Sun Sep 22 17:44:42 2013 +0000
+++ b/main.cpp	Sun Jan 19 14:57:41 2020 +0000
@@ -3,25 +3,65 @@
 #include "mbed.h"
 #include "MMA7660.h"
 #include "C12832_lcd.h"
+#include "USBMouse.h"
+#include "controller.h"
 
-C12832_LCD lcd; //On board LCD display
+USBMouse mouse;
+ //On board LCD display
 MMA7660 MMA(p28, p27); //I2C Accelerometer
 DigitalOut connectionLed(LED1);//Accel OK LED
+DigitalIn   center(p14);
+
+int16_t a_inx;
+int16_t a_iny;
 
 int main()
 {
-    int x=0,y=0;
+    int menuOption = 1;
+    int quit = 1;
+    int flag = 1;
     lcd.cls(); //clear LCD screen
     if (MMA.testConnection())
         connectionLed = 1; //Accelerometer init OK
+    while(quit){
+        if(menuOption == 1 && flag == 1){
+            lcd.printf("Jotstick <-     \n\r");
+            lcd.printf("Pot           Use Joystick\n\r");
+            lcd.printf("Accelometer        \n\r");
+            flag = 0;
+        }
+        if(menuOption == 2 && flag == 1){
+            lcd.printf("Jotstick        \n\r");
+            lcd.printf("Pot <-        Use Joystick\n\r");
+            lcd.printf("Accelometer         \n\r");
+            flag = 0;
+        }
+        if(menuOption == 3 && flag == 1){
+            lcd.printf("Jotstick        \n\r"); 
+            lcd.printf("Pot           Use Joystick\n\r");
+            lcd.printf("Accelometer <-       \n\r");
+            flag = 0;
+        }
+        
+        if(up == 1 && menuOption != 1){ menuOption--;flag = 1; wait(.3);}
+        else if(down == 1 && menuOption != 3){ menuOption++;flag = 1; wait(.3); }
+        if(center == 1){quit = 0;};
+    }
+    controller *control;
+    lcd.cls();
+    if(menuOption == 1){
+        control = new joystickController();
+        lcd.printf("Controlling With Joystick");
+    }else if(menuOption == 2){
+        control = new potController();
+        lcd.printf("Controlling With Pots");    
+    }
+    else if(menuOption == 3){
+        control = new accelController();
+        lcd.printf("Controlling With Accelerometer");    
+    }
     while(1) {
-        //read X,Y +/-Gs and scale for #display pixels
-        x = (x + MMA.x() * 32.0)/2.0;
-        y = (y -(MMA.y() * 16.0))/2.0;
-        lcd.fillcircle(x+63, y+15, 3, 1); //draw bubble
-        lcd.circle(63, 15, 8, 1);
-        wait(.1); //time delay
-        lcd.fillcircle(x+63, y+15, 3, 0); //erase bubble
+        control->moveCursor();
     }
 
 }