From c67882b243caec59cd274571edf21cd8583f29f1 Mon Sep 17 00:00:00 2001 From: Vishal Adhikari <40205726+vishal-adhikari@users.noreply.github.com> Date: Sun, 9 May 2021 04:10:48 +0530 Subject: [PATCH] 360 on north direction instead of West --- NazaDecoder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NazaDecoder.cpp b/NazaDecoder.cpp index e4248ae..056442f 100644 --- a/NazaDecoder.cpp +++ b/NazaDecoder.cpp @@ -211,7 +211,8 @@ uint8_t NazaDecoder::decode(int16_t input) { if (y < magYMin) { magYMin = y; } - heading = computeVectorAngle(y - ((magYMax + magYMin) / 2), x - ((magXMax + magXMin) / 2)); + heading = -atan2(y - ((magYMax + magYMin) / 2), x - ((magXMax + magXMin) / 2)) * 180.0 / M_PI; + if(heading < 0) heading += 360.0; } else if (messageId == NAZA_MESSAGE_MODULE_VERSION_TYPE) { firmwareVersion.version = pack4(NAZA_MESSAGE_POS_FW, 0x00); hardwareVersion.version = pack4(NAZA_MESSAGE_POS_HW, 0x00);