Rename minLimit/maxLimit to angleAtMin and angleAtMax. Remove unneeded

MSP_SET_SERVO_LIMIT.  Bump MSP API version.  Add basic sanity checks to
MSP_SET_SERVO_CONF, reset all servos and adhere to the msp packet's data
size.
This commit is contained in:
Dominic Clifton 2015-06-04 21:13:32 +01:00
parent da6ee6ffb7
commit c142e3dfe9
6 changed files with 17 additions and 28 deletions

View File

@ -483,8 +483,8 @@ static void resetConf(void)
currentProfile->servoConf[i].max = DEFAULT_SERVO_MAX;
currentProfile->servoConf[i].middle = DEFAULT_SERVO_MIDDLE;
currentProfile->servoConf[i].rate = servoRates[i];
currentProfile->servoConf[i].minLimit = DEFAULT_SERVO_MIN_LIMIT;
currentProfile->servoConf[i].maxLimit = DEFAULT_SERVO_MAX_LIMIT;
currentProfile->servoConf[i].angleAtMin = DEFAULT_SERVO_MIN_ANGLE;
currentProfile->servoConf[i].angleAtMax = DEFAULT_SERVO_MAX_ANGLE;
currentProfile->servoConf[i].forwardFromChannel = CHANNEL_FORWARDING_DISABLED;
}

View File

@ -87,8 +87,6 @@ typedef enum {
#define SERVO_FLAPPERONS_MIN SERVO_FLAPPERON_1
#define SERVO_FLAPPERONS_MAX SERVO_FLAPPERON_2
#define AUX_FORWARD_CHANNEL_TO_SERVO_COUNT
//#define MIXER_DEBUG
uint8_t motorCount = 0;
@ -484,7 +482,6 @@ void writeServos(void)
case MIXER_AIRPLANE:
for (int i = SERVO_PLANE_INDEX_MIN; i <= SERVO_PLANE_INDEX_MAX; i++) {
pwmWriteServo(servoIndex++, servo[i]);
}
break;
@ -504,7 +501,7 @@ void writeServos(void)
servoIndex += 2;
}
// forward AUX1-4 to servo outputs (not constrained)
// forward AUX to remaining servo outputs (not constrained)
if (gimbalConfig->gimbal_flags & GIMBAL_FORWARDAUX) {
forwardAuxChannelsToServos(servoIndex);
servoIndex += MAX_AUX_CHANNEL_COUNT;

View File

@ -96,9 +96,9 @@ typedef struct servoParam_t {
int16_t min; // servo min
int16_t max; // servo max
int16_t middle; // servo middle
int8_t rate; // range [-100;+100] ; can be used to ajust a rate 0-100% and a direction
int8_t minLimit; // range [-90;90] ; can be used to adjust a rate 0-100% and a direction
int8_t maxLimit; // range [-90;90] ; can be used to adjust a rate 0-100% and a direction
int8_t rate; // range [-100;+100] ; can be used to adjust a rate 0-100% and a direction
uint8_t angleAtMin; // range [0;180] the measured angle in degrees from the middle when the servo is at the 'min' value.
uint8_t angleAtMax; // range [0;180] the measured angle in degrees from the middle when the servo is at the 'max' value.
int8_t forwardFromChannel; // RX channel index, 0 based. See CHANNEL_FORWARDING_DISABLED
} servoParam_t;

View File

@ -889,8 +889,8 @@ static void cliServo(char *cmdline)
servo->min,
servo->max,
servo->middle,
servo->minLimit,
servo->maxLimit,
servo->angleAtMin,
servo->angleAtMax,
servo->rate,
servo->forwardFromChannel
);
@ -934,8 +934,8 @@ static void cliServo(char *cmdline)
servo->min = arguments[1];
servo->max = arguments[2];
servo->middle = arguments[3];
servo->minLimit = arguments[4];
servo->maxLimit = arguments[5];
servo->angleAtMin = arguments[4];
servo->angleAtMax = arguments[5];
servo->rate = arguments[6];
servo->forwardFromChannel = arguments[7];
}

View File

@ -131,7 +131,7 @@ void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, es
#define MSP_PROTOCOL_VERSION 0
#define API_VERSION_MAJOR 1 // increment when major changes are made
#define API_VERSION_MINOR 10 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR
#define API_VERSION_MINOR 11 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR
#define API_VERSION_LENGTH 2
@ -292,7 +292,6 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
#define MSP_SET_SERVO_CONF 212 //in message Servo settings
#define MSP_SET_MOTOR 214 //in message PropBalance function
#define MSP_SET_NAV_CONFIG 215 //in message Sets nav config parameters - write to the eeprom
#define MSP_SET_SERVO_LIMIT 216 //in message Servo settings limits
// #define MSP_BIND 240 //in message no param
@ -835,8 +834,8 @@ static bool processOutCommand(uint8_t cmdMSP)
serialize16(currentProfile->servoConf[i].max);
serialize16(currentProfile->servoConf[i].middle);
serialize8(currentProfile->servoConf[i].rate);
serialize8(currentProfile->servoConf[i].minLimit);
serialize8(currentProfile->servoConf[i].maxLimit);
serialize8(currentProfile->servoConf[i].angleAtMin);
serialize8(currentProfile->servoConf[i].angleAtMax);
}
break;
case MSP_CHANNEL_FORWARDING:
@ -1418,7 +1417,6 @@ static bool processInCommand(void)
headSerialError(0);
} else {
uint8_t servoCount = currentPort->dataSize / SERVO_CHUNK_SIZE;
for (i = 0; i < MAX_SUPPORTED_SERVOS && i < servoCount; i++) {
currentProfile->servoConf[i].min = read16();
currentProfile->servoConf[i].max = read16();
@ -1432,16 +1430,10 @@ static bool processInCommand(void)
currentProfile->servoConf[i].middle = potentialServoMiddleOrChannelToForward;
}
currentProfile->servoConf[i].rate = read8();
currentProfile->servoConf[i].angleAtMin = read8();
currentProfile->servoConf[i].angleAtMax = read8();
}
}
#endif
break;
case MSP_SET_SERVO_LIMIT:
#ifdef USE_SERVOS
for (i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
currentProfile->servoConf[i].minLimit = read8();
currentProfile->servoConf[i].maxLimit = read8();
}
#endif
break;
case MSP_SET_CHANNEL_FORWARDING:

View File

@ -30,8 +30,8 @@
#define DEFAULT_SERVO_MIN 1000
#define DEFAULT_SERVO_MIDDLE 1500
#define DEFAULT_SERVO_MAX 2000
#define DEFAULT_SERVO_MIN_LIMIT -90
#define DEFAULT_SERVO_MAX_LIMIT 90
#define DEFAULT_SERVO_MIN_ANGLE 90
#define DEFAULT_SERVO_MAX_ANGLE 90
typedef enum {
SERIAL_RX_FRAME_PENDING = 0,