Omerovic Mirza Kicin Adnan

Dependencies:   TSI mbed

Files at this revision

API Documentation at this revision

Comitter:
tim003
Date:
Mon May 05 15:30:09 2014 +0000
Commit message:
PAI-LV8-Tim003-Grupa3; ; ;

Changed in this revision

TSI.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 0fbe88248a46 TSI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Mon May 05 15:30:09 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/vsluiter/code/TSI/#4dc2f5a3a731
diff -r 000000000000 -r 0fbe88248a46 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 05 15:30:09 2014 +0000
@@ -0,0 +1,64 @@
+#include "mbed.h"
+#include "TSISensor.h"
+#include <string>
+
+Serial pc(USBTX, USBRX); 
+PwmOut crvena(LED_RED), zelena(LED_GREEN), plava(LED_BLUE);
+TSISensor senzor;
+Ticker tiker;
+
+string unos = "";
+bool mjerenje = false;
+
+bool daLiJeBroj(char znak) {
+    return znak >= '0' && znak <= '9';
+}
+
+void prikaziStatus() {
+    if(mjerenje==true)
+        pc.printf("Sad je vako: %f\n", senzor.readPercentage());
+}
+
+int main() {
+    
+    crvena = 1.;
+    zelena = 1.;
+    plava = 1.;
+   
+    
+    while(1) {
+        unos.push_back(pc.getc());
+        if(unos.length() == 3) {
+            if(daLiJeBroj(unos[1])==false || daLiJeBroj(unos[2])==false)
+                unos = "";
+            float intenzitet = ((unos[2] - '0') + 10 * (unos[1] - '0')) / 100.;
+            if(unos[0]=='R') {
+                crvena = 1 - intenzitet;
+                unos = "";
+            }
+            else if(unos[0]=='G')
+            {
+                zelena = 1 - intenzitet;
+                unos = "";
+            }
+            else if (unos[0]=='B')
+            {
+                plava = 1 - intenzitet;
+                unos = "";
+            }
+            else unos = "";
+    }
+        else if(unos[unos.length()-1] == 'P') {
+            unos="";
+            mjerenje = true;
+             tiker.attach(prikaziStatus, 1.);
+        } else if(unos[unos.length()-1] == 'Z') {
+           unos="";
+           mjerenje = false;
+           tiker.detach();
+        }
+    }
+    
+
+    return 0; 
+}
\ No newline at end of file
diff -r 000000000000 -r 0fbe88248a46 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon May 05 15:30:09 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file