Commit d6e0e342 authored by DonLakeFlyer's avatar DonLakeFlyer

parent 6e83df06
......@@ -9,9 +9,12 @@
#include "QGC.h"
#include <qmath.h>
#include <float.h>
#include <QtGlobal>
namespace QGC
{
......@@ -137,4 +140,17 @@ quint32 crc32(const quint8 *src, unsigned len, unsigned state)
return state;
}
bool fuzzyCompare(double value1, double value2)
{
if (qIsNaN(value1) && qIsNaN(value2)) {
return true;
} else if (qIsNaN(value1) || qIsNaN(value2)) {
return false;
} else if (value1 == value2) {
return true;
} else {
return qFuzzyCompare(value1, value2);
}
}
}
......@@ -7,9 +7,7 @@
*
****************************************************************************/
#ifndef QGC_H
#define QGC_H
#pragma once
#include <QDateTime>
#include <QColor>
......@@ -42,7 +40,8 @@ void initTimer();
/** @brief Get the ground time since boot in milliseconds */
quint64 bootTimeMilliseconds();
const static int MAX_FLIGHT_TIME = 60 * 60 * 24 * 21;
/// Returns true if the two values are equal or close. Correctly handles 0 and NaN values.
bool fuzzyCompare(double value1, double value2);
class SLEEP : public QThread
{
......@@ -56,7 +55,3 @@ public:
quint32 crc32(const quint8 *src, unsigned len, unsigned state);
}
#define QGC_EVENTLOOP_DEBUG 0
#endif // QGC_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment