tim007 tim007 / Mbed 2 deprecated lv8_tim007_grupa5_zad1

Dependencies:   TSI mbed

Files at this revision

API Documentation at this revision

Comitter:
tim007
Date:
Thu May 08 12:49:48 2014 +0000
Commit message:
lv8_grupa5_tim007

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 4603ec846206 TSI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Thu May 08 12:49:48 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/vsluiter/code/TSI/#4dc2f5a3a731
diff -r 000000000000 -r 4603ec846206 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 08 12:49:48 2014 +0000
@@ -0,0 +1,80 @@
+#include "mbed.h"
+#include "TSISensor.h"
+
+Serial pc(USBTX, USBRX);
+PwmOut crvena(LED1), zelena(LED2), plava(LED3);
+TSISensor tsi;
+Ticker tiker;
+Ticker t;
+bool daLiMjeri = false;
+char slovo;
+float procenat=0.0;
+void Funkcija()
+{
+    if(daLiMjeri==true)
+        pc.printf("%f\n", tsi.readPercentage());//prikazivanje procenta aktivacije senzora
+        
+
+}
+
+
+int main()
+{
+    crvena = zelena = plava = 1.0; //ili 1.0
+    tiker.attach(&Funkcija, 1.); //sa ili bez &
+    
+
+    while(1)
+    {
+
+        slovo = pc.getc();
+        
+
+        if (slovo== 'P')
+        {
+            daLiMjeri=true;
+        }
+        else if (slovo== 'Z')
+        {
+            daLiMjeri=false;
+        }
+        else if (slovo == 'R' || slovo == 'G' || slovo == 'B')
+        {
+            char a = pc.getc();
+            if(a >= '0' && a <= '9')
+            {
+                char b = pc.getc();
+                if(b >= '0' && b <= '9')
+                {
+                    procenat = ((b-'0') + 10 * (a-'0')) / 100.;
+                  
+                    if(slovo=='R')
+                    {
+                        zelena = plava = 1.0;//ili je 1.0
+                        crvena = 1.0-procenat;// ili 1-procenat
+                    }
+                    else if(slovo=='G')
+                    {
+                        crvena = plava = 1.0;
+                        zelena =1.0-procenat;
+                    }
+                    else if(slovo=='B')
+                    {
+                        crvena = zelena = 1.0;
+                        plava = 1.0-procenat;
+                    }
+
+
+                }
+            }
+        }
+        else
+        {
+            //ne valja ocitanje
+        }
+    }
+
+
+  return 0;
+}
+
diff -r 000000000000 -r 4603ec846206 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 08 12:49:48 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file