SB_SSD341_5.1

Dependencies:   SLCD TSI mbed

Fork of kl46z_slider_v1 by Stanley Cohen

Revision:
1:4f5a6fff2389
Parent:
0:04499bc54bee
diff -r 04499bc54bee -r 4f5a6fff2389 main.cpp
--- a/main.cpp	Fri Sep 09 17:51:13 2016 +0000
+++ b/main.cpp	Wed Sep 14 00:36:37 2016 +0000
@@ -8,6 +8,7 @@
 
 SLCD slcd; //define LCD display
 Serial pc(USBTX, USBRX);
+Timer SliderTimer;
 
 float tsidata;
 
@@ -18,6 +19,8 @@
 }
 
 int main(void) {
+    SliderTimer.start();
+    SliderTimer.reset();
     char lcdData[LCDCHARLEN];
     PwmOut gled(LED_GREEN);
     PwmOut rled(LED_RED);
@@ -26,16 +29,18 @@
 
      while (true) {
         tsidata = tsi.readPercentage();
-        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;
+        if (SliderTimer.read() > DATAINTERVAL){
+            SliderTimer.reset();
+            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;
+            }
         }
-            wait(DATAINTERVAL);
     }
 }
\ No newline at end of file