[SX128x] Added -1 as alias for lowest supported frequency deviation

pull/261/head
jgromes 2021-02-13 17:42:00 +01:00
rodzic ed4d6e8897
commit f4b2b6d257
1 zmienionych plików z 9 dodań i 3 usunięć

Wyświetl plik

@ -802,17 +802,23 @@ int16_t SX128x::setFrequencyDeviation(float freqDev) {
return(ERR_WRONG_MODEM);
}
RADIOLIB_CHECK_RANGE(freqDev, 0.0, 3200.0, ERR_INVALID_FREQUENCY_DEVIATION);
// set frequency deviation to lowest available setting (required for digimodes)
float newFreqDev = freqDev;
if(freqDev < 0.0) {
newFreqDev = 62.5;
}
RADIOLIB_CHECK_RANGE(newFreqDev, 62.5, 1000.0, ERR_INVALID_FREQUENCY_DEVIATION);
// override for the lowest possible frequency deviation - required for some PhysicalLayer protocols
if(freqDev == 0.0) {
if(newFreqDev == 0.0) {
_modIndex = SX128X_BLE_GFSK_MOD_IND_0_35;
_br = SX128X_BLE_GFSK_BR_0_125_BW_0_3;
return(setModulationParams(_br, _modIndex, _shaping));
}
// update modulation parameters
uint8_t modIndex = (uint8_t)((8.0 * (freqDev / (float)_brKbps)) - 1.0);
uint8_t modIndex = (uint8_t)((8.0 * (newFreqDev / (float)_brKbps)) - 1.0);
if(modIndex > SX128X_BLE_GFSK_MOD_IND_4_00) {
return(ERR_INVALID_MODULATION_PARAMETERS);
}