math: more abs() fixes

abs() is 16 bit
This commit is contained in:
Andrew Tridgell 2012-08-16 15:17:42 +10:00
parent e2c3149b2f
commit 50e2458df0
4 changed files with 4 additions and 4 deletions

View File

@ -358,7 +358,7 @@ static void set_servos(void)
*/
if (
(control_mode == CIRCLE || control_mode >= FLY_BY_WIRE_B) &&
(abs(home.alt - current_loc.alt) < 1000) &&
(labs(home.alt - current_loc.alt) < 1000) &&
((airspeed.use()? airspeed.get_airspeed_cm() : g_gps->ground_speed) < 500 ) &&
!(control_mode==AUTO && takeoff_complete == false)
) {

View File

@ -435,7 +435,7 @@ static void do_wait_delay()
static void do_change_alt()
{
condition_rate = abs((int)next_nonnav_command.lat);
condition_rate = labs((int)next_nonnav_command.lat);
condition_value = next_nonnav_command.alt;
if(condition_value < current_loc.alt) condition_rate = -condition_rate;
target_altitude_cm = current_loc.alt + (condition_rate / 10); // Divide by ten for 10Hz update

View File

@ -104,7 +104,7 @@ static void test_one_offset(struct Location &loc,
brg_error += 360;
}
if (abs(dist - dist2) > 1.0 ||
if (fabs(dist - dist2) > 1.0 ||
brg_error > 1.0) {
Serial.printf("Failed offset test brg_error=%f dist_error=%f\n",
brg_error, dist-dist2);

View File

@ -117,7 +117,7 @@ void
Navigation::calc_long_scaling(int32_t lat)
{
// this is used to offset the shrinking longitude as we go towards the poles
float rads = (abs(lat) / T7) * 0.0174532925;
float rads = (fabs(lat) / T7) * 0.0174532925;
_scaleLongDown = cos(rads);
_scaleLongUp = 1.0f / cos(rads);
}