1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-16 08:29:15 +01:00

LP-462 MWOSD - MSP: Handle Dterm scale

This commit is contained in:
Laurent Lalanne 2016-12-30 15:00:53 +01:00
parent c2cf44f8d8
commit f67c092d6a

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) static void pid_native2msp(const float *native, msp_pid_t *piditem, float scale, unsigned numelem)
{ {
for (unsigned i = 0; i < numelem; ++i) { 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) static void pid_msp2native(const msp_pid_t *piditem, float *native, float scale, unsigned numelem)
{ {
for (unsigned i = 0; i < numelem; ++i) { 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;
} }
} }