SB_SSD341_5.1

Dependencies:   SLCD TSI mbed

Fork of kl46z_slider_v1 by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
sbart
Date:
Wed Sep 14 00:36:37 2016 +0000
Parent:
0:04499bc54bee
Commit message:
SBART_SSD341_5.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	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