From d3c13e6570be9f778d463dccd558d86acc788291 Mon Sep 17 00:00:00 2001 From: Michael Carpenter Date: Mon, 20 May 2013 18:36:22 -0400 Subject: [PATCH] Changes for compiling in windows and getting the AHRS working --- src/ui/PrimaryFlightDisplay.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/ui/PrimaryFlightDisplay.cpp b/src/ui/PrimaryFlightDisplay.cpp index e31789529..f4e3c3050 100644 --- a/src/ui/PrimaryFlightDisplay.cpp +++ b/src/ui/PrimaryFlightDisplay.cpp @@ -10,14 +10,17 @@ #include #include #include - +#include /* *@TODO: * global fixed pens * repaint on demand multiple canvases * multi implementation with shared model class */ - +double round(double value, int digits=0) +{ + return floor(value * pow(10, digits) + 0.5) / pow(10, digits); +} const int PrimaryFlightDisplay::tickValues[] = {10, 20, 30, 45, 60}; const QString PrimaryFlightDisplay::compassWindNames[] = { QString("N"), @@ -35,7 +38,7 @@ PrimaryFlightDisplay::PrimaryFlightDisplay(int width, int height, QWidget *paren roll(0), pitch(0), - heading(NAN), + heading(0), aboveASLAltitude(0), GPSAltitude(0), aboveHomeAltitude(0), @@ -80,7 +83,7 @@ PrimaryFlightDisplay::PrimaryFlightDisplay(int width, int height, QWidget *paren // Refresh timer refreshTimer->setInterval(updateInterval); - connect(refreshTimer, SIGNAL(timeout()), this, SLOT(paintHUD())); + connect(refreshTimer, SIGNAL(timeout()), this, SLOT(update())); } PrimaryFlightDisplay::~PrimaryFlightDisplay() @@ -165,9 +168,9 @@ void PrimaryFlightDisplay::updateAttitude(UASInterface* uas, double roll, double if (!isnan(roll) && !isinf(roll) && !isnan(pitch) && !isinf(pitch) && !isnan(yaw) && !isinf(yaw)) { // TODO: Units conversion? - this->roll = roll; - this->pitch = pitch; - this->heading = yaw; + this->roll = roll * (180.0 / M_PI); + this->pitch = pitch * (180.0 / M_PI); + this->heading = yaw * (180.0 / M_PI); } // TODO: Else-part. We really should have an "attitude bad or unknown" indication instead of just freezing. @@ -309,7 +312,7 @@ void PrimaryFlightDisplay::paintEvent(QPaintEvent *event) // the event is ignored as this widget // is refreshed automatically Q_UNUSED(event); - makeDummyData(); + //makeDummyData(); doPaint(); } @@ -319,7 +322,7 @@ void PrimaryFlightDisplay::paintOnTimer() { *The whole tainted-flag shebang. *well not really so critical. Worst problem is deletion? */ - makeDummyData(); + //makeDummyData(); doPaint(); } -- 2.22.0