From 6193cdd59b589abe4fed3eb031c388d09a7bf71c Mon Sep 17 00:00:00 2001 From: Mikhail Yudin Date: Thu, 5 Oct 2023 01:17:17 +0700 Subject: [PATCH] feat: presets when entering to spectrum --- app/spectrum.c | 15 +++++++++++++++ app/spectrum.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/app/spectrum.c b/app/spectrum.c index 12844db..7602409 100644 --- a/app/spectrum.c +++ b/app/spectrum.c @@ -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]; @@ -1379,6 +1392,8 @@ void APP_RunSpectrum() { : BANDWIDTH_NARROW; settings.modulationType = vfo.IsAM ? MOD_AM : MOD_FM; + AutomaticPresetChoose(currentFreq); + BackupRegisters(); redrawStatus = true; diff --git a/app/spectrum.h b/app/spectrum.h index aee5cd5..04013a4 100644 --- a/app/spectrum.h +++ b/app/spectrum.h @@ -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 */