summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2016-12-28 14:18:00 -0500
committerScott Murray <scott.murray@konsulko.com>2016-12-28 14:18:00 -0500
commita275be6e611e359463c9b62567519dff8c561a05 (patch)
treee5291a7c40c9f5753d7dfeb46026914d47e13a90
parentdd5b6ee9df26b64f48b59dba702b4ca64cff4fba (diff)
Use 200 KHz frequency steps for North American FM band plan
Improved the FM band plan description scheme so it can include the frequency step, and set the North American band plan to use 200 KHz as the step size to match expected radio behavior. The Japan band plan is set to still use 100 KHz, as that seems to be accurate for the FM band in that locale. Beyond matching expectations of actual North American car radio behavior, the user benefit of this change is less button pressing and exposure to static or dead air in the higher level application. Change-Id: Ic3474ae8a8e96702efbcf1ea63703c7ea59d2dca Signed-off-by: Scott Murray <scott.murray@konsulko.com>
-rw-r--r--rtlfmradiotunercontrol.cpp21
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;