HW5.1

Dependencies:   SLCD TSI mbed

Fork of kl46z_slider_v1 by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
dorian505
Date:
Wed Sep 14 02:21:45 2016 +0000
Parent:
0:04499bc54bee
Commit message:
DorianFolieHW5.1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 04499bc54bee -r b71cf757c59f main.cpp
--- a/main.cpp	Fri Sep 09 17:51:13 2016 +0000
+++ b/main.cpp	Wed Sep 14 02:21:45 2016 +0000
@@ -12,9 +12,9 @@
 float tsidata;
 
 void LCDMess(char *lMess){
-        slcd.Home();
-        slcd.clear();
-        slcd.printf(lMess);
+    slcd.Home();
+    slcd.clear();
+    slcd.printf(lMess);
 }
 
 int main(void) {
@@ -24,18 +24,27 @@
     pc.printf(PROGNAME);
     TSISensor tsi;
 
-     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;
+    Timer LEDTimer;
+    Timer ButtonTimer;
+
+    while(true) {
+        buttonTimer = tsi.readPercentage();
+        if (ButtonTimer > Buttontime) {
+            for (i = 0; i < TSILIMIT; i++) { //i am hoping this makes the index 0 or 1
+                if (!buttons[i]) {
+                    allLEDsoff();
+                    LCDMess(rMess[i]);
+                    pc.printf(pMess[i]);
+                    currentLED = i;
+                }
+            }
+            ButtonTimer.reset();
         }
-            wait(DATAINTERVAL);
-    }
-}
\ No newline at end of file
+        if (LEDTimer.read() > blinkTimes[ledState]) {
+            LEDTimer.reset();
+            ledState = !ledState;
+            LEDs[currentLED] = ledState;
+            }
+        }
+
+    }
\ No newline at end of file