Reconcile implicit double / float promotion with math functions and passed function value types. Also suppress incorrect unused variable warnings when variables are used in logging macros.

This commit is contained in:
Pavlo Manovi 2024-08-29 09:30:31 -04:00
parent 0abb7512fc
commit 6847fcda5c
10 changed files with 116 additions and 115 deletions

View file

@ -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);
@ -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);
@ -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
@ -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);

View file

@ -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) {

View file

@ -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

View file

@ -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);
@ -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);
@ -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;

View file

@ -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);

View file

@ -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);
@ -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);
@ -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);

View file

@ -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);
}
}
@ -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);

View file

@ -734,13 +734,13 @@ int16_t SX128x::setBandwidth(float bw) {
return(RADIOLIB_ERR_WRONG_MODEM);
}
if(fabs(bw - 203.125) <= 0.001) {
if(fabsf(bw - 203.125) <= 0.001) {
this->bandwidth = RADIOLIB_SX128X_LORA_BW_203_125;
} else if(fabs(bw - 406.25) <= 0.001) {
} else if(fabsf(bw - 406.25) <= 0.001) {
this->bandwidth = RADIOLIB_SX128X_LORA_BW_406_25;
} else if(fabs(bw - 812.5) <= 0.001) {
} else if(fabsf(bw - 812.5) <= 0.001) {
this->bandwidth = RADIOLIB_SX128X_LORA_BW_812_50;
} else if(fabs(bw - 1625.0) <= 0.001) {
} else if(fabsf(bw - 1625.0) <= 0.001) {
this->bandwidth = RADIOLIB_SX128X_LORA_BW_1625_00;
} else {
return(RADIOLIB_ERR_INVALID_BANDWIDTH);
@ -1349,7 +1349,7 @@ RadioLibTime_t SX128x::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->codingRateLoRa + 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->codingRateLoRa + 4);
} else {
// long interleaving - abandon hope all ye who enter here

View file

@ -426,63 +426,63 @@ int16_t Si443x::setRxBandwidth(float rxBw) {
// this is the "Lord help thee who tread 'ere" section - no way to approximate this mess
/// \todo float tolerance equality as macro?
} else if(fabs(rxBw - 142.8) <= 0.001) {
} else if(fabsf(rxBw - 142.8) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 1;
filterSet = 4;
} else if(fabs(rxBw - 167.8) <= 0.001) {
} else if(fabsf(rxBw - 167.8) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 1;
filterSet = 5;
} else if(fabs(rxBw - 181.1) <= 0.001) {
} else if(fabsf(rxBw - 181.1) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 1;
filterSet = 6;
} else if(fabs(rxBw - 191.5) <= 0.001) {
} else if(fabsf(rxBw - 191.5) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 15;
} else if(fabs(rxBw - 225.1) <= 0.001) {
} else if(fabsf(rxBw - 225.1) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 1;
} else if(fabs(rxBw - 248.8) <= 0.001) {
} else if(fabsf(rxBw - 248.8) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 2;
} else if(fabs(rxBw - 269.3) <= 0.001) {
} else if(fabsf(rxBw - 269.3) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 3;
} else if(fabs(rxBw - 284.8) <= 0.001) {
} else if(fabsf(rxBw - 284.8) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 4;
} else if(fabs(rxBw -335.5) <= 0.001) {
} else if(fabsf(rxBw -335.5) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 8;
} else if(fabs(rxBw - 391.8) <= 0.001) {
} else if(fabsf(rxBw - 391.8) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 9;
} else if(fabs(rxBw - 420.2) <= 0.001) {
} else if(fabsf(rxBw - 420.2) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 10;
} else if(fabs(rxBw - 468.4) <= 0.001) {
} else if(fabsf(rxBw - 468.4) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 11;
} else if(fabs(rxBw - 518.8) <= 0.001) {
} else if(fabsf(rxBw - 518.8) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 12;
} else if(fabs(rxBw - 577.0) <= 0.001) {
} else if(fabsf(rxBw - 577.0) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 13;
} else if(fabs(rxBw - 620.7) <= 0.001) {
} else if(fabsf(rxBw - 620.7) <= 0.001) {
bypass = RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON;
decRate = 0;
filterSet = 14;

View file

@ -248,8 +248,8 @@ size_t RadioLibPrint::printFloat(double number, uint8_t digits) {
char code[] = {0x00, 0x00, 0x00, 0x00};
if (isnan(number)) strcpy(code, "nan");
if (isinf(number)) strcpy(code, "inf");
if (number > 4294967040.0) strcpy(code, "ovf"); // constant determined empirically
if (number <-4294967040.0) strcpy(code, "ovf"); // constant determined empirically
if (number > (double)4294967040.0) strcpy(code, "ovf"); // constant determined empirically
if (number < (double)-4294967040.0) strcpy(code, "ovf"); // constant determined empirically
if(code[0] != 0x00) {
if(this->encoding == RADIOLIB_ITA2) {
@ -264,7 +264,7 @@ size_t RadioLibPrint::printFloat(double number, uint8_t digits) {
}
// Handle negative numbers
if (number < 0.0) {
if (number < (double)0.0) {
if(this->encoding == RADIOLIB_ITA2) {
ITA2String ita2 = ITA2String("-");
uint8_t* arr = ita2.byteArr();
@ -279,7 +279,7 @@ size_t RadioLibPrint::printFloat(double number, uint8_t digits) {
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for(uint8_t i = 0; i < digits; ++i) {
rounding /= 10.0;
rounding /= (double)10.0;
}
number += rounding;
@ -302,7 +302,7 @@ size_t RadioLibPrint::printFloat(double number, uint8_t digits) {
// Extract digits from the remainder one at a time
while(digits-- > 0) {
remainder *= 10.0;
remainder *= (double) 10.0;
unsigned int toPrint = (unsigned int)(remainder);
n += RadioLibPrint::print(toPrint);
remainder -= toPrint;