Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Fixed Quansheng's bug with 8.33khz stepping.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dual Tachyon authored and Dual Tachyon committed Sep 28, 2023
1 parent 9708a6f commit dadd182
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
9 changes: 9 additions & 0 deletions frequencies.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit dadd182

Please sign in to comment.