Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reconcile implicit double / float promotion in math functions. #1199

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions src/modules/LR11x0/LR11x0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,47 +754,47 @@ int16_t LR11x0::setRxBandwidth(float rxBw) {
}*/

// check allowed receiver bandwidth values
if(fabs(rxBw - 4.8) <= 0.001) {
if(fabsf(rxBw - 4.8) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_4_8;
} else if(fabs(rxBw - 5.8) <= 0.001) {
} else if(fabsf(rxBw - 5.8) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_5_8;
} else if(fabs(rxBw - 7.3) <= 0.001) {
} else if(fabsf(rxBw - 7.3) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_7_3;
} else if(fabs(rxBw - 9.7) <= 0.001) {
} else if(fabsf(rxBw - 9.7) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_9_7;
} else if(fabs(rxBw - 11.7) <= 0.001) {
} else if(fabsf(rxBw - 11.7) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_11_7;
} else if(fabs(rxBw - 14.6) <= 0.001) {
} else if(fabsf(rxBw - 14.6) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_14_6;
} else if(fabs(rxBw - 19.5) <= 0.001) {
} else if(fabsf(rxBw - 19.5) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_19_5;
} else if(fabs(rxBw - 23.4) <= 0.001) {
} else if(fabsf(rxBw - 23.4) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_23_4;
} else if(fabs(rxBw - 29.3) <= 0.001) {
} else if(fabsf(rxBw - 29.3) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_29_3;
} else if(fabs(rxBw - 39.0) <= 0.001) {
} else if(fabsf(rxBw - 39.0) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_39_0;
} else if(fabs(rxBw - 46.9) <= 0.001) {
} else if(fabsf(rxBw - 46.9) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_46_9;
} else if(fabs(rxBw - 58.6) <= 0.001) {
} else if(fabsf(rxBw - 58.6) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_58_6;
} else if(fabs(rxBw - 78.2) <= 0.001) {
} else if(fabsf(rxBw - 78.2) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_78_2;
} else if(fabs(rxBw - 93.8) <= 0.001) {
} else if(fabsf(rxBw - 93.8) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_93_8;
} else if(fabs(rxBw - 117.3) <= 0.001) {
} else if(fabsf(rxBw - 117.3) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_117_3;
} else if(fabs(rxBw - 156.2) <= 0.001) {
} else if(fabsf(rxBw - 156.2) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_156_2;
} else if(fabs(rxBw - 187.2) <= 0.001) {
} else if(fabsf(rxBw - 187.2) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_187_2;
} else if(fabs(rxBw - 234.3) <= 0.001) {
} else if(fabsf(rxBw - 234.3) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_234_3;
} else if(fabs(rxBw - 312.0) <= 0.001) {
} else if(fabsf(rxBw - 312.0) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_312_0;
} else if(fabs(rxBw - 373.6) <= 0.001) {
} else if(fabsf(rxBw - 373.6) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_373_6;
} else if(fabs(rxBw - 467.0) <= 0.001) {
} else if(fabsf(rxBw - 467.0) <= 0.001) {
this->rxBandwidth = RADIOLIB_LR11X0_GFSK_RX_BW_467_0;
} else {
return(RADIOLIB_ERR_INVALID_RX_BANDWIDTH);
Expand Down Expand Up @@ -1070,28 +1070,28 @@ int16_t LR11x0::setTCXO(float voltage, uint32_t delay) {
}

// check 0 V disable
if(fabs(voltage - 0.0) <= 0.001) {
if(fabsf(voltage - 0.0) <= 0.001) {
setTcxoMode(0, 0);
return(reset());
}

// check allowed voltage values
uint8_t tune = 0;
if(fabs(voltage - 1.6) <= 0.001) {
if(fabsf(voltage - 1.6) <= 0.001) {
tune = RADIOLIB_LR11X0_TCXO_VOLTAGE_1_6;
} else if(fabs(voltage - 1.7) <= 0.001) {
} else if(fabsf(voltage - 1.7) <= 0.001) {
tune = RADIOLIB_LR11X0_TCXO_VOLTAGE_1_7;
} else if(fabs(voltage - 1.8) <= 0.001) {
} else if(fabsf(voltage - 1.8) <= 0.001) {
tune = RADIOLIB_LR11X0_TCXO_VOLTAGE_1_8;
} else if(fabs(voltage - 2.2) <= 0.001) {
} else if(fabsf(voltage - 2.2) <= 0.001) {
tune = RADIOLIB_LR11X0_TCXO_VOLTAGE_2_2;
} else if(fabs(voltage - 2.4) <= 0.001) {
} else if(fabsf(voltage - 2.4) <= 0.001) {
tune = RADIOLIB_LR11X0_TCXO_VOLTAGE_2_4;
} else if(fabs(voltage - 2.7) <= 0.001) {
} else if(fabsf(voltage - 2.7) <= 0.001) {
tune = RADIOLIB_LR11X0_TCXO_VOLTAGE_2_7;
} else if(fabs(voltage - 3.0) <= 0.001) {
} else if(fabsf(voltage - 3.0) <= 0.001) {
tune = RADIOLIB_LR11X0_TCXO_VOLTAGE_3_0;
} else if(fabs(voltage - 3.3) <= 0.001) {
} else if(fabsf(voltage - 3.3) <= 0.001) {
tune = RADIOLIB_LR11X0_TCXO_VOLTAGE_3_3;
} else {
return(RADIOLIB_ERR_INVALID_TCXO_VOLTAGE);
Expand Down Expand Up @@ -1265,7 +1265,7 @@ RadioLibTime_t LR11x0::getTimeOnAir(size_t len) {
uint32_t N_symbolPreamble = (this->preambleLengthLoRa & 0x0F) * (uint32_t(1) << ((this->preambleLengthLoRa & 0xF0) >> 4));

// calculate the number of symbols
N_symbol = (float)N_symbolPreamble + coeff1 + 8.0 + ceil(RADIOLIB_MAX((int16_t)(8 * len + N_bitCRC - coeff2 + N_symbolHeader), (int16_t)0) / (float)coeff3) * (float)(this->codingRate + 4);
N_symbol = (float)N_symbolPreamble + coeff1 + 8.0 + ceilf((float)RADIOLIB_MAX((int16_t)(8 * len + N_bitCRC - coeff2 + N_symbolHeader), (int16_t)0) / (float)coeff3) * (float)(this->codingRate + 4);

} else {
// long interleaving - abandon hope all ye who enter here
Expand Down Expand Up @@ -1791,6 +1791,7 @@ int16_t LR11x0::getGnssScanResult(uint16_t size) {
RADIOLIB_DEBUG_BASIC_PRINTLN("Timing:");
for(size_t i = 0; i < 31; i++) {
uint32_t t = (timing[i] * 1000UL) / 32768UL;
(void)t;
RADIOLIB_DEBUG_BASIC_PRINTLN(" %d: %lu ms", (int)i*4, (unsigned long)t);
}
RADIOLIB_DEBUG_BASIC_PRINTLN("constDemod: %d", constDemod);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/RF69/RF69.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ int16_t RF69::setRxBandwidth(float rxBw) {
for(int8_t e = 7; e >= 0; e--) {
for(int8_t m = 2; m >= 0; m--) {
float point = (RADIOLIB_RF69_CRYSTAL_FREQ * 1000000.0)/(((4 * m) + 16) * ((uint32_t)1 << (e + (this->ookEnabled ? 3 : 2))));
if(fabs(rxBw - (point / 1000.0)) <= 0.1) {
if(fabsf(rxBw - (point / 1000.0)) <= 0.1) {
// set Rx bandwidth
state = this->mod->SPIsetRegValue(RADIOLIB_RF69_REG_RX_BW, (m << 3) | e, 4, 0);
if(state == RADIOLIB_ERR_NONE) {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/SX123x/SX1233.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int16_t SX1233::begin(float freq, float br, float freqDev, float rxBw, int8_t po
int16_t SX1233::setBitRate(float br) {
// check high bit-rate operation
uint8_t pllBandwidth = RADIOLIB_SX1233_PLL_BW_LOW_BIT_RATE;
if((fabs(br - 500.0f) < 0.1) || (fabs(br - 600.0f) < 0.1)) {
if((fabsf(br - 500.0f) < 0.1) || (fabsf(br - 600.0f) < 0.1)) {
pllBandwidth = RADIOLIB_SX1233_PLL_BW_HIGH_BIT_RATE;
} else {
// datasheet says 1.2 kbps should be the smallest possible, but 0.512 works fine
Expand Down
62 changes: 31 additions & 31 deletions src/modules/SX126x/SX126x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,47 +1011,47 @@ int16_t SX126x::setRxBandwidth(float rxBw) {
this->rxBandwidthKhz = rxBw;

// check allowed receiver bandwidth values
if(fabs(rxBw - 4.8) <= 0.001) {
if(fabsf(rxBw - 4.8) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_4_8;
} else if(fabs(rxBw - 5.8) <= 0.001) {
} else if(fabsf(rxBw - 5.8) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_5_8;
} else if(fabs(rxBw - 7.3) <= 0.001) {
} else if(fabsf(rxBw - 7.3) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_7_3;
} else if(fabs(rxBw - 9.7) <= 0.001) {
} else if(fabsf(rxBw - 9.7) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_9_7;
} else if(fabs(rxBw - 11.7) <= 0.001) {
} else if(fabsf(rxBw - 11.7) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_11_7;
} else if(fabs(rxBw - 14.6) <= 0.001) {
} else if(fabsf(rxBw - 14.6) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_14_6;
} else if(fabs(rxBw - 19.5) <= 0.001) {
} else if(fabsf(rxBw - 19.5) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_19_5;
} else if(fabs(rxBw - 23.4) <= 0.001) {
} else if(fabsf(rxBw - 23.4) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_23_4;
} else if(fabs(rxBw - 29.3) <= 0.001) {
} else if(fabsf(rxBw - 29.3) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_29_3;
} else if(fabs(rxBw - 39.0) <= 0.001) {
} else if(fabsf(rxBw - 39.0) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_39_0;
} else if(fabs(rxBw - 46.9) <= 0.001) {
} else if(fabsf(rxBw - 46.9) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_46_9;
} else if(fabs(rxBw - 58.6) <= 0.001) {
} else if(fabsf(rxBw - 58.6) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_58_6;
} else if(fabs(rxBw - 78.2) <= 0.001) {
} else if(fabsf(rxBw - 78.2) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_78_2;
} else if(fabs(rxBw - 93.8) <= 0.001) {
} else if(fabsf(rxBw - 93.8) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_93_8;
} else if(fabs(rxBw - 117.3) <= 0.001) {
} else if(fabsf(rxBw - 117.3) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_117_3;
} else if(fabs(rxBw - 156.2) <= 0.001) {
} else if(fabsf(rxBw - 156.2) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_156_2;
} else if(fabs(rxBw - 187.2) <= 0.001) {
} else if(fabsf(rxBw - 187.2) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_187_2;
} else if(fabs(rxBw - 234.3) <= 0.001) {
} else if(fabsf(rxBw - 234.3) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_234_3;
} else if(fabs(rxBw - 312.0) <= 0.001) {
} else if(fabsf(rxBw - 312.0) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_312_0;
} else if(fabs(rxBw - 373.6) <= 0.001) {
} else if(fabsf(rxBw - 373.6) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_373_6;
} else if(fabs(rxBw - 467.0) <= 0.001) {
} else if(fabsf(rxBw - 467.0) <= 0.001) {
this->rxBandwidth = RADIOLIB_SX126X_GFSK_RX_BW_467_0;
} else {
return(RADIOLIB_ERR_INVALID_RX_BANDWIDTH);
Expand Down Expand Up @@ -1699,27 +1699,27 @@ int16_t SX126x::setTCXO(float voltage, uint32_t delay) {
}

// check 0 V disable
if(fabs(voltage - 0.0) <= 0.001) {
if(fabsf(voltage - 0.0) <= 0.001) {
return(reset(true));
}

// check alowed voltage values
uint8_t data[4];
if(fabs(voltage - 1.6) <= 0.001) {
if(fabsf(voltage - 1.6) <= 0.001) {
data[0] = RADIOLIB_SX126X_DIO3_OUTPUT_1_6;
} else if(fabs(voltage - 1.7) <= 0.001) {
} else if(fabsf(voltage - 1.7) <= 0.001) {
data[0] = RADIOLIB_SX126X_DIO3_OUTPUT_1_7;
} else if(fabs(voltage - 1.8) <= 0.001) {
} else if(fabsf(voltage - 1.8) <= 0.001) {
data[0] = RADIOLIB_SX126X_DIO3_OUTPUT_1_8;
} else if(fabs(voltage - 2.2) <= 0.001) {
} else if(fabsf(voltage - 2.2) <= 0.001) {
data[0] = RADIOLIB_SX126X_DIO3_OUTPUT_2_2;
} else if(fabs(voltage - 2.4) <= 0.001) {
} else if(fabsf(voltage - 2.4) <= 0.001) {
data[0] = RADIOLIB_SX126X_DIO3_OUTPUT_2_4;
} else if(fabs(voltage - 2.7) <= 0.001) {
} else if(fabsf(voltage - 2.7) <= 0.001) {
data[0] = RADIOLIB_SX126X_DIO3_OUTPUT_2_7;
} else if(fabs(voltage - 3.0) <= 0.001) {
} else if(fabsf(voltage - 3.0) <= 0.001) {
data[0] = RADIOLIB_SX126X_DIO3_OUTPUT_3_0;
} else if(fabs(voltage - 3.3) <= 0.001) {
} else if(fabsf(voltage - 3.3) <= 0.001) {
data[0] = RADIOLIB_SX126X_DIO3_OUTPUT_3_3;
} else {
return(RADIOLIB_ERR_INVALID_TCXO_VOLTAGE);
Expand Down Expand Up @@ -2038,7 +2038,7 @@ int16_t SX126x::fixSensitivity() {
RADIOLIB_ASSERT(state);

// fix the value for LoRa with 500 kHz bandwidth
if((getPacketType() == RADIOLIB_SX126X_PACKET_TYPE_LORA) && (fabs(this->bandwidthKhz - 500.0) <= 0.001)) {
if((getPacketType() == RADIOLIB_SX126X_PACKET_TYPE_LORA) && (fabsf(this->bandwidthKhz - 500.0) <= 0.001)) {
sensitivityConfig &= 0xFB;
} else {
sensitivityConfig |= 0x04;
Expand Down
6 changes: 3 additions & 3 deletions src/modules/SX127x/SX1272.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ int16_t SX1272::setBandwidth(float bw) {
uint8_t newBandwidth;

// check allowed bandwidth values
if(fabs(bw - 125.0) <= 0.001) {
if(fabsf(bw - 125.0) <= 0.001) {
newBandwidth = RADIOLIB_SX1272_BW_125_00_KHZ;
} else if(fabs(bw - 250.0) <= 0.001) {
} else if(fabsf(bw - 250.0) <= 0.001) {
newBandwidth = RADIOLIB_SX1272_BW_250_00_KHZ;
} else if(fabs(bw - 500.0) <= 0.001) {
} else if(fabsf(bw - 500.0) <= 0.001) {
newBandwidth = RADIOLIB_SX1272_BW_500_00_KHZ;
} else {
return(RADIOLIB_ERR_INVALID_BANDWIDTH);
Expand Down
42 changes: 21 additions & 21 deletions src/modules/SX127x/SX1278.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,25 @@ int16_t SX1278::setBandwidth(float bw) {
uint8_t newBandwidth;

// check allowed bandwidth values
if(fabs(bw - 7.8) <= 0.001) {
if(fabsf(bw - 7.8) <= 0.001) {
newBandwidth = RADIOLIB_SX1278_BW_7_80_KHZ;
} else if(fabs(bw - 10.4) <= 0.001) {
} else if(fabsf(bw - 10.4) <= 0.001) {
newBandwidth = RADIOLIB_SX1278_BW_10_40_KHZ;
} else if(fabs(bw - 15.6) <= 0.001) {
} else if(fabsf(bw - 15.6) <= 0.001) {
newBandwidth = RADIOLIB_SX1278_BW_15_60_KHZ;
} else if(fabs(bw - 20.8) <= 0.001) {
} else if(fabsf(bw - 20.8) <= 0.001) {
newBandwidth = RADIOLIB_SX1278_BW_20_80_KHZ;
} else if(fabs(bw - 31.25) <= 0.001) {
} else if(fabsf(bw - 31.25) <= 0.001) {
newBandwidth = RADIOLIB_SX1278_BW_31_25_KHZ;
} else if(fabs(bw - 41.7) <= 0.001) {
} else if(fabsf(bw - 41.7) <= 0.001) {
newBandwidth = RADIOLIB_SX1278_BW_41_70_KHZ;
} else if(fabs(bw - 62.5) <= 0.001) {
} else if(fabsf(bw - 62.5) <= 0.001) {
newBandwidth = RADIOLIB_SX1278_BW_62_50_KHZ;
} else if(fabs(bw - 125.0) <= 0.001) {
} else if(fabsf(bw - 125.0) <= 0.001) {
newBandwidth = RADIOLIB_SX1278_BW_125_00_KHZ;
} else if(fabs(bw - 250.0) <= 0.001) {
} else if(fabsf(bw - 250.0) <= 0.001) {
newBandwidth = RADIOLIB_SX1278_BW_250_00_KHZ;
} else if(fabs(bw - 500.0) <= 0.001) {
} else if(fabsf(bw - 500.0) <= 0.001) {
newBandwidth = RADIOLIB_SX1278_BW_500_00_KHZ;
} else {
return(RADIOLIB_ERR_INVALID_BANDWIDTH);
Expand Down Expand Up @@ -623,7 +623,7 @@ void SX1278::errataFix(bool rx) {
// sensitivity optimization for 500kHz bandwidth
// see SX1276/77/78 Errata, section 2.1 for details
Module* mod = this->getMod();
if(fabs(SX127x::bandwidth - 500.0) <= 0.001) {
if(fabsf(SX127x::bandwidth - 500.0) <= 0.001) {
if((frequency >= 862.0) && (frequency <= 1020.0)) {
mod->SPIwriteRegister(0x36, 0x02);
mod->SPIwriteRegister(0x3a, 0x64);
Expand All @@ -639,49 +639,49 @@ void SX1278::errataFix(bool rx) {
// figure out what we need to set
uint8_t fixedRegs[3] = { 0x00, 0x00, 0x00 };
float rxFreq = frequency;
if(fabs(SX127x::bandwidth - 7.8) <= 0.001) {
if(fabsf(SX127x::bandwidth - 7.8) <= 0.001) {
fixedRegs[0] = 0b00000000;
fixedRegs[1] = 0x48;
fixedRegs[2] = 0x00;
rxFreq += 0.00781;
} else if(fabs(SX127x::bandwidth - 10.4) <= 0.001) {
} else if(fabsf(SX127x::bandwidth - 10.4) <= 0.001) {
fixedRegs[0] = 0b00000000;
fixedRegs[1] = 0x44;
fixedRegs[2] = 0x00;
rxFreq += 0.01042;
} else if(fabs(SX127x::bandwidth - 15.6) <= 0.001) {
} else if(fabsf(SX127x::bandwidth - 15.6) <= 0.001) {
fixedRegs[0] = 0b00000000;
fixedRegs[1] = 0x44;
fixedRegs[2] = 0x00;
rxFreq += 0.01562;
} else if(fabs(SX127x::bandwidth - 20.8) <= 0.001) {
} else if(fabsf(SX127x::bandwidth - 20.8) <= 0.001) {
fixedRegs[0] = 0b00000000;
fixedRegs[1] = 0x44;
fixedRegs[2] = 0x00;
rxFreq += 0.02083;
} else if(fabs(SX127x::bandwidth - 31.25) <= 0.001) {
} else if(fabsf(SX127x::bandwidth - 31.25) <= 0.001) {
fixedRegs[0] = 0b00000000;
fixedRegs[1] = 0x44;
fixedRegs[2] = 0x00;
rxFreq += 0.03125;
} else if(fabs(SX127x::bandwidth - 41.7) <= 0.001) {
} else if(fabsf(SX127x::bandwidth - 41.7) <= 0.001) {
fixedRegs[0] = 0b00000000;
fixedRegs[1] = 0x44;
fixedRegs[2] = 0x00;
rxFreq += 0.04167;
} else if(fabs(SX127x::bandwidth - 62.5) <= 0.001) {
} else if(fabsf(SX127x::bandwidth - 62.5) <= 0.001) {
fixedRegs[0] = 0b00000000;
fixedRegs[1] = 0x40;
fixedRegs[2] = 0x00;
} else if(fabs(SX127x::bandwidth - 125.0) <= 0.001) {
} else if(fabsf(SX127x::bandwidth - 125.0) <= 0.001) {
fixedRegs[0] = 0b00000000;
fixedRegs[1] = 0x40;
fixedRegs[2] = 0x00;
} else if(fabs(SX127x::bandwidth - 250.0) <= 0.001) {
} else if(fabsf(SX127x::bandwidth - 250.0) <= 0.001) {
fixedRegs[0] = 0b00000000;
fixedRegs[1] = 0x40;
fixedRegs[2] = 0x00;
} else if(fabs(SX127x::bandwidth - 500.0) <= 0.001) {
} else if(fabsf(SX127x::bandwidth - 500.0) <= 0.001) {
fixedRegs[0] = 0b10000000;
fixedRegs[1] = mod->SPIreadRegister(0x2F);
fixedRegs[2] = mod->SPIreadRegister(0x30);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/SX127x/SX127x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ uint8_t SX127x::calculateBWManExp(float bandwidth)
for(uint8_t e = 7; e >= 1; e--) {
for(int8_t m = 2; m >= 0; m--) {
float point = (RADIOLIB_SX127X_CRYSTAL_FREQ * 1000000.0)/(((4 * m) + 16) * ((uint32_t)1 << (e + 2)));
if(fabs(bandwidth - ((point / 1000.0) + 0.05)) <= 0.5) {
if(fabsf(bandwidth - ((point / 1000.0) + 0.05)) <= 0.5) {
return((m << 3) | e);
}
}
Expand Down Expand Up @@ -1244,7 +1244,7 @@ float SX127x::getNumSymbols(size_t len) {
float n_pre = (float) ((this->mod->SPIgetRegValue(RADIOLIB_SX127X_REG_PREAMBLE_MSB) << 8) | this->mod->SPIgetRegValue(RADIOLIB_SX127X_REG_PREAMBLE_LSB));

// get number of payload symbols
float n_pay = 8.0 + RADIOLIB_MAX(ceil((8.0 * (float) len - 4.0 * (float) this->spreadingFactor + 28.0 + 16.0 * crc - 20.0 * ih) / (4.0 * (float) this->spreadingFactor - 8.0 * de)) * (float) this->codingRate, 0.0);
float n_pay = 8.0 + RADIOLIB_MAX(ceilf((8.0 * (float) len - 4.0 * (float) this->spreadingFactor + 28.0 + 16.0 * crc - 20.0 * ih) / (4.0 * (float) this->spreadingFactor - 8.0 * de)) * (float) this->codingRate, 0.0);

// add 4.25 symbols for the sync
return(n_pre + n_pay + 4.25f);
Expand Down
Loading
Loading