Skip to content

Commit

Permalink
feat: presets when entering to spectrum
Browse files Browse the repository at this point in the history
  • Loading branch information
fagci committed Oct 4, 2023
1 parent 310a54f commit 6193cdd
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,19 @@ static void Tick() {
}
}

static void AutomaticPresetChoose(uint32_t f) {
for (int i = 0; i < ARRAY_SIZE(freqPresets); ++i) {
FreqPreset p = freqPresets[i];
if (f >= p.fStart && f <= freqPresets[i].fEnd) {
currentFreq = p.fStart;
settings.scanStepIndex = p.stepSizeIndex;
settings.listenBw = p.listenBW;
settings.modulationType = p.modulationType;
settings.stepsCount = p.stepsCountIndex;
}
}
}

void APP_RunSpectrum() {
// TX here coz it always? set to active VFO
VFO_Info_t vfo = gEeprom.VfoInfo[gEeprom.TX_CHANNEL];
Expand All @@ -1379,6 +1392,8 @@ void APP_RunSpectrum() {
: BANDWIDTH_NARROW;
settings.modulationType = vfo.IsAM ? MOD_AM : MOD_FM;

AutomaticPresetChoose(currentFreq);

BackupRegisters();

redrawStatus = true;
Expand Down
35 changes: 35 additions & 0 deletions app/spectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,41 @@ typedef struct PeakInfo {
uint32_t f;
} PeakInfo;

typedef struct FreqPreset {
const char name[16];
const uint32_t fStart;
const uint32_t fEnd;
const StepsCount stepsCountIndex;
const uint8_t stepSizeIndex;
const ModulationType modulationType;
const BK4819_FilterBandwidth_t listenBW;
} FreqPreset;

static const FreqPreset freqPresets[] = {
{"CB", 2697500, 2785500, STEPS_128, S_STEP_5_0kHz, MOD_FM,
BK4819_FILTER_BW_NARROW},
{"17m", 1806800, 1831800, STEPS_128, S_STEP_1_0kHz, MOD_USB,
BK4819_FILTER_BW_NARROWER},
{"15m", 2100000, 2145000, STEPS_128, S_STEP_1_0kHz, MOD_USB,
BK4819_FILTER_BW_NARROWER},
{"12m", 2489000, 2514000, STEPS_128, S_STEP_1_0kHz, MOD_USB,
BK4819_FILTER_BW_NARROWER},
{"10m", 2800000, 2970000, STEPS_128, S_STEP_1_0kHz, MOD_USB,
BK4819_FILTER_BW_NARROWER},
{"2m", 14400000, 14600000, STEPS_128, S_STEP_25_0kHz, MOD_FM,
BK4819_FILTER_BW_NARROW},
{"AIR", 11800000, 13500000, STEPS_128, S_STEP_100_0kHz, MOD_AM,
BK4819_FILTER_BW_NARROW},
{"JD1", 15175000, 15400000, STEPS_128, S_STEP_25_0kHz, MOD_FM,
BK4819_FILTER_BW_NARROW},
{"JD2", 15500000, 15600000, STEPS_64, S_STEP_25_0kHz, MOD_FM,
BK4819_FILTER_BW_NARROW},
{"LPD", 43307500, 43477500, STEPS_128, S_STEP_25_0kHz, MOD_FM,
BK4819_FILTER_BW_NARROW},
{"PMR", 44600625, 44620000, STEPS_32, S_STEP_6_25kHz, MOD_FM,
BK4819_FILTER_BW_NARROW},
};

void APP_RunSpectrum(void);

#endif /* ifndef SPECTRUM_H */
Expand Down

0 comments on commit 6193cdd

Please sign in to comment.