Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: RTOS-Threads/src/Task3.cpp
- Revision:
- 25:a7cfe421cb4a
- Parent:
- 24:54a8cdf17378
- Child:
- 27:18b6580eb0b1
--- a/RTOS-Threads/src/Task3.cpp Thu May 08 13:00:50 2014 +0000 +++ b/RTOS-Threads/src/Task3.cpp Thu May 08 13:35:13 2014 +0000 @@ -6,7 +6,7 @@ */ #define STICK_GAIN 2 -#define STICK_GAIN_YAW 8 +#define STICK_GAIN_YAW 16 #include "tasks.h" #include "setup.h" @@ -30,13 +30,7 @@ /* Decoded input: [YAW PITCH ROLL] */ int inputYPR[3]; -//typedef enum { -enum FLIGHT_MODE { - RATE, - STABLE -}; - -FLIGHT_MODE mode; +FLIGHT_MODE mode = STABLE; void Task3(void const *argument) { @@ -321,6 +315,19 @@ armed? BT.printf("ARMED\n") : BT.printf("ARM FAILED\n"); break; + case 'M': + case 'm': + switch (mode) { + case RATE: + BT.printf("RATE MODE\n"); + break; + case STABLE: + default: + BT.printf("STABLE MODE\n"); + break; + } + break; + default: break; } @@ -334,10 +341,20 @@ if (RCCommand[4] > 1500) mode = RATE; + else + mode = STABLE; inputYPR[0] = (RCCommand[0]-1500)*9/100*STICK_GAIN_YAW; inputYPR[1] = (RCCommand[1]-1500)*-1*9/100*STICK_GAIN; - inputYPR[2] = (RCCommand[2]-1500)*-1*9/100*STICK_GAIN; + switch (mode) { + case RATE: + inputYPR[2] = (RCCommand[2]-1500)*9/100*STICK_GAIN; + break; + case STABLE: + default: + inputYPR[2] = (RCCommand[2]-1500)*-1*9/100*STICK_GAIN; + break; + } if (rxModule[1].stallTimer.read_us() > 18820) { //armed = false;