Armin Klačar Josip Kvesić

Dependencies:   TSI mbed

Files at this revision

API Documentation at this revision

Comitter:
tim007
Date:
Thu May 08 14:27:02 2014 +0000
Commit message:
LV8-PAI-Grupa6-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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Thu May 08 14:27:02 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/TSI/#1a60ef257879
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 08 14:27:02 2014 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+#include "TSISensor.h"
+#include <ctype.h>
+
+Serial pc(USBTX, USBRX);
+TSISensor tsi;
+Ticker t;
+PwmOut led[3] = {LED1, LED2, LED3};
+
+void dioda(char c)
+{
+    char cnum1 = pc.getc();
+    char cnum2 = pc.getc();
+    int brightness;
+    if ((!isdigit(cnum1))||(!isdigit(cnum1)))return;
+    brightness = (cnum1-'0')*10 + (cnum2-'0');
+    for(int i=0; i<3; i++) led[i]=1.0;
+    switch(c)
+    {
+    case 'R':
+        led[0]=1.0-brightness/100.0;
+        break;
+    case 'G':
+        led[1]=1.0-brightness/100.0;
+        break;
+    case 'B':
+        led[2]=1.0-brightness/100.0;
+        break;
+    }
+}
+
+void write(){
+    pc.printf("TSI: %.2f\n",tsi.readPercentage());
+    }
+
+void pcread()
+{
+    if (!pc.readable()) return;
+    char c = pc.getc();
+    if(c=='R'||c=='G'||c=='B') dioda(c);
+    else if (c=='P') t.attach(write,1.0);
+    else if (c=='Z') t.detach();
+    else return;
+}
+
+int main()
+{
+    for(int i=0; i<3; i++) led[i]=1.0;
+    pc.attach(pcread);
+    while(1);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 08 14:27:02 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file