Mission Accomplished

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "Compass.h"
00002 #include "Temperature.h"
00003 #include "mbed.h"
00004 #include "Tap.h"
00005 #include "TextLCD.h"
00006 
00007 TextLCD lcd(p19,p20,p21,p22,p23,p24);
00008 I2C acc(p9,p10);
00009 InterruptIn to(p5);
00010 Serial pc(USBTX,USBRX);
00011 
00012 double direction;
00013 float temp2;
00014 float tap;
00015 float test;
00016 void Temperature(float t);
00017 void Direction(double d);
00018 void toggle(void);
00019 void printReading(void);
00020 Ticker t;
00021 bool displayTemperature;
00022 DigitalOut led(LED1);
00023 
00024 int main() 
00025 {
00026     displayTemperature = 1;
00027     Tap_init();
00028     Tap();
00029     t.attach(&printReading,3);
00030     to.rise(&toggle);
00031     pc.printf("Beginning \n\r");   
00032     while(1) {Tap();}
00033     
00034 }
00035 
00036 
00037    /*
00038         
00039         direction = Compass();
00040         temp2 = Temperature();
00041         test = Tap();
00042         
00043         if(test ==1)
00044         {
00045            Direction(direction);
00046            Temperature(temp2);
00047         }
00048         test =0;
00049         // pc.printf( "%1.2f = Taps, %1.2f = Temp, %1.2f = Direction  \n\r" , tap, temp2, direction); 
00050         */
00051         
00052 void printReading() 
00053 {
00054         if (displayTemperature){
00055             Temperature(Temperature());}
00056         else{
00057             Direction(Compass());}
00058 }
00059         
00060 void Direction(double d)
00061 {
00062         lcd.cls();
00063         pc.printf( "%1.2f = Direction  \n\r" , d); 
00064         lcd.printf("%1.2f = Direction" , d);
00065 }
00066 
00067 void Temperature(float t)
00068 {
00069         lcd.cls();
00070         pc.printf( "%1.2f = Temperature  \n\r" , t);
00071         lcd.printf( "%1.2f = Temperature" , t);
00072 }
00073 
00074 void toggle(void)
00075 {
00076         displayTemperature = !displayTemperature;
00077         Tap();
00078         led=!led;
00079 }