From 89f202ce6a1fcc0ab4906ecd6d68b8b87e94cb9e Mon Sep 17 00:00:00 2001 From: Robert <3704942+JasonRJ@users.noreply.github.com> Date: Sat, 26 Feb 2022 18:44:05 -0500 Subject: [PATCH] Changed method to return float instead of double. All calculations within the method also use float instead of double. Results of the method do not seem to be effected. --- src/modules/SX128x/SX128x.cpp | 8 ++++---- src/modules/SX128x/SX128x.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 5f5ac79e..3bc66b89 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -1112,7 +1112,7 @@ float SX128x::getSNR() { } } -double SX128x::getFrequencyError() { +float SX128x::getFrequencyError() { // check active modem uint8_t modem = getPacketType(); if (!((modem == RADIOLIB_SX128X_PACKET_TYPE_LORA) || (modem == RADIOLIB_SX128X_PACKET_TYPE_RANGING))) { @@ -1130,16 +1130,16 @@ double SX128x::getFrequencyError() { uint32_t efe = ((uint32_t) efeRaw[0] << 16) | ((uint32_t) efeRaw[1] << 8) | efeRaw[2]; efe &= 0x0FFFFF; - double error; + float error; // check the first bit if (efe & 0x80000) { // frequency error is negative efe |= (uint32_t) 0xFFF00000; efe = ~efe + 1; - error = 1.55 * (double) efe / (1600.0 / (double) _bwKhz) * -1.0; + error = 1.55 * (float) efe / (1600.0 / (float) _bwKhz) * -1.0; } else { - error = 1.55 * (double) efe / (1600.0 / (double) _bwKhz); + error = 1.55 * (float) efe / (1600.0 / (float) _bwKhz); } return (error); diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index b86c3984..18f12f72 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -750,7 +750,7 @@ class SX128x: public PhysicalLayer { \returns Frequency error in Hz. */ - double getFrequencyError(); + float getFrequencyError(); /*! \brief Query modem for the packet length of received payload.