Sumejja Porča

Dependencies:   TSI mbed

Files at this revision

API Documentation at this revision

Comitter:
tim008
Date:
Thu May 08 12:26:44 2014 +0000
Commit message:
priprema Zad01 Sumejja Porca

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 68fe7f3fda8a TSI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Thu May 08 12:26:44 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/vsluiter/code/TSI/#4dc2f5a3a731
diff -r 000000000000 -r 68fe7f3fda8a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 08 12:26:44 2014 +0000
@@ -0,0 +1,60 @@
+#include "mbed.h"
+ #include "TSISensor.h"
+ 
+Serial pc(USBTX, USBRX); // tx, rx
+PwmOut ledR(LED1), ledG(LED2), ledB(LED3);
+TSISensor tsi;
+Ticker ticker;
+ 
+float brightness = 1.0;
+
+void printTSI()
+{
+    pc.printf("Percentage of tsi is %f\n", tsi.readPercentage());
+}
+ 
+ int getBrightness()
+ {
+     char c1 = pc.getc();
+     char c2 = pc.getc();
+     if( c1 < '0' || c2 < '0' || c1 > '9' || c2 > '9' ) return -1;
+     else return (c1 - '0') * 10 + c2 - '0';
+ }
+ void getCommand()
+ {
+     char c = pc.getc();
+     brightness = getBrightness();
+     if(brightness == -1) return;
+     switch(c) 
+     {
+        case 'R':
+            ledG = ledB = 1.0;
+            ledR = brightness / 100.0;
+            break;
+        case 'G':
+            ledR = ledB = 1.0;
+            ledG = brightness / 100.0;
+            break;
+        case 'B':
+            ledG = ledR = 1.0;
+            ledB = brightness / 100.0;
+            break;
+        case 'P':
+            ticker.attach(&printTSI, 1);
+            break;
+        case 'Z':
+           ticker.detach();
+           break;
+        default:
+        return;
+    }
+    }
+    
+int main() {
+    pc.printf("Press XDD -> X to turn R/G/B diode up and DD to adjust its brightness,or P to start measuring TSI and Z to stop it\n");
+    ledR = ledG = ledB = 1.0;
+    pc.attach(&getCommand);
+    while(1) {
+    
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 68fe7f3fda8a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 08 12:26:44 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file