Fixed Quansheng's bug with 8.33khz stepping.

This commit is contained in:
Dual Tachyon 2023-09-15 21:10:15 +01:00
parent 86b737ca4d
commit ac5ff212ec
2 changed files with 19 additions and 0 deletions

View File

@ -381,6 +381,16 @@ void APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step)
uint32_t Frequency;
Frequency = pInfo->ConfigRX.Frequency + (Step * pInfo->StepFrequency);
if (pInfo->StepFrequency == 833) {
const uint32_t Lower = LowerLimitFrequencyBandTable[pInfo->Band];
const uint32_t Delta = Frequency - Lower;
const uint32_t Base = (Delta / 2500) * 2500;
const uint32_t Index = ((Delta - Base) % 2500) / 833;
Frequency = Lower + Base + (Index * 833);
}
if (Frequency > UpperLimitFrequencyBandTable[pInfo->Band]) {
pInfo->ConfigRX.Frequency = LowerLimitFrequencyBandTable[pInfo->Band];
} else if (Frequency < LowerLimitFrequencyBandTable[pInfo->Band]) {

View File

@ -121,7 +121,16 @@ uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower)
{
uint32_t Index;
if (Step == 833) {
const uint32_t Delta = Upper - Lower;
const uint32_t Base = (Delta / 2500) * 2500;
const uint32_t Index = ((Delta - Base) % 2500) / 833;
return Lower + Base + (Index * 833);
}
Index = (Upper - Lower) / Step;
return Lower + (Step * Index);
}