From 017e564af27af3557f0b52bf65c81cc6ed089b7a Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Tue, 11 Feb 2014 18:46:42 -0800 Subject: [PATCH] Fix double->float truncations --- src/comm/QGCFlightGearLink.cc | 4 +-- src/comm/QGCXPlaneLink.cc | 12 ++++---- src/uas/UAS.cc | 2 +- src/ui/PrimaryFlightDisplay.cc | 18 +++++------ src/ui/configuration/BatteryMonitorConfig.cc | 32 ++++++++++---------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/comm/QGCFlightGearLink.cc b/src/comm/QGCFlightGearLink.cc index 4a044c840..6379f7db8 100644 --- a/src/comm/QGCFlightGearLink.cc +++ b/src/comm/QGCFlightGearLink.cc @@ -353,8 +353,8 @@ void QGCFlightGearLink::readBytes() // qDebug() << "sensorHilRawImuChanged " << xacc << yacc << zacc << rollspeed << pitchspeed << yawspeed << xmag << ymag << zmag << abs_pressure << diff_pressure << pressure_alt << temperature; int gps_fix_type = 3; - float eph = 0.3; - float epv = 0.6; + float eph = 0.3f; + float epv = 0.6f; float vel = sqrt(vx*vx + vy*vy + vz*vz); float cog = yaw; int satellites = 8; diff --git a/src/comm/QGCXPlaneLink.cc b/src/comm/QGCXPlaneLink.cc index 3d0819545..4459e727b 100644 --- a/src/comm/QGCXPlaneLink.cc +++ b/src/comm/QGCXPlaneLink.cc @@ -518,19 +518,19 @@ void QGCXPlaneLink::readBytes() // X-Plane expresses yaw as 0..2 PI if (yaw > M_PI) { - yaw -= 2.0 * M_PI; + yaw -= 2.0f * static_cast(M_PI); } if (yaw < -M_PI) { - yaw += 2.0 * M_PI; + yaw += 2.0f * static_cast(M_PI); } float yawmag = p.f[3] / 180.0f * M_PI; if (yawmag > M_PI) { - yawmag -= 2.0 * M_PI; + yawmag -= 2.0f * static_cast(M_PI); } if (yawmag < -M_PI) { - yawmag += 2.0 * M_PI; + yawmag += 2.0f * static_cast(M_PI); } // Normal rotation matrix, but since we rotate the @@ -689,8 +689,8 @@ void QGCXPlaneLink::readBytes() // XXX make these GUI-configurable and add randomness int gps_fix_type = 3; - float eph = 0.3; - float epv = 0.6; + float eph = 0.3f; + float epv = 0.6f; float vel = sqrt(vx*vx + vy*vy + vz*vz); float cog = atan2(vy, vx); int satellites = 8; diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 1d8a51e71..6aa4258a7 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -3198,7 +3198,7 @@ void UAS::sendHilGps(quint64 time_us, double lat, double lon, double alt, int fi float course = cog; // map to 0..2pi if (course < 0) - course += 2.0f * M_PI; + course += 2.0f * static_cast(M_PI); // scale from radians to degrees course = (course / M_PI) * 180.0f; diff --git a/src/ui/PrimaryFlightDisplay.cc b/src/ui/PrimaryFlightDisplay.cc index 9a206fae8..aa9d250b6 100644 --- a/src/ui/PrimaryFlightDisplay.cc +++ b/src/ui/PrimaryFlightDisplay.cc @@ -33,7 +33,7 @@ static const float PITCHTRANSLATION = 65; // 5 degrees for each line static const int PITCH_SCALE_RESOLUTION = 5; static const float PITCH_SCALE_MAJORWIDTH = 0.1f; -static const float PITCH_SCALE_MINORWIDTH = 0.066; +static const float PITCH_SCALE_MINORWIDTH = 0.066f; // Beginning from PITCH_SCALE_WIDTHREDUCTION_FROM degrees of +/- pitch, the // width of the lines is reduced, down to PITCH_SCALE_WIDTHREDUCTION times @@ -49,18 +49,18 @@ static const int PITCH_SCALE_HALFRANGE = 15; static const int COMPASS_DISK_MAJORTICK = 10; static const int COMPASS_DISK_ARROWTICK = 45; -static const float COMPASS_DISK_MAJORLINEWIDTH = 0.006; -static const float COMPASS_DISK_MINORLINEWIDTH = 0.004; +static const float COMPASS_DISK_MAJORLINEWIDTH = 0.006f; +static const float COMPASS_DISK_MINORLINEWIDTH = 0.004f; static const int COMPASS_DISK_RESOLUTION = 10; -static const float COMPASS_SEPARATE_DISK_RESOLUTION = 5; -static const float COMPASS_DISK_MARKERWIDTH = 0.2; -static const float COMPASS_DISK_MARKERHEIGHT = 0.133; +static const float COMPASS_SEPARATE_DISK_RESOLUTION = 5.0f; +static const float COMPASS_DISK_MARKERWIDTH = 0.2f; +static const float COMPASS_DISK_MARKERHEIGHT = 0.133f; static const int CROSSTRACK_MAX = 1000; -static const float CROSSTRACK_RADIUS = 0.6; +static const float CROSSTRACK_RADIUS = 0.6f; -static const float TAPE_GAUGES_TICKWIDTH_MAJOR = 0.25; -static const float TAPE_GAUGES_TICKWIDTH_MINOR = 0.15; +static const float TAPE_GAUGES_TICKWIDTH_MAJOR = 0.25f; +static const float TAPE_GAUGES_TICKWIDTH_MINOR = 0.15f; // The altitude difference between top and bottom of scale static const int ALTIMETER_LINEAR_SPAN = 50; diff --git a/src/ui/configuration/BatteryMonitorConfig.cc b/src/ui/configuration/BatteryMonitorConfig.cc index a4d3ca319..ec09c817c 100644 --- a/src/ui/configuration/BatteryMonitorConfig.cc +++ b/src/ui/configuration/BatteryMonitorConfig.cc @@ -149,39 +149,39 @@ void BatteryMonitorConfig::monitorCurrentIndexChanged(int index) } void BatteryMonitorConfig::sensorCurrentIndexChanged(int index) { - float maxvolt = 0.0; - float maxamps = 0.0; - float mvpervolt = 0.0; - float mvperamp = 0.0; - float topvolt = 0.0; - float topamps = 0.0; + float maxvolt = 0.0f; + float maxamps = 0.0f; + float mvpervolt = 0.0f; + float mvperamp = 0.0f; + float topvolt = 0.0f; + float topamps = 0.0f; if (index == 1) { //atto 45 see https://www.sparkfun.com/products/10643 - maxvolt = 13.6; - maxamps = 44.7; + maxvolt = 13.6f; + maxamps = 44.7f; } else if (index == 2) { //atto 90 see https://www.sparkfun.com/products/9028 - maxvolt = 51.8; - maxamps = 89.4; + maxvolt = 51.8f; + maxamps = 89.4f; } else if (index == 3) { //atto 180 see https://www.sparkfun.com/products/10644 - maxvolt = 51.8; - maxamps = 178.8; + maxvolt = 51.8f; + maxamps = 178.8f; } else if (index == 4) { //3dr - maxvolt = 50.0; - maxamps = 90.0; + maxvolt = 50.0f; + maxamps = 90.0f; } - mvpervolt = calculatemVPerVolt(3.3,maxvolt); - mvperamp = calculatemVPerAmp(3.3,maxamps); + mvpervolt = calculatemVPerVolt(3.3f, maxvolt); + mvperamp = calculatemVPerAmp(3.3f, maxamps); if (index == 0) { //Other -- 2.22.0