1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Merged in f5soh/librepilot/LP-462_MSP_Dterm_zeroed (pull request #373)

LP-462 MWOSD - MSP: Handle Dterm scale
This commit is contained in:
Philippe Renon 2017-01-09 22:45:20 +01:00
commit 02d4d47139

View File

@ -676,14 +676,18 @@ static void msp_send_pidnames(struct msp_bridge *m)
static void pid_native2msp(const float *native, msp_pid_t *piditem, float scale, unsigned numelem)
{
for (unsigned i = 0; i < numelem; ++i) {
piditem->values[i] = lroundf(native[i] * scale);
// Handle Dterm scale
float s = (i == 2) ? scale * 100 : scale;
piditem->values[i] = lroundf(native[i] * s);
}
}
static void pid_msp2native(const msp_pid_t *piditem, float *native, float scale, unsigned numelem)
{
for (unsigned i = 0; i < numelem; ++i) {
native[i] = (float)piditem->values[i] / scale;
// Handle Dterm scale
float s = (i == 2) ? scale * 100 : scale;
native[i] = (float)piditem->values[i] / s;
}
}