From e29316c40e29280d67bc8dc21111b0c297ecbeaa Mon Sep 17 00:00:00 2001 From: Felix Rusu Date: Wed, 12 Feb 2025 21:20:36 -0500 Subject: [PATCH] revert to working getPowerLevel() --- RFM69.cpp | 31 +++---------------------------- RFM69.h | 5 ++--- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/RFM69.cpp b/RFM69.cpp index 4e55c34..f27cf52 100644 --- a/RFM69.cpp +++ b/RFM69.cpp @@ -290,33 +290,8 @@ uint8_t RFM69::getOutputPower() { return readReg(REG_PALEVEL) & 0x1F; } -uint8_t RFM69::getPowerLevel() { - uint8_t val = readReg(REG_PALEVEL); - uint8_t outputPower = getOutputPower(); - - bool pa0 = (val & 0b10000000) > 0; - bool pa1 = (val & 0b01000000) > 0; - bool pa2 = (val & 0b00100000) > 0; - - if (pa0 && !pa1 && !pa2) { - // -18 to 13 dBm range - return -18 + outputPower; - } - if (!pa0 && pa1 && !pa2) { - // -2 to 13 dBm range - return -18 + outputPower; - } - if (!pa0 && pa1 && pa2 && !_isRFM69HW) { - // 2 to 17 dBm range - return -14 + outputPower; - } - if (!pa0 && pa1 && pa2 && _isRFM69HW) { - // 5 to 20 dBm range - return -11 + outputPower; - } - - return 255; -} +// return stored _powerLevel +uint8_t RFM69::getPowerLevel() { return _powerLevel; } // Set TX Output power in dBm: // [-18..+13]dBm in RFM69 W/CW @@ -1351,4 +1326,4 @@ void RFM69::listenModeSendBurst(uint8_t targetNode, const void* buffer, uint8_t setMode(RF69_MODE_STANDBY); reinitRadio(); } -#endif +#endif \ No newline at end of file diff --git a/RFM69.h b/RFM69.h index d7661e4..6dada6d 100644 --- a/RFM69.h +++ b/RFM69.h @@ -232,12 +232,11 @@ class RFM69 { //void promiscuous(bool onOff=true); // replaced with spyMode() virtual void setHighPower(bool _isRFM69HW_HCW=true); // has to be called after initialize() for RFM69 HW/HCW bool isHighPower(); + virtual uint8_t getPowerLevel(); // get powerLevel virtual void setPowerLevel(uint8_t level); // reduce/increase transmit power level virtual int8_t setPowerDBm(int8_t dBm); // reduce/increase transmit power level, in dBm double dBm_to_mW(uint8_t dBm); // convert dBm to mW - uint8_t getOutputPower(); - uint8_t getPowerLevel(); // get powerLevel void sleep(); uint8_t readTemperature(uint8_t calFactor=0); // get CMOS temperature (8bit) void rcCalibration(); // calibrate the internal RC oscillator for use in wide temperature variations - see datasheet section [4.3.5. RC Timer Accuracy] @@ -342,4 +341,4 @@ class RFM69 { #endif }; -#endif +#endif \ No newline at end of file