mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Reduce maximum servos from 10 to 8.
1) the 2 extra servos were not used for anything, yet. 2) the MSP packet to set ALL the servo configurations in one go is larger than the MSP input buffer size. Likely the MSP_SET_SERVO_CONF should be updated with command that takes an index of a servo to configure, as per mode ranges/colors/leds/etc. Fixes #1002
This commit is contained in:
parent
78b52c53d5
commit
9a8a31676b
4 changed files with 28 additions and 16 deletions
|
@ -308,6 +308,8 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
|||
|
||||
#define INBUF_SIZE 64
|
||||
|
||||
#define SERVO_CHUNK_SIZE 7
|
||||
|
||||
typedef struct box_e {
|
||||
const uint8_t boxId; // see boxId_e
|
||||
const char *boxName; // GUI-readable box name
|
||||
|
@ -619,6 +621,8 @@ void mspReleasePortIfAllocated(serialPort_t *serialPort)
|
|||
|
||||
void mspInit(serialConfig_t *serialConfig)
|
||||
{
|
||||
BUILD_BUG_ON((SERVO_CHUNK_SIZE * MAX_SUPPORTED_SERVOS) > INBUF_SIZE);
|
||||
|
||||
// calculate used boxes based on features and fill availableBoxes[] array
|
||||
memset(activeBoxIds, 0xFF, sizeof(activeBoxIds));
|
||||
|
||||
|
@ -1408,18 +1412,26 @@ static bool processInCommand(void)
|
|||
break;
|
||||
case MSP_SET_SERVO_CONF:
|
||||
#ifdef USE_SERVOS
|
||||
for (i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
|
||||
currentProfile->servoConf[i].min = read16();
|
||||
currentProfile->servoConf[i].max = read16();
|
||||
// provide temporary support for old clients that try and send a channel index instead of a servo middle
|
||||
uint16_t potentialServoMiddleOrChannelToForward = read16();
|
||||
if (potentialServoMiddleOrChannelToForward < MAX_SUPPORTED_SERVOS) {
|
||||
currentProfile->servoConf[i].forwardFromChannel = potentialServoMiddleOrChannelToForward;
|
||||
if (currentPort->dataSize % SERVO_CHUNK_SIZE != 0) {
|
||||
debug[0] = currentPort->dataSize;
|
||||
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();
|
||||
|
||||
// provide temporary support for old clients that try and send a channel index instead of a servo middle
|
||||
uint16_t potentialServoMiddleOrChannelToForward = read16();
|
||||
if (potentialServoMiddleOrChannelToForward < MAX_SUPPORTED_SERVOS) {
|
||||
currentProfile->servoConf[i].forwardFromChannel = potentialServoMiddleOrChannelToForward;
|
||||
}
|
||||
if (potentialServoMiddleOrChannelToForward >= PWM_RANGE_MIN && potentialServoMiddleOrChannelToForward <= PWM_RANGE_MAX) {
|
||||
currentProfile->servoConf[i].middle = potentialServoMiddleOrChannelToForward;
|
||||
}
|
||||
currentProfile->servoConf[i].rate = read8();
|
||||
}
|
||||
if (potentialServoMiddleOrChannelToForward >= PWM_RANGE_MIN && potentialServoMiddleOrChannelToForward <= PWM_RANGE_MAX) {
|
||||
currentProfile->servoConf[i].middle = potentialServoMiddleOrChannelToForward;
|
||||
}
|
||||
currentProfile->servoConf[i].rate = read8();
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue