Skip to content

Commit

Permalink
Rig Widget: RIT/XIT are displayed with user-friendly units
Browse files Browse the repository at this point in the history
  • Loading branch information
foldynl committed Dec 17, 2023
1 parent 54cc975 commit 78a2415
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ TBC - 0.31.0
- [NEW] - Main Window - Current profile name is shown (issue #282)
- [NEW] - Import - Details can be saved to file (issue #284)
- [NEW] - Added Simplified Chinese translation (PR #285 thank BG7JAF)
- [NEW] - RIG Widget - RIT/XIT are displayed with user-friendly units.
- Fixed Missing Satellite Mode SX (issue #291)

2023/12/01 - 0.30.0
Expand Down
32 changes: 32 additions & 0 deletions data/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,38 @@ QString Data::dbFilename()
return dir.filePath("qlog.db");
}

double Data::MHz2UserFriendlyFreq(double freqMHz,
QString &unit,
unsigned char &efectiveDecP)
{
FCT_IDENTIFICATION;

if ( freqMHz < 0.001 )
{
unit = tr("Hz");
efectiveDecP = 0;
return freqMHz * 1000000.0;
}

if ( freqMHz < 1 )
{
unit = tr("kHz");
efectiveDecP = 3;
return freqMHz * 1000.0;
}

if ( freqMHz >= 1000 )
{
unit = tr("GHz");
efectiveDecP = 3;
return freqMHz / 1000.0;
}

unit = tr("MHz");
efectiveDecP = 3;
return freqMHz;
}

QPair<QString, QString> Data::legacyMode(const QString &mode)
{
FCT_IDENTIFICATION;
Expand Down
3 changes: 3 additions & 0 deletions data/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class Data : public QObject
static int getCQZMin();
static int getCQZMax();
static QString dbFilename();
static double MHz2UserFriendlyFreq(double,
QString &unit,
unsigned char &efectiveDecP);

QStringList contestList() { return contests.values(); }
QStringList propagationModesList() { return propagationModes.values(); }
Expand Down
12 changes: 10 additions & 2 deletions ui/RigWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ void RigWidget::updateXIT(VFOID, double xit)
if ( xit != 0.0 )
{
ui->xitOffset->setVisible(true);
ui->xitOffset->setText(QString("XIT: %1 MHz").arg(QSTRING_FREQ(xit)));
QString unit;
unsigned char decP;
double xitDisplay = Data::MHz2UserFriendlyFreq(xit, unit, decP);
ui->xitOffset->setText(QString("XIT: %1 %2").arg(QString::number(xitDisplay, 'f', decP),
unit));
}
else
{
Expand All @@ -162,7 +166,11 @@ void RigWidget::updateRIT(VFOID, double rit)
if ( rit != 0.0 )
{
ui->ritOffset->setVisible(true);
ui->ritOffset->setText(QString("RIT: %1 MHz").arg(QSTRING_FREQ(rit)));
QString unit;
unsigned char decP;
double ritDisplay = Data::MHz2UserFriendlyFreq(rit, unit, decP);
ui->ritOffset->setText(QString("RIT: %1 %2").arg(QString::number(ritDisplay, 'f', decP),
unit));
}
else
{
Expand Down

0 comments on commit 78a2415

Please sign in to comment.