APM: fixed throttle display to always be between 0 and 100

when rc3 is below RC3_MIN, don't give an invalid value
This commit is contained in:
Andrew Tridgell 2012-11-20 13:50:11 +11:00
parent 8ccac5da3d
commit f80783665f

View File

@ -358,12 +358,15 @@ static void NOINLINE send_vfr_hud(mavlink_channel_t chan)
} else if (!ahrs.airspeed_estimate(&aspeed)) {
aspeed = 0;
}
float throttle_norm = g.channel_throttle.norm_output() * 100;
throttle_norm = constrain(throttle_norm, -100, 100);
uint16_t throttle = ((uint16_t)(throttle_norm + 100)) / 2;
mavlink_msg_vfr_hud_send(
chan,
aspeed,
(float)g_gps->ground_speed * 0.01,
(ahrs.yaw_sensor / 100) % 360,
(uint16_t)(100 * (g.channel_throttle.norm_output() / 2.0 + 0.5)), // scale -1,1 to 0-100
throttle,
current_loc.alt / 100.0,
barometer.get_climb_rate());
}