1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

LP-10 Update previous abs float fix to use fabs

Previous fix casted the float arguments to ints. Use a fabs instead,
since it gives easier code to read. The beSmooth check was also moved
to further enhance the readability of the code.
This commit is contained in:
Stefan Karlsson 2015-07-12 23:54:37 +02:00
parent de07c028a9
commit c5ed56226d

View File

@ -29,6 +29,7 @@
#include "dialgadgetwidget.h"
#include <utils/stylehelper.h>
#include <iostream>
#include <math.h>
#include <QtOpenGL/QGLWidget>
#include <QDebug>
@ -558,7 +559,7 @@ void DialGadgetWidget::rotateNeedles()
int dialRun = 3;
if (n2enabled) {
double needle2Diff;
if (abs(int((needle2Value - needle2Target) * 10)) > 5 && beSmooth) {
if (beSmooth && fabs(needle2Value - needle2Target) > 0.5) {
needle2Diff = (needle2Target - needle2Value) / 5;
} else {
needle2Diff = needle2Target - needle2Value;
@ -590,7 +591,7 @@ void DialGadgetWidget::rotateNeedles()
// We assume that needle1 always exists!
double needle1Diff;
if ((abs(int((needle1Value - needle1Target) * 10)) > 5) && beSmooth) {
if (beSmooth && fabs(needle1Value - needle1Target) > 0.5) {
needle1Diff = (needle1Target - needle1Value) / 5;
} else {
needle1Diff = needle1Target - needle1Value;
@ -614,7 +615,7 @@ void DialGadgetWidget::rotateNeedles()
if (n3enabled) {
double needle3Diff;
if ((abs(int((needle3Value - needle3Target) * 10)) > 5) && beSmooth) {
if (beSmooth && fabs(needle3Value - needle3Target) > 0.5) {
needle3Diff = (needle3Target - needle3Value) / 5;
} else {
needle3Diff = needle3Target - needle3Value;