kekw

Dependencies:   mbed C12832_lcd MMA7660

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //Uses x & y acceleration to simulate a bubble level
00002 //on the application board LCD display
00003 #include "mbed.h"
00004 #include "MMA7660.h"
00005 #include "C12832_lcd.h"
00006 #include "USBMouse.h"
00007 #include "controller.h"
00008 
00009 USBMouse mouse;
00010  //On board LCD display
00011 MMA7660 MMA(p28, p27); //I2C Accelerometer
00012 DigitalOut connectionLed(LED1);//Accel OK LED
00013 DigitalIn   center(p14);
00014 
00015 int16_t a_inx;
00016 int16_t a_iny;
00017 
00018 int main()
00019 {
00020     int menuOption = 1;
00021     int quit = 1;
00022     int flag = 1;
00023     lcd.cls(); //clear LCD screen
00024     if (MMA.testConnection())
00025         connectionLed = 1; //Accelerometer init OK
00026     while(quit){
00027         if(menuOption == 1 && flag == 1){
00028             lcd.printf("Jotstick <-     \n\r");
00029             lcd.printf("Pot           Use Joystick\n\r");
00030             lcd.printf("Accelometer        \n\r");
00031             flag = 0;
00032         }
00033         if(menuOption == 2 && flag == 1){
00034             lcd.printf("Jotstick        \n\r");
00035             lcd.printf("Pot <-        Use Joystick\n\r");
00036             lcd.printf("Accelometer         \n\r");
00037             flag = 0;
00038         }
00039         if(menuOption == 3 && flag == 1){
00040             lcd.printf("Jotstick        \n\r"); 
00041             lcd.printf("Pot           Use Joystick\n\r");
00042             lcd.printf("Accelometer <-       \n\r");
00043             flag = 0;
00044         }
00045         
00046         if(up == 1 && menuOption != 1){ menuOption--;flag = 1; wait(.3);}
00047         else if(down == 1 && menuOption != 3){ menuOption++;flag = 1; wait(.3); }
00048         if(center == 1){quit = 0;};
00049     }
00050     controller *control;
00051     lcd.cls();
00052     if(menuOption == 1){
00053         control = new joystickController();
00054         lcd.printf("Controlling With Joystick");
00055     }else if(menuOption == 2){
00056         control = new potController();
00057         lcd.printf("Controlling With Pots");    
00058     }
00059     else if(menuOption == 3){
00060         control = new accelController();
00061         lcd.printf("Controlling With Accelerometer");    
00062     }
00063     while(1) {
00064         control->moveCursor();
00065     }
00066 
00067 }