Homework 5.1 timer class

Dependencies:   SLCD TSI mbed

Fork of kl46z_slider_v1 by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
annalou
Date:
Tue Sep 13 22:02:31 2016 +0000
Parent:
0:04499bc54bee
Commit message:
AMartSSD341_hw5.1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Sep 09 17:51:13 2016 +0000
+++ b/main.cpp	Tue Sep 13 22:02:31 2016 +0000
@@ -1,15 +1,18 @@
 #include "mbed.h"
 #include "TSISensor.h"
 #include "SLCD.h"
+#include "Timer.h"
 #define TSILIMIT 0.99
 #define LCDCHARLEN 10
 #define DATAINTERVAL 0.1
 #define PROGNAME "kl46z_slider_test_v1\n\r"
 
+
 SLCD slcd; //define LCD display
 Serial pc(USBTX, USBRX);
 
 float tsidata;
+Timer T;
 
 void LCDMess(char *lMess){
         slcd.Home();
@@ -29,13 +32,29 @@
         if (tsidata > TSILIMIT){
             gled = 0.0;
             rled = 0.0;
-        }else {
-            pc.printf("\n Position %f\n\r", tsidata);
-            sprintf (lcdData,"%0.4f",tsidata);  
-            LCDMess(lcdData);  
-            gled = tsidata;
-            rled = 1.0 - tsidata;
+        }
+        else 
+        {
+            if(tsidata >= 0.01)
+            {
+                pc.printf("\n Position %f\n\r", tsidata);
+                sprintf (lcdData,"%0.4f",tsidata);  
+                LCDMess(lcdData);  
+                gled = tsidata;
+                rled = 1.0 - tsidata;
+            }
         }
-            wait(DATAINTERVAL);
+        
+                T.start();
+                float read = T.read();
+                if(read >= 0.1)
+                {
+                   pc.printf("stopping");
+                   T.stop();
+                }
+                T.reset();
+        
+       // wait(DATAINTERVAL);
     }
+    
 }
\ No newline at end of file