tim010 tim010
/
PRVIZ_LV8
Haskovic Nezdad
Revision 0:0809739583c3, committed 2014-05-08
- Comitter:
- tim010
- Date:
- Thu May 08 15:15:33 2014 +0000
- Commit message:
- LV8_grupa6_zadatak1_pai
Changed in this revision
diff -r 000000000000 -r 0809739583c3 TSI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TSI.lib Thu May 08 15:15:33 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/bmdlh/code/TSI/#a192baf6250c
diff -r 000000000000 -r 0809739583c3 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 08 15:15:33 2014 +0000 @@ -0,0 +1,69 @@ +#include "mbed.h" +#include <string> +#include "TSISensor.h" + +Serial pc(USBTX, USBRX); +PwmOut crvena(LED1), zelena(LED2), plava(LED3); +TSISensor tsi; +Ticker tiker; +bool mjerenjeSenzora = false; + +char komanda; + +bool DaLiJeCifra(char c) { + return (c >= '0' && c <= '9'); +} + +void PrikaziMjerenje() { + if(mjerenjeSenzora) + pc.printf("%f\n", tsi.readPercentage()); + + } + + +int main() { + + crvena = zelena = plava = 1.0; + tiker.attach(PrikaziMjerenje, 1.); + + while(true) { + + komanda = pc.getc(); + float dd; + + if (komanda== 'P') { mjerenjeSenzora=true; } + else if (komanda == 'Z') {mjerenjeSenzora=false; } + else if (komanda == 'R' || komanda == 'G' || komanda == 'B') + { + char a = pc.getc(); + if(DaLiJeCifra(a)){ + char b = pc.getc(); + if(DaLiJeCifra(b)){ + dd = ((b-'0') + 10 * (a-'0')) / 100.; + switch(komanda) { + case 'R': + zelena = plava = 1.0; + crvena = 1 - dd; + break; + + case 'G': + crvena = plava = 1.0; + zelena = 1 - dd; + break; + + case 'B': + crvena = zelena = 1.0; + plava = 1 - dd; + break; + } + } + } + else pc.printf("Ne valja.\n"); + } + + + + } + + return 0; +} \ No newline at end of file
diff -r 000000000000 -r 0809739583c3 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 08 15:15:33 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file