tim008 tim008 / Mbed 2 deprecated LV08_Grupa7_Tim008_Zad01

Dependencies:   TSI mbed

Files at this revision

API Documentation at this revision

Comitter:
tim008
Date:
Thu May 08 16:58:06 2014 +0000
Commit message:
LV08_Grupa7_Tim008_Z01

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Thu May 08 16:58:06 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/vsluiter/code/TSI/#4dc2f5a3a731
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 08 16:58:06 2014 +0000
@@ -0,0 +1,64 @@
+#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 %.2f\n", tsi.readPercentage()*100.0);
+}
+ 
+ int getBrightness()
+ {
+     char c1 = pc.getc();
+     if( c1 < '0' ||  c1 > '9' ) return -1;
+     char c2 = pc.getc();
+     if (c2 < '0' || c2 > '9' ) return -1;
+     else return (c1 - '0') * 10 + c2 - '0';
+ }
+ void getCommand()
+ {
+     char c = pc.getc();
+     switch(c) 
+     {
+        case 'R':
+            ledG = ledB = 1.0;
+            brightness = getBrightness();
+            if(brightness == -1) return;
+            ledR = 1 - brightness / 100.0;
+            break;
+        case 'G':
+            ledR = ledB = 1.0;
+            brightness = getBrightness();
+            if(brightness == -1) return;
+            ledG = 1 - brightness / 100.0;
+            break;
+        case 'B':
+            ledG = ledR = 1.0;
+            brightness = getBrightness();
+            if(brightness == -1) return;
+            ledB = 1 - 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 08 16:58:06 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file