DP
Dependencies: FastAnalogIn mbed-rtos mbed
Fork of dipl_prace_v10 by
Diff: threads.cpp
- Revision:
- 1:28d74f044818
- Parent:
- 0:f3b355df6f26
diff -r f3b355df6f26 -r 28d74f044818 threads.cpp --- a/threads.cpp Sun Apr 26 13:14:02 2015 +0000 +++ b/threads.cpp Tue Apr 28 18:48:50 2015 +0000 @@ -25,6 +25,16 @@ cLedSensor baumer(p20); cControl control; +/* +* Beh vlaken +*/ +DigitalOut vl1(p28); +DigitalOut vl2(p27); +DigitalOut vl3(p26); +DigitalOut vl4(p25); +DigitalOut vl5(p24); +DigitalOut vl6(p23); + char first; states_t states; @@ -74,13 +84,14 @@ */ void ledThread(void const *args) { while(true) { + vl1 = !vl1; switch(programMode) { case WAITING: ledMode = 1; can.nullResolver(); break; case STARTING: - ledMode = 1; + ledMode = 0; break; case RUNNING: ledMode = !ledMode; @@ -110,10 +121,8 @@ */ void usThread(void const *args) { while(true) { - if(programMode != STOP) { - can.actual_speed(); - us100.setTrig(); - } + can.actual_speed(); + us100.setTrig(); Thread::wait(15); } } @@ -123,11 +132,10 @@ * This thread requires reading analog value every 3 ms */ void laserThread(void const *args) { - while(true) { + while(true) { + vl2 = !vl2; can.actual_speed(); - if(programMode != STOP) { - baumer.read(); - } + baumer.read(); Thread::wait(3); } } @@ -138,12 +146,11 @@ */ void controlThread(void const *args) { while(true) { - if(programMode != STOP) { + vl3 = !vl3; mutex1.lock(); control.setCurrent(); can.setCurrent(states.current); mutex1.unlock(); - } Thread::wait(15); } @@ -153,13 +160,15 @@ * This thread thread collect the states of system */ void collectThread(void const *args) { - while(true) { + while(true) { + osEvent ev = Thread::signal_wait(0); - if(programMode != STOP) { float timeout, volts,phi_temp,phi_old,omega_temp,phi,omega; if(ev.status == osEventSignal) { + if(programMode != STOP){ switch(ev.value.signals) { case 0x01 : + vl4 = !vl4; if(sensor == ULTRA) { timeout = us100.getPulseWidth(); mutex1.lock(); @@ -263,23 +272,22 @@ states.phi1 = phi; states.omega1 = omega; mutex1.unlock(); - break; case 0x02 : - + vl4 = !vl4; mutex1.lock(); states.phi2 = can.getPhi(); mutex1.unlock(); break; case 0x03 : - + vl4 = !vl4; mutex1.lock(); states.omega2 = can.getOmega(); mutex1.unlock(); break; - } - }} + }} + } } } @@ -289,6 +297,7 @@ */ void syncThread(void const *args) { while(true) { + vl5 = !vl5; can.sync(); Thread::wait(2); } @@ -301,6 +310,7 @@ void printThread(void const *args) { while(true) { if(programMode != STOP) { + vl6 = !vl6; mutex1.lock(); pc.printStates(); mutex1.unlock();