first extract from Tilting for Servo pull request

This commit is contained in:
Mauro Mombelli 2015-05-20 15:21:02 +02:00 committed by Dominic Clifton
parent 9277a8b7bf
commit da6ee6ffb7
5 changed files with 27 additions and 6 deletions

View File

@ -483,6 +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].forwardFromChannel = CHANNEL_FORWARDING_DISABLED;
}

View File

@ -97,6 +97,8 @@ typedef struct servoParam_t {
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 forwardFromChannel; // RX channel index, 0 based. See CHANNEL_FORWARDING_DISABLED
} servoParam_t;

View File

@ -871,7 +871,7 @@ static void cliServo(char *cmdline)
#ifndef USE_SERVOS
UNUSED(cmdline);
#else
enum { SERVO_ARGUMENT_COUNT = 6 };
enum { SERVO_ARGUMENT_COUNT = 8 };
int16_t arguments[SERVO_ARGUMENT_COUNT];
servoParam_t *servo;
@ -884,11 +884,13 @@ static void cliServo(char *cmdline)
for (i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
servo = &currentProfile->servoConf[i];
printf("servo %u %d %d %d %d %d\r\n",
printf("servo %u %d %d %d %d %d %d %d\r\n",
i,
servo->min,
servo->max,
servo->middle,
servo->minLimit,
servo->maxLimit,
servo->rate,
servo->forwardFromChannel
);
@ -932,8 +934,10 @@ static void cliServo(char *cmdline)
servo->min = arguments[1];
servo->max = arguments[2];
servo->middle = arguments[3];
servo->rate = arguments[4];
servo->forwardFromChannel = arguments[5];
servo->minLimit = arguments[4];
servo->maxLimit = arguments[5];
servo->rate = arguments[6];
servo->forwardFromChannel = arguments[7];
}
#endif
}

View File

@ -292,6 +292,7 @@ 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
@ -828,12 +829,14 @@ static bool processOutCommand(uint8_t cmdMSP)
s_struct((uint8_t *)&servo, MAX_SUPPORTED_SERVOS * 2);
break;
case MSP_SERVO_CONF:
headSerialReply(MAX_SUPPORTED_SERVOS * 7);
headSerialReply(MAX_SUPPORTED_SERVOS * 9);
for (i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
serialize16(currentProfile->servoConf[i].min);
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);
}
break;
case MSP_CHANNEL_FORWARDING:
@ -1431,6 +1434,14 @@ static bool processInCommand(void)
currentProfile->servoConf[i].rate = 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

@ -27,9 +27,11 @@
#define PWM_PULSE_MIN 750 // minimum PWM pulse width which is considered valid
#define PWM_PULSE_MAX 2250 // maximum PWM pulse width which is considered valid
#define DEFAULT_SERVO_MIN 1020
#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
typedef enum {
SERIAL_RX_FRAME_PENDING = 0,