Mission Accomplished

Dependencies:   TextLCD mbed

Revision:
0:96cf16c88314
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jan 20 01:01:04 2016 +0000
@@ -0,0 +1,79 @@
+#include "Compass.h"
+#include "Temperature.h"
+#include "mbed.h"
+#include "Tap.h"
+#include "TextLCD.h"
+
+TextLCD lcd(p19,p20,p21,p22,p23,p24);
+I2C acc(p9,p10);
+InterruptIn to(p5);
+Serial pc(USBTX,USBRX);
+
+double direction;
+float temp2;
+float tap;
+float test;
+void Temperature(float t);
+void Direction(double d);
+void toggle(void);
+void printReading(void);
+Ticker t;
+bool displayTemperature;
+DigitalOut led(LED1);
+
+int main() 
+{
+    displayTemperature = 1;
+    Tap_init();
+    Tap();
+    t.attach(&printReading,3);
+    to.rise(&toggle);
+    pc.printf("Beginning \n\r");   
+    while(1) {Tap();}
+    
+}
+
+
+   /*
+        
+        direction = Compass();
+        temp2 = Temperature();
+        test = Tap();
+        
+        if(test ==1)
+        {
+           Direction(direction);
+           Temperature(temp2);
+        }
+        test =0;
+        // pc.printf( "%1.2f = Taps, %1.2f = Temp, %1.2f = Direction  \n\r" , tap, temp2, direction); 
+        */
+        
+void printReading() 
+{
+        if (displayTemperature){
+            Temperature(Temperature());}
+        else{
+            Direction(Compass());}
+}
+        
+void Direction(double d)
+{
+        lcd.cls();
+        pc.printf( "%1.2f = Direction  \n\r" , d); 
+        lcd.printf("%1.2f = Direction" , d);
+}
+
+void Temperature(float t)
+{
+        lcd.cls();
+        pc.printf( "%1.2f = Temperature  \n\r" , t);
+        lcd.printf( "%1.2f = Temperature" , t);
+}
+
+void toggle(void)
+{
+        displayTemperature = !displayTemperature;
+        Tap();
+        led=!led;
+}