diff options
-rw-r--r-- | rtlfmradiotunercontrol.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/rtlfmradiotunercontrol.cpp b/rtlfmradiotunercontrol.cpp index 99054ac..a50b3ef 100644 --- a/rtlfmradiotunercontrol.cpp +++ b/rtlfmradiotunercontrol.cpp @@ -15,6 +15,13 @@ #include <QtCore/QTimer> #include <QtCore/QSettings> +// Structure to describe FM band plans, all values in Hz. +struct fmBandPlan { + unsigned int minFreq; + unsigned int maxFreq; + unsigned int freqStep; +}; + class RtlFmRadioTunerControl::Private { public: @@ -39,12 +46,12 @@ public: bool searchOne; int step; bool present; - QPair<int, int> fmBandPlan; + struct fmBandPlan fmBandPlan; private: - QMap<QString, QPair<int, int> > knownFmBandPlans = { - { QString::fromUtf8("US"), qMakePair(87900000, 107900000) }, - { QString::fromUtf8("JP"), qMakePair(76100000, 89900000) } + QMap<QString, struct fmBandPlan> knownFmBandPlans = { + { QString::fromUtf8("US"), { .minFreq = 87900000, .maxFreq = 107900000, .freqStep = 200000 } }, + { QString::fromUtf8("JP"), { .minFreq = 76100000, .maxFreq = 89900000, .freqStep = 100000 } } }; static void output_thread_fn(int16_t *result, int result_len, void *ctx); @@ -102,7 +109,7 @@ RtlFmRadioTunerControl::Private::Private(RtlFmRadioTunerControl *parent) fmBandPlan = knownFmBandPlans.value(settings.value("fmbandplan").toString()); // Initialize frequency to lower bound of band plan - frequency = fmBandPlan.first; + frequency = fmBandPlan.minFreq; connect(q, &RtlFmRadioTunerControl::stationFound, [this](int frequency, const QString &name) { qDebug() << frequency << name; @@ -193,7 +200,7 @@ int RtlFmRadioTunerControl::frequencyStep(QRadioTuner::Band band) const ret = 1000; // 1 kHz break; case QRadioTuner::FM: - ret = 100000; // 0.1 MHz + ret = d->fmBandPlan.freqStep; break; default: break; @@ -210,7 +217,7 @@ QPair<int,int> RtlFmRadioTunerControl::frequencyRange(QRadioTuner::Band band) co ret = qMakePair<int,int>(531000, 1602000); break; case QRadioTuner::FM: - ret = QPair<int,int>(d->fmBandPlan); + ret = qMakePair<int,int>(d->fmBandPlan.minFreq, d->fmBandPlan.maxFreq); break; default: break; |