1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-23 00:05:28 +03:00

Merge pull request #2950 from shellixyz/fix_servo_params_saving

Fix bug when saving servo params causing the servos not to move as configured
This commit is contained in:
Konstantin Sharlaimov 2018-03-23 20:40:44 +10:00 committed by GitHub
commit e312b105b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

View file

@ -1668,6 +1668,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
sbufReadU8(src); sbufReadU8(src);
servoParamsMutable(tmp_u8)->forwardFromChannel = sbufReadU8(src); servoParamsMutable(tmp_u8)->forwardFromChannel = sbufReadU8(src);
servoParamsMutable(tmp_u8)->reversedSources = sbufReadU32(src); servoParamsMutable(tmp_u8)->reversedSources = sbufReadU32(src);
servoComputeScalingFactors(tmp_u8);
} }
break; break;
#endif #endif

View file

@ -192,6 +192,14 @@ int servoDirection(int servoIndex, int inputSource)
return 1; return 1;
} }
/*
* Compute scaling factor for upper and lower servo throw
*/
void servoComputeScalingFactors(uint8_t servoIndex) {
servoMetadata[servoIndex].scaleMax = (servoParams(servoIndex)->max - servoParams(servoIndex)->middle) / 500.0f;
servoMetadata[servoIndex].scaleMin = (servoParams(servoIndex)->middle - servoParams(servoIndex)->min) / 500.0f;
}
void servosInit(void) void servosInit(void)
{ {
const mixerMode_e currentMixerMode = mixerConfig()->mixerMode; const mixerMode_e currentMixerMode = mixerConfig()->mixerMode;
@ -235,13 +243,8 @@ void servosInit(void)
} }
} }
/* for (uint8_t i = 0; i < MAX_SUPPORTED_SERVOS; i++)
* Compute scaling factor for upper and lower servo throw servoComputeScalingFactors(i);
*/
for (uint8_t i = 0; i < MAX_SUPPORTED_SERVOS; i++) {
servoMetadata[i].scaleMax = (servoParams(i)->max - servoParams(i)->middle) / 500.0f;
servoMetadata[i].scaleMin = (servoParams(i)->middle - servoParams(i)->min) / 500.0f;
}
} }

View file

@ -136,4 +136,5 @@ void servoMixerLoadMix(int index);
bool loadCustomServoMixer(void); bool loadCustomServoMixer(void);
int servoDirection(int servoIndex, int fromChannel); int servoDirection(int servoIndex, int fromChannel);
void servoMixer(float dT); void servoMixer(float dT);
void servoComputeScalingFactors(uint8_t servoIndex);
void servosInit(void); void servosInit(void);