mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-22 07:45:24 +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:
commit
e312b105b1
3 changed files with 12 additions and 7 deletions
|
@ -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
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue