Aida Pločo Tarik Demirović

Dependencies:   TSI mbed

Files at this revision

API Documentation at this revision

Comitter:
tim003
Date:
Mon May 05 07:35:49 2014 +0000
Commit message:
LV8-Grupa1-Tim003-Zadatak1

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 31590ed52245 TSI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Mon May 05 07:35:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/vsluiter/code/TSI/#4dc2f5a3a731
diff -r 000000000000 -r 31590ed52245 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 05 07:35:49 2014 +0000
@@ -0,0 +1,78 @@
+#include "mbed.h"
+#include "TSISensor.h"
+
+PwmOut r(LED1);
+PwmOut g(LED2);
+PwmOut b(LED3);
+
+Serial pc(USBTX, USBRX);
+
+TSISensor tsi;
+Ticker t1;
+
+char buf[150];
+int i = 0;
+
+void ispisiTSI()
+{
+    pc.printf("\nTSI: %f", tsi.readPercentage());
+}
+
+void upaliLedicu(char ledica, float intenzitet)
+{
+    if(ledica == 'R')
+    {
+        r = 1.0 - intenzitet;
+        g = 1.0;
+        b = 1.0;
+    }
+    
+    if(ledica == 'G')
+    {
+        r = 1.0;
+        g = 1.0 - intenzitet;
+        b = 1.0;
+    }
+    
+    if(ledica == 'B')
+    {
+        r = 1.0;
+        g = 1.0;
+        b = 1.0 - intenzitet;
+    }
+}
+
+void ocitaj()
+{
+
+    buf[i] = pc.getc();
+    i++;
+
+    
+    if((buf[0] == 'R' or buf[0] == 'G' or buf[0] == 'B') and buf[1] >= '0' and buf[1] <= '9' and buf[2] >= '0' and buf[2] <= '9' and i == 3)
+    {
+        char ledica = buf[0];
+        float intenzitet = ((buf[1] - 48)*10 + buf[2] - 48)/100.0;
+        upaliLedicu(ledica, intenzitet);
+        i = 0;
+    }
+    
+    if(buf[0] == 'P' and i == 1)
+    {
+        i = 0;
+        t1.attach(&ispisiTSI, 1);
+    }
+    
+    if(buf[0] == 'Z' and i == 1)
+    {
+        i = 0;
+        t1.detach();
+    }
+}
+
+int main() {
+    r = 1.0;
+    g = 1.0;
+    b = 1.0;  
+    pc.attach(&ocitaj);
+}
diff -r 000000000000 -r 31590ed52245 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon May 05 07:35:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file