GIU\ZF
Dependencies: MCP23017 WattBob_TextLCD mbed-rtos mbed
Fork of rtos_basic by
Revision 20:202e0046527e, committed 2018-03-28
- Comitter:
- ihexx
- Date:
- Wed Mar 28 14:34:34 2018 +0000
- Parent:
- 19:2044bb5d7f29
- Commit message:
- LAST MINUTE CHJECKS
Changed in this revision
diff -r 2044bb5d7f29 -r 202e0046527e main.cpp --- a/main.cpp Wed Mar 28 01:32:01 2018 +0000 +++ b/main.cpp Wed Mar 28 14:34:34 2018 +0000 @@ -5,7 +5,6 @@ */ #include "core.h" -DigitalOut led1(LED4); Thread thread; @@ -37,7 +36,7 @@ while (true) { //indicate program still running - led1 = !led1; + //led1 = !led1; Thread::wait(500); } }
diff -r 2044bb5d7f29 -r 202e0046527e tasks/core.h --- a/tasks/core.h Wed Mar 28 01:32:01 2018 +0000 +++ b/tasks/core.h Wed Mar 28 14:34:34 2018 +0000 @@ -19,12 +19,12 @@ //Outputs ---------------- #define PORT_REDBOX_LED1 p22 -#define PORT_REDBOX_LED2 p23 +#define PORT_REDBOX_LED2 p30 -#define PORT_SIDE_LIGHTS p5 -#define IGNITION_LED p6 -#define PORT_TURN_SIGNAL_LED_LEFT p25 -#define PORT_TURN_SIGNAL_LED_RIGHT p26 +#define PORT_SIDE_LIGHTS LED1 +#define IGNITION_LED LED4 +#define PORT_TURN_SIGNAL_LED_LEFT LED2 +#define PORT_TURN_SIGNAL_LED_RIGHT LED2 //#define PORT_SIDE_LIGHTS LED1 //#define IGNITION_LED LED4
diff -r 2044bb5d7f29 -r 202e0046527e tasks/task_group1.cpp --- a/tasks/task_group1.cpp Wed Mar 28 01:32:01 2018 +0000 +++ b/tasks/task_group1.cpp Wed Mar 28 14:34:34 2018 +0000 @@ -29,13 +29,19 @@ namespace brakeIndicator{ //Show use of the brake on a LED on the RedBox Unit const float freq = 2.0f; //hz - PwmOut led2(PORT_REDBOX_LED1); + DigitalOut led2(PORT_REDBOX_LED1); static inline void init(){ - led2.period_ms(50); +// led2.period_ms(50); } static inline void hotLoop(){ runTimeParams::liveAccess.lock(); - led2.write(runTimeParams::brakeForce); + if (runTimeParams::brakeForce>0.3f){ +// led2.write(runTimeParams::brakeForce*100.0f); + led2 = 1; + } + else{ + led2 = 0; + } runTimeParams::liveAccess.unlock(); } @@ -44,13 +50,18 @@ //Monitor speed and if it goes over 88 mph switch on a LED on //the RedBox unit static const float freq = 1; //hz - DigitalOut led(PORT_REDBOX_LED1); + DigitalOut led(PORT_REDBOX_LED2); static inline void init(){ led = 0; } static inline void hotLoop(){ runTimeParams::liveAccess.lock(); - led = (runTimeParams::avgSpeed>88); + if (runTimeParams::avgSpeed>88.0f){ + led = 1; + } + else{ + led = 0; + } runTimeParams::liveAccess.unlock(); } @@ -82,8 +93,8 @@ //If both switches are switched on //then flash both indicator LEDs at a rate of 2Hz (hazard mode) if(a&&b){ - lLed.period(2.0f); - rLed.period(2.0f); + lLed.period(0.5f); + rLed.period(0.5f); } else{ lLed.period(1.0f); @@ -97,8 +108,6 @@ - - namespace task_group_1{ Thread thread; const float freq = 2.0f; //hz
diff -r 2044bb5d7f29 -r 202e0046527e tasks/task_group2.cpp --- a/tasks/task_group2.cpp Wed Mar 28 01:32:01 2018 +0000 +++ b/tasks/task_group2.cpp Wed Mar 28 14:34:34 2018 +0000 @@ -8,7 +8,7 @@ static inline void hotLoop(){ runTimeParams::liveAccess.lock(); runTimeParams::brakeForce = brake.read(); - runTimeParams::accelForce = brake.read(); + runTimeParams::accelForce = accel.read(); runTimeParams::liveAccess.unlock(); } } @@ -43,9 +43,11 @@ const int i_prev = i; i = (i>=3)? 0: i+1; //Store to speed array in round robin format - float tmpSpeed = accel * + runTimeParams::speed[i_prev]; - runTimeParams::speed[i] = (tmpSpeed>0)?tmpSpeed:0; - + float tmpSpeed = accel + runTimeParams::speed[i_prev]; + tmpSpeed = (tmpSpeed>0)?tmpSpeed:0; + tmpSpeed = (tmpSpeed>200)?200:tmpSpeed; + runTimeParams::speed[i] = tmpSpeed; + runTimeParams::odometer += tmpSpeed*0.01f; runTimeParams::liveAccess.unlock(); } }