![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
All tasks complete
Dependencies: mbed MCP23017 mbed-rtos WattBob_TextLCD
Diff: assignment3tasks.cpp
- Revision:
- 8:3f3f2c2e2046
- Parent:
- 7:87f7ba90fdce
- Child:
- 9:2fd97246b8f0
--- a/assignment3tasks.cpp Tue Mar 26 16:48:30 2019 +0000 +++ b/assignment3tasks.cpp Tue Mar 26 21:42:14 2019 +0000 @@ -81,7 +81,7 @@ void task3enginestate() { - float delay = 1000 / TASKFREQ3; + float delay = 125; while(true){ //lock carstateXS.lock(); @@ -97,7 +97,7 @@ ngeneind = 0; } - Thread::wait( (int) delay); + Thread::wait(125); } } @@ -107,9 +107,10 @@ while(true){ speedXS.lock();//lock - for(int i = 0; i < SAMPLESIZE ; i++) + for(int i = 0; i < SAMPLESIZE ; i++){ //speed.rawspeed = (speed.accelvalue - speed.brakevalue)*MAXSPEED; speed.average += speed.array[i]; + } speed.average = (speed.average / SAMPLESIZE); speedXS.unlock();//unlock @@ -191,7 +192,8 @@ { float delay = 1000 / TASKFREQ7; while(true){ - display->cls(); + + display->cls(); //LOCK data carstateXS.lock(); @@ -199,7 +201,7 @@ speedXS.lock(); display->locate(1,0); - display->printf("S_AVER: %.2f",speed.average); + display->printf("AvgS: %.2f",speed.average); display->locate(0,0); display->printf("ODOM: %d",(int) info.odometer); @@ -208,8 +210,37 @@ //UNLOCK Speed speedXS.unlock(); + + + + Thread::wait(500); + + + } +} + +void task8sidelights() +{ + float delay = 1000 / TASKFREQ8; + while(true){ + + // LOCK Car data + carstateXS.lock(); + + info.sideind = sidesw.read(); + uint8_t temp = info.sideind; + + //UNLOCK Car data + carstateXS.unlock(); + + if (temp == 1) + sideind = 1; + else + sideind = 0; + Thread::wait((int)delay); + } -} \ No newline at end of file +} \ No newline at end of file