tim003 tim003
/
PAI_LV8_Grupa1_Tim003_Zadatak1
Aida Pločo Tarik Demirović
Revision 0:31590ed52245, committed 2014-05-05
- Comitter:
- tim003
- Date:
- Mon May 05 07:35:49 2014 +0000
- Commit message:
- LV8-Grupa1-Tim003-Zadatak1
Changed in this revision
diff -r 000000000000 -r 31590ed52245 TSI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TSI.lib Mon May 05 07:35:49 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/vsluiter/code/TSI/#4dc2f5a3a731
diff -r 000000000000 -r 31590ed52245 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 05 07:35:49 2014 +0000 @@ -0,0 +1,78 @@ +#include "mbed.h" +#include "TSISensor.h" + +PwmOut r(LED1); +PwmOut g(LED2); +PwmOut b(LED3); + +Serial pc(USBTX, USBRX); + +TSISensor tsi; +Ticker t1; + +char buf[150]; +int i = 0; + +void ispisiTSI() +{ + pc.printf("\nTSI: %f", tsi.readPercentage()); +} + +void upaliLedicu(char ledica, float intenzitet) +{ + if(ledica == 'R') + { + r = 1.0 - intenzitet; + g = 1.0; + b = 1.0; + } + + if(ledica == 'G') + { + r = 1.0; + g = 1.0 - intenzitet; + b = 1.0; + } + + if(ledica == 'B') + { + r = 1.0; + g = 1.0; + b = 1.0 - intenzitet; + } +} + +void ocitaj() +{ + + buf[i] = pc.getc(); + i++; + + + if((buf[0] == 'R' or buf[0] == 'G' or buf[0] == 'B') and buf[1] >= '0' and buf[1] <= '9' and buf[2] >= '0' and buf[2] <= '9' and i == 3) + { + char ledica = buf[0]; + float intenzitet = ((buf[1] - 48)*10 + buf[2] - 48)/100.0; + upaliLedicu(ledica, intenzitet); + i = 0; + } + + if(buf[0] == 'P' and i == 1) + { + i = 0; + t1.attach(&ispisiTSI, 1); + } + + if(buf[0] == 'Z' and i == 1) + { + i = 0; + t1.detach(); + } +} + +int main() { + r = 1.0; + g = 1.0; + b = 1.0; + pc.attach(&ocitaj); +}
diff -r 000000000000 -r 31590ed52245 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon May 05 07:35:49 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file