Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:347b86312097, committed 2014-05-08
- Comitter:
- tim008
- Date:
- Thu May 08 16:58:06 2014 +0000
- Commit message:
- LV08_Grupa7_Tim008_Z01
Changed in this revision
--- /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